public ActionResult Delete(AccountViewModel account) { try { accountService.Delete(account); accountService.SaveChanges(); return RedirectToAction("Index"); } catch { ModelState.AddModelError("", "Unable to save changes"); } return View(account); }
/// <summary> /// Обновление аккаунта /// </summary> /// <param name="account"></param> public void Edit(AccountViewModel account) { repository.Update(Convert(account)); }
/// <summary> /// Удаление аккаунта /// </summary> /// <param name="account"></param> public void Delete(AccountViewModel account) { repository.Delete(Convert(account)); }
/// <summary> /// Добавление аккаунта в репозиторий /// </summary> /// <param name="account"></param> public void Add(AccountViewModel account) { repository.Add(Convert(account)); }
/// <summary> /// Конвертационные функции /// </summary> private User Convert(AccountViewModel c) { return new User() { Id = c.Id, Login = c.Login, Email = c.Email, PasswordHash = c.Password, Role = c.Role, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now, Status = System.Convert.ToByte(c.IsActive) }; }
public ActionResult Edit(AccountViewModel account) { try { if (ModelState.IsValid) { account.Password = hasher.Hash(account.Password); accountService.Edit(account); accountService.SaveChanges(); return RedirectToAction("Index"); } } catch (Exception e) { ModelState.AddModelError("", "Unable to save changes"); } return View(account); }
public ActionResult New() { AccountViewModel model = new AccountViewModel(); return View(model); }