使用asp.net mvc,用戶更新他的個人資料。這是我的更新行爲看起來如何:行動完成後,您如何給予用戶反饋?
[HttpPost]
public ActionResult EditUser(string id, UserEditViewModel model)
{
Mapper.CreateMap<UserEditViewModel, SimpleUser>();
var user = Mapper.Map<UserEditViewModel, SimpleUser>(model);
userService.EditUser(user);
//Re-populating the countries.
var countries = geoService.GetCountries();
model.Countries = countries.Select(c => new SelectListItem { Text = c.Name, Value = c.CountryId.ToString() });
return View(model);
}
首先,我這樣做是正確的嗎?通過編寫兩次填充代碼的國家(GET中1個,此處1個)。
其次,我如何給用戶某種形式的反饋,他們已經成功地更新了他們的個人資料?
只需在模型中添加一個標誌即可切換「更新成功」消息。或者可能是一個布爾和一個字符串,所以你也可以呈現某種錯誤信息。 – R0MANARMY 2011-04-27 01:36:14