public async Task <ActionResult> Edit(YearResource yearResource) { if (ModelState.IsValid) { var existingYear = await _yearService.GetByIdAsync(yearResource.Id); existingYear.Year = yearResource.Year; existingYear.Status = yearResource.Status; existingYear.UpdatedDate = DateTime.Now; var userId = System.Web.HttpContext.Current.User.Identity.GetUserId(); existingYear.UserId = userId; await _yearService.UpdateAsync(existingYear); _yearService.UnitOfWorkSaveChanges(); return(RedirectToAction("Index")); } return(View(yearResource)); }
public async Task <ActionResult> Create(YearResource yearResource) { if (ModelState.IsValid) { var yearDetails = Mapper.Map <YearResource, YearDetails>(yearResource); yearDetails.CreatedDate = DateTime.Now; yearDetails.UpdatedDate = DateTime.Now; var userId = System.Web.HttpContext.Current.User.Identity.GetUserId(); yearDetails.UserId = userId; await _yearService.AddAsync(yearDetails); _yearService.UnitOfWorkSaveChanges(); return(RedirectToAction("Index")); } return(View(yearResource)); }