public string InquiryCreate([Bind(Exclude = "InquiryID")] Inquiry inquiry) { string msg; string guuid = Request.Form["Guuid"]; try { if (ModelState.IsValid) { openMapDB.Inquiry.Add(inquiry); openMapDB.SaveChanges(); // attachments update // Get attachment by guuid IEnumerable<Attachment> attachmentList = openMapDB.Attachment.Where(a => a.Path == guuid).ToList(); foreach (Attachment attachment in attachmentList) { attachment.ParentID = inquiry.InquiryID; attachment.Path = "attachments"; openMapDB.Entry(attachment).State = EntityState.Modified; openMapDB.SaveChanges(); } msg = "Berhasil menambah Inquiry baru with ID ." + inquiry.InquiryID; // INSERT PROGRESS INQUIRY ProgressInquiry progressInquiry = new ProgressInquiry(); progressInquiry.InquiryID = inquiry.InquiryID; progressInquiry.ProgressDate = DateTime.Now; progressInquiry.Description = "Inquiry Created By Marketing"; openMapDB.ProgressInquiry.Add(progressInquiry); openMapDB.SaveChanges(); } else { msg = "Validasi data mengalami kegagalan."; } } catch (Exception e) { msg = "Terjadi kesalahan " + e.Message; } return msg; }
public JsonResult InquiryApprove(int InquiryID,int EmployeeID,string GroupName) { string msg = "Gagal Approve"; // GET INQUIRY try { Inquiry inquiry = openMapDB.Inquiry.Find(InquiryID); if(GroupName == "estimator") { inquiry.Approve2 = EmployeeID; } else if(GroupName == "head_of_marketing") { inquiry.Approve4 = EmployeeID; } else if(GroupName == "marketing_director") { inquiry.Approve3 = EmployeeID; } openMapDB.Entry(inquiry).State = EntityState.Modified; openMapDB.SaveChanges(); // INSERT PROGRESS INQUIRY ProgressInquiry progressInquiry = new ProgressInquiry(); progressInquiry.InquiryID = inquiry.InquiryID; progressInquiry.ProgressDate = DateTime.Now; if(GroupName == "estimator") { progressInquiry.Description = "Approval By Estimator"; } else if(GroupName == "head_of_marketing") { progressInquiry.Description = "Approval By Head Of Marketing Dept."; } else if(GroupName == "marketing_director") { progressInquiry.Description = "Approval By Marketing Director."; } openMapDB.ProgressInquiry.Add(progressInquiry); openMapDB.SaveChanges(); msg = "Berhasil Approve"; } catch(Exception e){ } return Json(new {message=msg}, JsonRequestBehavior.AllowGet); }