public async Task <IActionResult> ChangeAccountType(ChangeAccountTypeViewModel model) { if (ModelState.IsValid) { var r = await _accountService.ChangeAccountType(CurrentUser.Id, model, CurrentUser.Username); if (r) { await ReSignIn(CurrentUser.Id); this.AddAlert(true); return(RedirectToAction("ChangeAccountType")); } } return(View(model)); }
public async Task <bool> ChangeAccountType(int id, ChangeAccountTypeViewModel model, string username) { var entity = await _accountRepository.GetByIdAsync(id, false); if (entity != null) { entity.Type = model.Type; if (model.Type == AccountType.HotMom) { entity.TypeData = JsonConvert.SerializeObject(model.HotMomData); } entity.DateModified = DateTime.Now; entity.UserModified = username; await _accountRepository.UpdateAsync(entity); return(true); } return(false); }