public ActionResult Delete(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProductGroupProcessSettings ProductGroupProcessSettings = _ProductGroupProcessSettingsService.Find(id); if (ProductGroupProcessSettings == null) { return(HttpNotFound()); } ReasonViewModel vm = new ReasonViewModel() { id = id, }; return(PartialView("_Reason", vm)); }
public ActionResult Post(ProductGroupProcessSettingsViewModel vm) { ProductGroupProcessSettings pt = AutoMapper.Mapper.Map <ProductGroupProcessSettingsViewModel, ProductGroupProcessSettings>(vm); if (ModelState.IsValid) { ProductGroup ProductGroup = new ProductGroupService(_unitOfWork).Find(vm.ProductGroupId); if (vm.ProductGroupProcessSettingsId <= 0) { pt.CreatedDate = DateTime.Now; pt.ModifiedDate = DateTime.Now; pt.CreatedBy = User.Identity.Name; pt.ModifiedBy = User.Identity.Name; pt.ObjectState = Model.ObjectState.Added; _ProductGroupProcessSettingsService.Create(pt); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); PrepareViewBag(vm); return(View("Create", vm)); } int DocTypeId = new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.Carpet).DocumentTypeId; LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocId = pt.ProductGroupProcessSettingsId, DocTypeId = DocTypeId, ActivityType = (int)ActivityTypeContants.SettingsAdded, })); return(RedirectToAction("Index", "ProductGroupProcessSettings", new { id = ProductGroup.ProductGroupId }).Success("Data saved successfully")); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); ProductGroupProcessSettings temp = _ProductGroupProcessSettingsService.Find(pt.ProductGroupProcessSettingsId); ProductGroupProcessSettings ExRec = Mapper.Map <ProductGroupProcessSettings>(temp); temp.ProcessId = vm.ProcessId; temp.QAGroupId = vm.QAGroupId; temp.ModifiedDate = DateTime.Now; temp.ModifiedBy = User.Identity.Name; temp.ObjectState = Model.ObjectState.Modified; _ProductGroupProcessSettingsService.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); PrepareViewBag(vm); return(View("Create", pt)); } int DocTypeId = new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.Carpet).DocumentTypeId; LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocId = temp.ProductGroupProcessSettingsId, ActivityType = (int)ActivityTypeContants.SettingsModified, DocTypeId = DocTypeId, xEModifications = Modifications, })); return(RedirectToAction("Index", "ProductGroupProcessSettings", new { id = ProductGroup.ProductGroupId }).Success("Data saved successfully")); } } PrepareViewBag(vm); return(View("Create", vm)); }
public void Delete(ProductGroupProcessSettings s) { _unitOfWork.Repository <ProductGroupProcessSettings>().Delete(s); }
public void Update(ProductGroupProcessSettings s) { s.ObjectState = ObjectState.Modified; _unitOfWork.Repository <ProductGroupProcessSettings>().Update(s); }
public ProductGroupProcessSettings Create(ProductGroupProcessSettings s) { s.ObjectState = ObjectState.Added; _unitOfWork.Repository <ProductGroupProcessSettings>().Insert(s); return(s); }