public ActionResult Create(Route svm) { if (ModelState.IsValid) { if (svm.RouteId == 0) { svm.CreatedDate = DateTime.Now; svm.ModifiedDate = DateTime.Now; svm.CreatedBy = User.Identity.Name; svm.ModifiedBy = User.Identity.Name; _RouteService.Create(svm); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(View("Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.Route).DocumentTypeId, DocId = svm.RouteId, ActivityType = (int)ActivityTypeContants.Added, })); return(RedirectToAction("Edit", new { id = svm.RouteId }).Success("Data saved Successfully")); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); Route temp = _RouteService.Find(svm.RouteId); Route ExRec = Mapper.Map <Route>(temp); temp.RouteName = svm.RouteName; temp.IsActive = svm.IsActive; temp.ModifiedDate = DateTime.Now; temp.ModifiedBy = User.Identity.Name; _RouteService.Update(temp); LogList.Add(new LogTypeViewModel { ExObj = ExRec, Obj = temp, }); XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(View("Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.Route).DocumentTypeId, DocId = temp.RouteId, ActivityType = (int)ActivityTypeContants.Modified, xEModifications = Modifications, })); return(RedirectToAction("Index").Success("Data saved successfully")); } } PrepareViewBag(svm); return(View("Create", svm)); }