public ActionResult Edit(NewSDSModelManually model) { if (ModelState.IsValid) { // Status is new by Default model.PubliChem.Status = "New"; model.PubliChem.PDFNAME = string.IsNullOrEmpty(model.SDSPdfFile) ? model.PubliChem.PDFNAME : model.SDSPdfFile.Trim().Replace(' ', '_').ToLower(); var data = publicChemRepository.Update(model.PubliChem); if (data != null) { // Assign SDS to Customer if (model.AssignedCustomers != null) { //1. Reset all SDS's Assigned foreach (var ac in model.AssignedCustomers) { assignedCustomerRepository.DeletePerSDSAssigned(data.Id, ac.UserId, CurrentUser.UserId); } //2. Assign new SDS to Customer var assignedCustomer = model.AssignedCustomers.Where(c => c.Value).ToList(); if (assignedCustomer != null) { foreach (var ac in assignedCustomer) { AssignedCustomer objAC = new AssignedCustomer(); objAC.SDSId = data.Id; objAC.SupplierId = CurrentUser.UserId; objAC.CustomerId = ac.UserId; objAC.Status = SDSStatus.New.ToString(); assignedCustomerRepository.Create(objAC); } } } return RedirectToAction(WebConstants.View_Index); } } else { return GetView(WebConstants.View_CreateManually); } return Json(new JsonViewModel() { IsSuccess = false, Message = "Data is not valid" }, JsonRequestBehavior.AllowGet); }
public ActionResult Edit(Guid Id) { var sds = publicChemRepository.GetById(Id); NewSDSModelManually edit = new NewSDSModelManually(); edit.SDSId = Id; edit.PubliChem = sds; return GetView(WebConstants.View_Edit, edit); }