public IActionResult Add() { AddViewModel vm = new AddViewModel(); vm.Init(UserId, Request.Cookies["DateOfAddingExpense"]); return(View(vm)); }
public IActionResult Add(AddViewModel vm) { if (!ModelState.IsValid) { vm.Init(UserId, Request.Cookies["DateOfAddingExpense"]); return(View(vm)); } new AddingExpenseService().Add(vm, UserId); Response.Cookies.Append("DateOfAddingExpense", vm.Date.ToString(), new CookieOptions() { Expires = DateTime.Now.AddDays(7) }); TempData["SuccessMessage"] = "Wydatek zostaĆ dodany"; return(RedirectToAction(nameof(Add))); }