// GET: /ProductMaster/Create public ActionResult Create(int id) { ProductDesignPattern vm = new ProductDesignPattern(); vm.IsActive = true; vm.ProductTypeId = id; ViewBag.id = id; ViewBag.Name = new ProductTypeService(_unitOfWork).Find(vm.ProductTypeId).ProductTypeName; return(View("Create", vm)); }
// GET: /ProductMaster/Edit/5 public ActionResult Edit(int id) { ProductDesignPattern pt = _ProductDesignPatternService.GetProductDesignPattern(id); if (pt == null) { return(HttpNotFound()); } ViewBag.id = pt.ProductTypeId; ViewBag.Name = new ProductTypeService(_unitOfWork).Find(pt.ProductTypeId).ProductTypeName; return(View("Create", pt)); }
// GET: /ProductMaster/Delete/5 public ActionResult Delete(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProductDesignPattern ProductDesignPattern = _ProductDesignPatternService.GetProductDesignPattern(id); if (ProductDesignPattern == null) { return(HttpNotFound()); } ReasonViewModel vm = new ReasonViewModel() { id = id, }; return(PartialView("_Reason", vm)); }
public ActionResult Post(ProductDesignPattern vm) { ProductDesignPattern pt = vm; if (ModelState.IsValid) { if (vm.ProductDesignPatternId <= 0) { pt.CreatedDate = DateTime.Now; pt.ModifiedDate = DateTime.Now; pt.CreatedBy = User.Identity.Name; pt.ModifiedBy = User.Identity.Name; pt.ObjectState = Model.ObjectState.Added; _ProductDesignPatternService.Create(pt); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); ViewBag.id = vm.ProductTypeId; ViewBag.Name = new ProductTypeService(_unitOfWork).Find(vm.ProductTypeId).ProductTypeName; return(View("Create", vm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductDesignPattern).DocumentTypeId, DocId = pt.ProductDesignPatternId, ActivityType = (int)ActivityTypeContants.Added, })); return(RedirectToAction("Create", new { id = vm.ProductTypeId }).Success("Data saved successfully")); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); ProductDesignPattern temp = _ProductDesignPatternService.Find(pt.ProductDesignPatternId); ProductDesignPattern ExRec = Mapper.Map <ProductDesignPattern>(temp); temp.ProductDesignPatternName = pt.ProductDesignPatternName; temp.IsActive = pt.IsActive; temp.ModifiedDate = DateTime.Now; temp.ModifiedBy = User.Identity.Name; temp.ObjectState = Model.ObjectState.Modified; _ProductDesignPatternService.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); ViewBag.id = pt.ProductTypeId; ViewBag.Name = new ProductTypeService(_unitOfWork).Find(pt.ProductTypeId).ProductTypeName; return(View("Create", pt)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductDesignPattern).DocumentTypeId, DocId = temp.ProductDesignPatternId, ActivityType = (int)ActivityTypeContants.Modified, xEModifications = Modifications, })); return(RedirectToAction("Index", new { id = vm.ProductTypeId }).Success("Data saved successfully")); } } ViewBag.id = vm.ProductTypeId; ViewBag.Name = new ProductTypeService(_unitOfWork).Find(vm.ProductTypeId).ProductTypeName; return(View("Create", vm)); }
public void Update(ProductDesignPattern pt) { pt.ObjectState = ObjectState.Modified; _unitOfWork.Repository <ProductDesignPattern>().Update(pt); }
public void Delete(ProductDesignPattern pt) { _unitOfWork.Repository <ProductDesignPattern>().Delete(pt); }
public ProductDesignPattern Create(ProductDesignPattern pt) { pt.ObjectState = ObjectState.Added; _unitOfWork.Repository <ProductDesignPattern>().Insert(pt); return(pt); }
public ProductDesignPattern Add(ProductDesignPattern pt) { _unitOfWork.Repository <ProductDesignPattern>().Insert(pt); return(pt); }