public ActionResult Create() { var process = ProcessTypeRepository.GetAll(); var products = ProductRepository.GetAll(); var user = UserRepository.GetAll().Where(x => x.RoleId == (int)RoleType.ANALYST || x.RoleId == (int)RoleType.MANAGER); var bind = new ProcessProductViewModel { ProcessTypes = process, Products = products, Users = user, }; return View(bind); }
public async Task<ActionResult> Create(ProcessProductViewModel viewmodel) { if (ModelState.IsValid) { MSTProcessProductDto bu = new MSTProcessProductDto { ProcessTypeId = viewmodel.ProcessId, ProductId = viewmodel.ProductId, InChargePerson = viewmodel.InChargePerson, Description = viewmodel.Description, LastUpdatedBy = CurrentName }; var result = await ProProtRep.AddAsync(bu); if (result == Model.SaveResult.SUCCESS) return RedirectToAction("Index"); } return View(viewmodel); }
public async Task<ActionResult> Edit(int id) { if (id == 0) return new HttpStatusCodeResult(HttpStatusCode.BadRequest); MSTProcessProductDto product = await ProProtRep.SingleAsync(id); if (product == null) return HttpNotFound(); var process = ProcessTypeRepository.GetAll(); var products = ProductRepository.GetAll(); var user = UserRepository.GetAll().Where(x => x.RoleId == (int)RoleType.ANALYST || x.RoleId == (int)RoleType.MANAGER); ProcessProductViewModel bind = new ProcessProductViewModel { ProcessId = product.ProcessTypeId, ProductId = product.ProductId, InChargePerson = product.InChargePerson, Description = product.Description, Users = user, ProcessTypes = process, Products = products, LastUpdatedBy = CurrentName }; return View(bind); }