public FeetConversionToCms Create(FeetConversionToCms pt) { pt.ObjectState = ObjectState.Added; _unitOfWork.Repository <FeetConversionToCms>().Insert(pt); return(pt); }
public void Delete(FeetConversionToCms pt) { _unitOfWork.Repository <FeetConversionToCms>().Delete(pt); }
public ActionResult Post(FeetConversionToCms vm) { FeetConversionToCms pt = vm; if (ModelState.IsValid) { if (vm.FeetConversionToCmsId <= 0) { pt.CreatedDate = DateTime.Now; pt.ModifiedDate = DateTime.Now; pt.CreatedBy = User.Identity.Name; pt.ModifiedBy = User.Identity.Name; pt.ObjectState = Model.ObjectState.Added; _FeetConversionToCmsService.Create(pt); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(View("Create", vm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.FeetConversionToCms).DocumentTypeId, DocId = pt.FeetConversionToCmsId, ActivityType = (int)ActivityTypeContants.Added, })); return(RedirectToAction("Create").Success("Data saved successfully")); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); FeetConversionToCms temp = _FeetConversionToCmsService.Find(pt.FeetConversionToCmsId); FeetConversionToCms ExRec = Mapper.Map <FeetConversionToCms>(temp); temp.Feet = pt.Feet; temp.Inch = pt.Inch; temp.Cms = pt.Cms; temp.ModifiedDate = DateTime.Now; temp.ModifiedBy = User.Identity.Name; temp.ObjectState = Model.ObjectState.Modified; _FeetConversionToCmsService.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", pt)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.FeetConversionToCms).DocumentTypeId, DocId = temp.FeetConversionToCmsId, ActivityType = (int)ActivityTypeContants.Modified, xEModifications = Modifications, })); return(RedirectToAction("Index").Success("Data saved successfully")); } } return(View("Create", vm)); }