public ActionResult ChangeNegativeFormat() { ChangeNegativeFormatViewModel vm = new ChangeNegativeFormatViewModel(); vm.FormatList.Add(0, "Parenthesis: ($100.00)"); vm.FormatList.Add(1, "Negative: -$100.00"); return(View(vm)); }
public async Task <ActionResult> ChangeNegativeFormat(ChangeNegativeFormatViewModel vm) { if (!ModelState.IsValid) { vm.FormatList.Add(0, "Parenthesis: ($100.00)"); vm.FormatList.Add(1, "Negative: -$100.00"); return(View(vm)); } else { var user = db.Users.Find(User.Identity.GetUserId()); if (!(vm.FormatSelection < 0 || vm.FormatSelection > 1)) { user.NegFormatId = vm.FormatSelection.Value; } db.Entry(user).State = EntityState.Modified; db.SaveChanges(); await ControllerContext.HttpContext.RefreshAuthentication(user); return(RedirectToAction("Index")); } }