public async Task <ActionResult> Create(ExamTypeResource examTypeResource) { if (ModelState.IsValid) { var examType = Mapper.Map <ExamTypeResource, ExamType>(examTypeResource); examType.CreatedDate = DateTime.Now; examType.UpdatedDate = DateTime.Now; var userId = System.Web.HttpContext.Current.User.Identity.GetUserId(); examType.UserId = userId; await _examTypeService.AddAsync(examType); _examTypeService.UnitOfWorkSaveChanges(); return(RedirectToAction("Index")); } return(View(examTypeResource)); }
public async Task <ActionResult> Edit(ExamTypeResource examTypeResource) { if (ModelState.IsValid) { var exstexamType = await _examTypeService.GetByIdAsync(examTypeResource.Id); exstexamType.Name = examTypeResource.Name; exstexamType.UpdatedDate = DateTime.Now; exstexamType.Status = examTypeResource.Status; var userId = System.Web.HttpContext.Current.User.Identity.GetUserId(); exstexamType.UserId = userId; await _examTypeService.UpdateAsync(exstexamType); _examTypeService.UnitOfWorkSaveChanges(); return(RedirectToAction("Index")); } return(View(examTypeResource)); }