Пример #1
0
 public ActionResult Edit(int? id)
 {
     if (id == null)
         return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest);
     Account account = repository.Get(id.Value);
     if (account == null)
         return new HttpStatusCodeResult(System.Net.HttpStatusCode.NotFound);
     AccountEditViewModel model = new AccountEditViewModel() { Account = account };
     return View(model);
 }
Пример #2
0
        public ActionResult Edit(Account account)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    repository.Edit(account);
                    repository.SaveChanges();
                    return RedirectToAction("Index");
                }
            }
            catch (Exception e)
            {
                Log.Write(e);
                ModelState.AddModelError("", "Unable to save changes");
            }

            AccountEditViewModel evm = new AccountEditViewModel() { Account = account };
            return View(evm);
        }