Esempio n. 1
0
        public static Login ConvertToEntity(this AccountEditViewModel entity, Login login)
        {
            if (entity == null)
            {
                throw new Exception("Account not found");
            }

            login.Email     = entity.Email;
            login.Email2    = entity.Email2;
            login.Username  = entity.UserName;
            login.MemberPIN = entity.MemberPIN;
            return(login);
        }
Esempio n. 2
0
 public ActionResult Edit(AccountEditViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         Login login = _dataService.GetLoginById(viewModel.LoginId);
         if (login.Username != viewModel.UserName &&
             _dataService.GetLoginByUsername(viewModel.UserName) != null)
         {
             ModelState.AddModelError("UserName", "An Account with this username already exists in the database");
         }
         else
         {
             _dataService.UpdateLoginInfo(viewModel.ConvertToEntity(login));
             return RedirectToAction("Index");
         }
     }
     return View(viewModel);
 }