public ActionResult Create([Bind(Include = "EmployeeID,Type,Name,NoPEK,Email,PhoneNumber,Status,OrganizationID,PositionID")] Employee employee, IEnumerable <HttpPostedFileBase> files) { if (ModelState.IsValid) { bool nameExist = db.Employees.Any(p => p.Name == employee.Name); if (!nameExist) { string username = User.Identity.Name; db.Employees.Add(employee); db.SaveChanges(); Employee emp = new Employee(); auditTransact.CreateAuditTrail("Create", employee.EmployeeID, "Employee", emp, employee, username); TempData["message"] = "Employee successfully created!"; return(RedirectToAction("Index")); } else { ViewBag.NameExist = "Name already taken"; } } ViewBag.OrganizationID = new SelectList(db.Organizations, "OrganizationID", "Name", employee.OrganizationID); ViewBag.PositionID = new SelectList(db.Positions, "PositionID", "PositionName", employee.PositionID); return(View(employee)); }
public ActionResult EditProfile(int EmployeeID, string FirstName, string LastName, string Email, string UserName) { if (ModelState.IsValid) { var Mywho = Request.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(User.Identity.GetUserId()); var empl = db.Employees.Find(EmployeeID); empl.Name = FirstName + " " + LastName; empl.Email = Email; Mywho.Id = Mywho.Id; Mywho.UserName = UserName; Mywho.FirstName = FirstName; Mywho.LastName = LastName; Mywho.Email = Email; db.Entry(empl).State = EntityState.Modified; Request.GetOwinContext().GetUserManager <ApplicationUserManager>().Update(Mywho); db.SaveChanges(); string userId = User.Identity.GetUserId(); var currentUserLogin = db.UserLoginDetail.Where(p => p.UserID.Equals(userId)); if (currentUserLogin.Count() > 0) { db.UserLoginDetail.Remove(currentUserLogin.FirstOrDefault()); db.SaveChanges(); } AuthenticationManager.SignOut(); return(RedirectToAction("Login", "Account")); } return(View("EditProfile")); }
public ActionResult CreateAuditUniverse(Activity org, [Bind(Include = "ActivityID,ActivityParentID,Name,Description,Tahun,DepartementID,Status,Status_Active")] Activity activity, string submit) { if (ModelState.IsValid) { string username = User.Identity.Name; string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { activity.Status = "Draft"; } else if (submit == "Send Back") { activity.Status = HelperController.GetStatusSendback(db, "Audit Universe", activity.Status); } else if (submit == "Approve") { activity.Status = "Approve"; } else if (submit == "Submit For Review By" + user) { activity.Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { activity.Status = "Pending for Approve by" + user; string baseUrl = Request.Url.GetLeftPart(UriPartial.Authority); List <string> CIAUserIds = Request.GetOwinContext().GetUserManager <ApplicationRoleManager>().Roles.Where(p => p.Name.Equals(user.Trim())).FirstOrDefault().Users.Select(p => p.UserId).ToList(); List <Employee> CIAEmpList = new List <Employee>(); if (CIAUserIds.Count() > 0) { var CIAUsers = Request.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.Where(p => (CIAUserIds.Contains(p.Id))).ToList(); foreach (var CIAUser in CIAUsers) { Employee emp = db.Employees.Where(p => p.Email.Equals(CIAUser.Email)).FirstOrDefault(); string emailContent = "Dear {0}, <BR/><BR/>Audit Universe : {1} need your approval. Please click on this <a href=\"{2}\" title=\"Audit Universe\">link</a> to show the Audit Universe.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = baseUrl + "/AuditUniverses/Details?ActivityID=" + org.ActivityID; emailTransact.SentEmailApproval(emp.Email, emp.Name, org.Name, emailContent, url); } } } db.Activities.Add(activity); db.SaveChanges(); Activity ac = new Activity(); auditTransact.CreateAuditTrail("Create", activity.ActivityID, "AuditUniverse", ac, activity, username); ReviewRelationMaster rrm = new ReviewRelationMaster(); string page = "au"; rrm.Description = page + activity.ActivityID; db.ReviewRelationMasters.Add(rrm); db.SaveChanges(); TempData["message"] = "Audit Universe successfully created!"; return(RedirectToAction("Index")); } return(View(activity)); }
public ActionResult Create([Bind(Include = "ConsultingDraftAgreementID,NoRequest,NoSurat,RequesterID,Date_Start,ActivityStr,Tujuan,RuangLingkup,Peran,Status")] ConsultingDraftAgreement consultingDraftAgreement) { if (ModelState.IsValid) { db.ConsultingDraftAgreements.Add(consultingDraftAgreement); db.SaveChanges(); TempData["message"] = "Draft Agreement successfully created!"; return(RedirectToAction("Index")); } //ViewBag.ActivityID = new SelectList(db.Activities, "ActivityID", "Name", consultingDraftAgreement.ActivityID); return(View(consultingDraftAgreement)); }
public ActionResult Create([Bind(Include = "ConsultingReportingID,ConsultingSuratPerintahID,ActivityID,NoLaporan,Kepada,Dari,Lampiran,Perihal,Hasil")] ConsultingReporting consultingReporting) { if (ModelState.IsValid) { db.ConsultingReportings.Add(consultingReporting); db.SaveChanges(); TempData["message"] = "Consulting Report successfully created!"; return(RedirectToAction("Index")); } ViewBag.ConsultingSuratPerintahID = new SelectList(db.ConsultingLetterOfCommands, "ConsultingSuratPerintahID", "NomorSP", consultingReporting.ConsultingSuratPerintahID); return(View(consultingReporting)); }
public ActionResult CreateOrganizations([Bind(Include = "OrganizationID,OrganizationParentID,Name,Description")] Organization organization, string Command) { if (ModelState.IsValid) { string username = User.Identity.Name; db.Organizations.Add(organization); db.SaveChanges(); Organization org = new Organization(); auditTransact.CreateAuditTrail("Create", organization.OrganizationID, "Organization", org, organization, username); TempData["message"] = "Organization successfully created!"; return(RedirectToAction("Index")); } return(PartialView("CreateOrganization")); }
public ActionResult Create([Bind(Include = "PositionID,PositionName,JobDesc")] Position position) { if (ModelState.IsValid) { string username = User.Identity.Name; db.Positions.Add(position); db.SaveChanges(); Position pos = new Position(); auditTransact.CreateAuditTrail("Create", position.PositionID, "Position", pos, position, username); TempData["message"] = "Position successfully created!"; return(RedirectToAction("Index")); } return(View(position)); }
public void CreateAuditTrail(string Action, int KeyFieldID, string keyValue, Object OldValue, Object NewValue, string username) { CompareLogic compLogic = new CompareLogic(); compLogic.Config.MaxDifferences = 99; ComparisonResult compResult = compLogic.Compare(OldValue, NewValue); List <AuditTrailsTemp.AuditDelta> deltaList = new List <AuditTrailsTemp.AuditDelta>(); foreach (var change in compResult.Differences) { AuditTrailsTemp.AuditDelta delta = new AuditTrailsTemp.AuditDelta(); if (change.PropertyName.Substring(0, 1) == ".") { delta.FieldName = change.PropertyName.Substring(1, change.PropertyName.Length - 1); } delta.ValueBefore = change.Object1Value; delta.ValueAfter = change.Object2Value; deltaList.Add(delta); } AuditTrails audit = new AuditTrails(); audit.AuditAction = Action; audit.DataModel = this.GetType().Name; audit.DateTimeStamp = DateTime.Now; audit.KeyFieldID = KeyFieldID; audit.Desc = keyValue; audit.ValueBefore = JsonConvert.SerializeObject(OldValue); audit.ValueAfter = JsonConvert.SerializeObject(NewValue); audit.Changes = JsonConvert.SerializeObject(deltaList); audit.Username = username; db.AuditTrails.Add(audit); db.SaveChanges(); }
public ActionResult SaveDetailFeedback(int feedbackID, string questions, string pics) { Feedback feedback = db.Feedbacks.Find(feedbackID); foreach (var pic in pics.Split(';')) { Employee emp = db.Employees.Where(p => p.Name.Equals(pic)).FirstOrDefault(); FeedbackQuestionDetail fqd = new FeedbackQuestionDetail(); if (emp != null) { fqd.FeedbackID = feedbackID; fqd.QuestionerID = questions; fqd.PICID = emp.EmployeeID; fqd.LetterofCommandID = feedback.FieldWork.LetterOfCommandID; fqd.Status = "Unsubmitted"; db.FeedbackQuestionDetails.Add(fqd); db.SaveChanges(); FeedbackQuestionDetail feed = db.FeedbackQuestionDetails.Find(fqd.FeedbackQuestionDetailID); feed.FeedbackURL = Request.Url.GetLeftPart(UriPartial.Authority) + "/Feedbacks/FeedBackURL/" + feed.FeedbackQuestionDetailID + "?empId=" + emp.EmployeeID; feed.RandomURL = GetURL(); db.Entry(feed).State = EntityState.Modified; db.SaveChanges(); if (!db.ListFeedbackSended.Any(s => s.FeddbackId == feed.FeedbackQuestionDetailID && s.PicId == feed.PICID)) { string emailContent = "Dear {0}, <BR/><BR/>This is your feedback URL, please click on this <a href=\"{1}\" title=\"your feedback\">link</a> to complete your answers.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.Url.GetLeftPart(UriPartial.Authority) + "/Feedbacks/YourQuestionURL/" + feed.RandomURL; emailTransact.SentEmailFeedback(emp.Email, emp.Name, emailContent, url); db.ListFeedbackSended.Add(new ListFeedbackSended() { FeddbackId = feed.FeedbackQuestionDetailID, PicId = feed.PICID }); db.SaveChanges(); } } } return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "ConsultingFeedbackID,ConsultingSuratPerintahID")] ConsultingFeedback consultingFeedback) { if (ModelState.IsValid) { db.ConsultingFeedbacks.Add(consultingFeedback); db.SaveChanges(); TempData["message"] = "Consulting Feedback successfully created!"; return(RedirectToAction("Index")); } ViewBag.ConsultingSuratPerintahID = new SelectList(db.ConsultingLetterOfCommands, "ConsultingSuratPerintahID", "NomorSP", consultingFeedback.ConsultingSuratPerintahID); return(View(consultingFeedback)); }
// PUT api/ReviewRelationDetail/5 public HttpResponseMessage PutReviewRelationDetail(int id, ReviewRelationDetail reviewrelationdetail) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } if (id != reviewrelationdetail.ReviewRelationDetailID) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } db.Entry(reviewrelationdetail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } return(Request.CreateResponse(HttpStatusCode.OK)); }
// PUT api/Comment/5 public HttpResponseMessage PutPostComment(int id, PostComment postcomment) { if (!ModelState.IsValid) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState)); } if (id != postcomment.PostCommentId) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } db.Entry(postcomment).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } return(Request.CreateResponse(HttpStatusCode.OK)); }
public ActionResult Create([Bind(Include = "PermissionRoleID,PermissionID,IsCreate,IsRead,IsUpdate,IsDelete,IsSubmit1,IsSubmit2,IsApprove,roleID,Desc,Status")] PermissionRoles permRole) { if (ModelState.IsValid) { string username = User.Identity.Name; db.PermissionRoles.Add(permRole); db.SaveChanges(); PermissionRoles pos = new PermissionRoles(); auditTransact.CreateAuditTrail("Create", permRole.permissionID, "Role Permission", pos, permRole, username); TempData["message"] = "Role Permission successfully created!"; return(RedirectToAction("Index")); } return(View(permRole)); }
public async Task <ActionResult> Create(string submit, [Bind(Include = "QuestionerID,Name,Type,Value,Status")] Questioner questioner, string Textarea, string Textbox, string Rating, string from, string to) { if (ModelState.IsValid) { if (questioner.Type == "TextBox") { questioner.Value = Textbox; } else if (questioner.Type == "TextArea") { questioner.Value = Textarea; } else { questioner.Value = from + ";" + to; } string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save" || submit == "Send Back") { questioner.Status = "Draft"; } else if (submit == "Approve") { questioner.Status = "Approve"; } else if (submit == "Submit For Review By" + user) { questioner.Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { questioner.Status = "Pending for Approve by" + user; string baseUrl = Request.Url.GetLeftPart(UriPartial.Authority); List <string> CIAUserIds = Request.GetOwinContext().GetUserManager <ApplicationRoleManager>().Roles.Where(p => p.Name.Equals(user.Trim())).FirstOrDefault().Users.Select(p => p.UserId).ToList(); List <Employee> CIAEmpList = new List <Employee>(); if (CIAUserIds.Count() > 0) { var CIAUsers = Request.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.Where(p => (CIAUserIds.Contains(p.Id))).ToList(); foreach (var CIAUser in CIAUsers) { Employee emp = db.Employees.Where(p => p.Email.Equals(CIAUser.Email)).FirstOrDefault(); string emailContent = "Dear {0}, <BR/><BR/>Questioner : {1} need your approval. Please click on this <a href=\"{2}\" title=\"Questioner\">link</a> to show the Questioner.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = baseUrl + "/Questioners/Details/" + questioner.QuestionerID; //emailTransact.SentEmailApproval(emp.Email, emp.Name, questioner.Name, emailContent, url); } } } db.Questioners.Add(questioner); await db.SaveChangesAsync(); string username = User.Identity.Name; Questioner qus = new Questioner(); auditTransact.CreateAuditTrail("Create", questioner.QuestionerID, "Questioner", qus, questioner, username); ReviewRelationMaster rrm = new ReviewRelationMaster(); string page = "questioner"; rrm.Description = page + questioner.QuestionerID; db.ReviewRelationMasters.Add(rrm); db.SaveChanges(); TempData["message"] = "Questioner successfully created!"; return(RedirectToAction("Index")); } return(View(questioner)); }
public ActionResult Create([Bind(Include = "ExitMeetingID,ActivityID,EngagementID,Date_Start,Date_End,Status,OrganizationID,LetterOfCommandID,Reviewer1,Reviewer2")] ExitMeeting exitMeeting, string activname, string enggname, string submit, string organame, string nomersp, string period1, string period2) { if (ModelState.IsValid) { string username = User.Identity.Name; IQueryable <Activity> act = db.Activities.Where(p => p.Name.Equals(activname)); int actID = 0; if (act.Count() > 0 || act != null) { actID = act.Select(p => p.ActivityID).FirstOrDefault(); } exitMeeting.ActivityID = actID; IQueryable <EngagementActivity> eng = db.EngagementActivities.Where(p => p.Name.Equals(enggname)); int engID = 0; if (eng.Count() > 0 || eng != null) { engID = eng.Select(p => p.EngagementID).FirstOrDefault(); } exitMeeting.EngagementID = engID; exitMeeting.Date_Start = Convert.ToDateTime(period1); exitMeeting.Date_End = Convert.ToDateTime(period2); IQueryable <Organization> org = db.Organizations.Where(p => p.Name.Equals(organame)); int orgID = 0; if (act.Count() > 0 || act != null) { orgID = org.Select(p => p.OrganizationID).FirstOrDefault(); } exitMeeting.OrganizationID = orgID; IQueryable <LetterOfCommand> letter = db.LetterOfCommands.Where(p => p.NomorSP.Equals(nomersp)); int letterID = 0; if (letter.Count() > 0 || letter != null) { letterID = letter.Select(p => p.LetterOfCommandID).FirstOrDefault(); } exitMeeting.LetterOfCommandID = letterID; LetterOfCommand sp = db.LetterOfCommands.Find(exitMeeting.LetterOfCommandID); string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { exitMeeting.Status = "Draft"; } else if (submit == "Send Back") { exitMeeting.Status = HelperController.GetStatusSendback(db, "Exit Meeting", exitMeeting.Status); } else if (submit == "Approve") { exitMeeting.Status = "Approve"; } else if (submit == "Submit For Review By" + user) { exitMeeting.Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { exitMeeting.Status = "Pending for Approve by" + user; string userToSentEmail = String.Empty; if (user.Trim() == "CIA") { userToSentEmail = sp.PICID; if (userToSentEmail != null) { sentSingleEmailEM(userToSentEmail, exitMeeting); } else { sentEmailEM(exitMeeting, user.Trim()); } } else if (user.Trim() == "Pengawas") { userToSentEmail = sp.SupervisorID; if (userToSentEmail != null) { sentSingleEmailEM(userToSentEmail, exitMeeting); } else { sentEmailEM(exitMeeting, user.Trim()); } } else if (user.Trim() == "Ketua Tim") { userToSentEmail = sp.TeamLeaderID; if (userToSentEmail != null) { sentSingleEmailEM(userToSentEmail, exitMeeting); } else { sentEmailEM(exitMeeting, user.Trim()); } } else if (user.Trim() == "Member") { userToSentEmail = sp.MemberID; if (userToSentEmail != null) { sentSingleEmailEM(userToSentEmail, exitMeeting); } else { sentEmailEM(exitMeeting, user.Trim()); } } } exitMeeting.StatusTanggapan = "On Progress"; db.ExitMeetings.Add(exitMeeting); db.SaveChanges(); ExitMeeting exitmeet = new ExitMeeting(); auditTransact.CreateAuditTrail("Create", exitMeeting.ExitMeetingID, "Exit Meeting", exitmeet, exitMeeting, username); ReviewRelationMaster rrm = new ReviewRelationMaster(); string page = "exitmeet"; rrm.Description = page + exitMeeting.ExitMeetingID; db.ReviewRelationMasters.Add(rrm); db.SaveChanges(); TempData["message"] = "Exit Meeting successfully created!"; return(RedirectToAction("Index")); } //LetterOfCommand letter = db.LetterOfCommands.Where(p => p.NomorSP.Equals(nomersp)).FirstOrDefault(); //var activId = letter.ActivityID; //var engId = letter.Preliminary.EngagementID; //var orgId = letter.Activity.DepartementID; //string activnam = db.Activities.Find(activId).Name; //string engname = db.EngagementActivities.Find(engId).Name; //string orgname = db.Organizations.Find(orgId).Name; //var data = activnam + "," + engname + "," + orgname; return(View(exitMeeting)); }
public async Task <ActionResult> EditBusiness(IEnumerable <HttpPostedFileBase> files, [Bind(Include = "BusinessProcesID,WalktroughID,DocumentNo,DocumentName,FolderName,BPMID")] BusinessProces businessProces) { if (ModelState.IsValid) { int i = 0; HttpServerUtilityBase server = Server; List <string> newFilesName = new List <string>(); List <string> paths = new List <string>(); UrlHelper url = Url; List <string> keepImages = new List <string>(); //object imagesTemp = Session["Images"]; var sessionImages = Session["Images"]; if (sessionImages != null) { Array arrKeepImages = (Array)sessionImages; foreach (var arrKeepImage in arrKeepImages) { keepImages.Add(arrKeepImage.ToString()); } bool getFiles = filesTransact.getFiles(businessProces.DocumentNo, out newFilesName, out paths, url, server); List <string> deletedFiles = paths.Except(keepImages).ToList(); bool deleteFiles = filesTransact.deleteFiles(deletedFiles, server); i = filesTransact.getLastNumberOfFiles(businessProces.DocumentNo, server); } foreach (var file in files) { if (file != null) { i = i + 1; bool addFile = filesTransact.addFile(businessProces.DocumentNo, i, file, server); } } Session.Remove("Images"); string username = User.Identity.Name; db.Configuration.ProxyCreationEnabled = false; BusinessProces oldData = db.BusinessProcess.AsNoTracking().Where(p => p.BusinessProcesID.Equals(businessProces.BusinessProcesID)).FirstOrDefault(); auditTransact.CreateAuditTrail("Update", Convert.ToInt32(businessProces.WalktroughID), "BusinessProcessDetail", oldData, businessProces, username); db.Entry(businessProces).State = EntityState.Modified; await db.SaveChangesAsync(); db.SaveChanges(); TempData["message"] = "BPM detail successfully updated!"; return(RedirectToAction("CreateBusiness", new { id = businessProces.BPMID, walkid = businessProces.WalktroughID })); } return(View(businessProces)); }
public ActionResult Create(string submit, [Bind(Include = "AnnualPlanningID,Date_Start,Date_End,Status,Approval_Status,Tahun,ActivityID,PICID,SupervisorID,TeamLeaderID,MemberID")] AnnualPlanning annualPlanning, string[] member, string supervisor, string pic, string leader, EngagementActivity engagementActivity) { if (ModelState.IsValid) { HttpServerUtilityBase server = Server; string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { annualPlanning.Approval_Status = "Draft"; } else if (submit == "Approve") { annualPlanning.Approval_Status = "Approve"; } else if (submit == "Send Back") { annualPlanning.Approval_Status = HelperController.GetStatusSendback(db, "Annual Planning", annualPlanning.Approval_Status); } else if (submit == "Submit For Review By" + user) { annualPlanning.Approval_Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { annualPlanning.Approval_Status = "Pending for Approve by" + user; string activname = db.Activities.Where(p => p.ActivityID.Equals(annualPlanning.ActivityID)).Select(p => p.Name).FirstOrDefault(); string baseUrl = Request.Url.GetLeftPart(UriPartial.Authority); List <string> UserIds = Request.GetOwinContext().GetUserManager <ApplicationRoleManager>().Roles.Where(p => p.Name.Equals(user.Trim())).FirstOrDefault().Users.Select(p => p.UserId).ToList(); List <Employee> EmpList = new List <Employee>(); if (UserIds.Count() > 0) { var users = Request.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.Where(p => (UserIds.Contains(p.Id))).ToList(); foreach (var userr in users) { Employee emp = db.Employees.Where(p => p.Email.Equals(userr.Email)).FirstOrDefault(); if (emp != null) { string emailContent = "Dear {0}, <BR/><BR/>There is a Annual Planning that need your approval. Please click on this <a href=\"{2}\" title=\"Annual Planning\">link</a> to show the Annual Planning.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = baseUrl + "/AnnualPlannings/Details/" + annualPlanning.AnnualPlanningID; emailTransact.SentEmailApproval(emp.Email, emp.Name, activname, emailContent, url); } } } } db.AnnualPlannings.Add(annualPlanning); db.SaveChanges(); string username = User.Identity.Name; AnnualPlanning an = new AnnualPlanning(); auditTransact.CreateAuditTrail("Create", annualPlanning.AnnualPlanningID, "AnnualPlanning", an, annualPlanning, username); ReviewRelationMaster rrm = new ReviewRelationMaster(); string page = "apl"; rrm.Description = page + annualPlanning.AnnualPlanningID; db.ReviewRelationMasters.Add(rrm); db.SaveChanges(); TempData["message"] = "Annual Planning successfully created!"; return(RedirectToAction("Index")); } ActivityServices activity = new ActivityServices(); var activities = activity.GetActivity().Where(p => p.Status == "Approve"); IEnumerable <SelectListItem> activityid = activities .Select(d => new SelectListItem { Value = d.ActivityID.ToString(), Text = d.Name }); ViewBag.ActivityID = activityid; ViewBag.membereng = new MultiSelectList(db.Employees, "EmployeeID", "Name"); ViewBag.membereng1 = new MultiSelectList(db.Employees, "EmployeeID", "Name"); return(View(annualPlanning)); }
public ActionResult Create(string nomerapm, string membernull, string enggname, EngagementActivity engga, AuditPlanningMemorandum audit, [Bind(Include = "AuditPlanningMemorandumID,NomerAPM,PreliminaryID,Date_Start,Date_End,Status,ActivityID,TujuanAudit,RuangLingkupAudit,MetodologiAudit,DataDanDokumen,AttachmentMasterID,EntryMeetingDateStart,EntryMeetingDateEnd,WalktroughDateStart,WalktroughDateEnd,FieldWorkDateStart,FieldWorkDateEnd,ExitMeetingDateStart,ExitMeetingDateEnd,LHADateStart,LHADateEnd,PICID,SupervisorID,TeamLeaderID,MemberID,ReviewMasterID,Kesimpulan,ActualEngagement")] AuditPlanningMemorandum auditPlanningMemorandum, IEnumerable <HttpPostedFileBase> files, string submit, string[] members, string supervisor, string pic, string leader, string nomer, string activid) { if (ModelState.IsValid) { HttpServerUtilityBase server = Server; string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { auditPlanningMemorandum.Status = "Draft"; } else if (submit == "Send Back") { HelperController.GetStatusSendback(db, "Audit Planning Memorandum", auditPlanningMemorandum.Status); } else if (submit == "Approve") { auditPlanningMemorandum.Status = "Approve"; } else if (submit == "Submit For Review By" + user) { auditPlanningMemorandum.Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { auditPlanningMemorandum.Status = "Pending for Approve by" + user; string userToSentEmail = String.Empty; if (user.Trim() == "CIA") { userToSentEmail = auditPlanningMemorandum.PICID; if (userToSentEmail != null) { sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum); } else { sentEmailAPM(auditPlanningMemorandum, user.Trim()); } } else if (user.Trim() == "Pengawas") { userToSentEmail = auditPlanningMemorandum.SupervisorID; if (userToSentEmail != null) { sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum); } else { sentEmailAPM(auditPlanningMemorandum, user.Trim()); } } else if (user.Trim() == "Ketua Tim") { userToSentEmail = auditPlanningMemorandum.TeamLeaderID; if (userToSentEmail != null) { sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum); } else { sentEmailAPM(auditPlanningMemorandum, user.Trim()); } } else if (user.Trim() == "Member") { userToSentEmail = auditPlanningMemorandum.MemberID; if (userToSentEmail != null) { sentSingleEmailAPM(userToSentEmail, auditPlanningMemorandum); } else { sentEmailAPM(auditPlanningMemorandum, user.Trim()); } } } foreach (var mem in members) { auditPlanningMemorandum.MemberID += mem + ";"; } IQueryable <Preliminary> prel = db.Preliminaries.Where(p => p.NomorPreliminarySurvey.Equals(nomer)); int preID = 0; if (prel.Count() > 0 || prel != null) { preID = prel.Select(p => p.PreliminaryID).FirstOrDefault(); } auditPlanningMemorandum.PreliminaryID = preID; auditPlanningMemorandum.SupervisorID = supervisor; auditPlanningMemorandum.TeamLeaderID = leader; auditPlanningMemorandum.PICID = pic; IQueryable <Activity> act = db.Activities.Where(p => p.Name.Equals(activid)); int actid = 0; if (act.Count() > 0 || act != null) { actid = act.Select(p => p.ActivityID).FirstOrDefault(); } auditPlanningMemorandum.ActivityID = actid; auditPlanningMemorandum.NomerAPM = nomerapm; db.AuditPlanningMemorandums.Add(auditPlanningMemorandum); db.SaveChanges(); int i = 0; foreach (var file in files) { if (file != null) { i = i + 1; bool addFile = filesTransact.addFile(auditPlanningMemorandum.NomerAPM.Replace("/", ""), i, file, server); } } ReviewRelationMaster rrm = new ReviewRelationMaster(); string page = "apm"; rrm.Description = page + auditPlanningMemorandum.AuditPlanningMemorandumID; db.ReviewRelationMasters.Add(rrm); db.SaveChanges(); string username = User.Identity.Name; AuditPlanningMemorandum au = new AuditPlanningMemorandum(); auditTransact.CreateAuditTrail("Create", auditPlanningMemorandum.AuditPlanningMemorandumID, "AuditPlanningMemorandum", au, auditPlanningMemorandum, username); TempData["message"] = "Audit Planning Memorandum successfully created!"; return(RedirectToAction("Index")); } return(View(auditPlanningMemorandum)); }
public ActionResult Create(string noprelim, int?ActivityID, string EngagementNameNull, string EngagementName, int?UnActivityID, int?engid, [Bind(Include = "PreliminaryID,Type,Status,NomorPreliminarySurvey,Date_Start,Date_End,EmployeeID,EngagementID,PICID,SupervisorID,TeamLeaderID,MemberID")] Preliminary preliminary, IEnumerable <HttpPostedFileBase> files, string submit, string[] member, string pic, string supervisor, string leader, string[] members) { if (ModelState.IsValid) { if (member != null) { foreach (var mem in member) { preliminary.EmployeeID += mem + ";"; } } preliminary.PICID = pic; preliminary.SupervisorID = supervisor; preliminary.TeamLeaderID = leader; if (members != null) { foreach (var mem in members) { preliminary.MemberID += mem + ";"; } } HttpServerUtilityBase server = Server; int a = 0; if (engid == 0 && a < ActivityID) { EngagementActivity engagement = new EngagementActivity(); engagement.ActivityID = ActivityID.Value; engagement.Name = EngagementNameNull; engagement.Date_Start = null; engagement.Date_End = null; db.EngagementActivities.Add(engagement); db.SaveChanges(); preliminary.ActivityID = ActivityID.Value; preliminary.EngagementID = engagement.EngagementID; preliminary.NomorPreliminarySurvey = noprelim; int i = 0; foreach (var file in files) { if (file != null) { i = i + 1; var pre = preliminary.NomorPreliminarySurvey.Split('/')[0]; var no = preliminary.NomorPreliminarySurvey.Split('/')[1]; bool addFile = filesTransact.addFile(pre + no, i, file, server); } } string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { preliminary.Status = "Draft"; } else if (submit == "Send Back") { preliminary.Status = HelperController.GetStatusSendback(db, "Preliminary Survey", preliminary.Status); } else if (submit == "Approve") { preliminary.Status = "Approve"; } else if (submit == "Submit For Review By" + user) { preliminary.Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { preliminary.Status = "Pending for Approve by" + user; string userToSentEmail = String.Empty; if (user.Trim() == "CIA") { userToSentEmail = preliminary.PICID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Pengawas") { userToSentEmail = preliminary.SupervisorID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Ketua Tim") { userToSentEmail = preliminary.TeamLeaderID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Member") { userToSentEmail = preliminary.MemberID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } } db.Preliminaries.Add(preliminary); db.SaveChanges(); string username = User.Identity.Name; Preliminary pr = new Preliminary(); auditTransact.CreateAuditTrail("Create", preliminary.PreliminaryID, "Preliminary", pr, preliminary, username); ReviewRelationMaster rrm = new ReviewRelationMaster(); string page = "prelim"; rrm.Description = page + preliminary.PreliminaryID; db.ReviewRelationMasters.Add(rrm); db.SaveChanges(); } else if (preliminary.Type == "UnPlanned") { EngagementActivity engagement = new EngagementActivity(); engagement.ActivityID = UnActivityID.Value; engagement.Name = EngagementName; engagement.Date_Start = null; engagement.Date_End = null; db.EngagementActivities.Add(engagement); db.SaveChanges(); preliminary.ActivityID = UnActivityID.Value; preliminary.EngagementID = engagement.EngagementID; preliminary.NomorPreliminarySurvey = noprelim; int i = 0; foreach (var file in files) { if (file != null) { i = i + 1; var pre = preliminary.NomorPreliminarySurvey.Split('/')[0]; var no = preliminary.NomorPreliminarySurvey.Split('/')[1]; bool addFile = filesTransact.addFile(pre + no, i, file, server); } } string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { preliminary.Status = "Draft"; } else if (submit == "Send Back") { preliminary.Status = HelperController.GetStatusSendback(db, "Preliminary Survey", preliminary.Status); } else if (submit == "Approve") { preliminary.Status = "Approve"; } else if (submit == "Submit For Review By" + user) { preliminary.Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { preliminary.Status = "Pending for Approve by" + user; string userToSentEmail = String.Empty; if (user.Trim() == "CIA") { userToSentEmail = preliminary.PICID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Pengawas") { userToSentEmail = preliminary.SupervisorID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Ketua Tim") { userToSentEmail = preliminary.TeamLeaderID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Member") { userToSentEmail = preliminary.MemberID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } } db.Preliminaries.Add(preliminary); db.SaveChanges(); string username = User.Identity.Name; Preliminary pr = new Preliminary(); auditTransact.CreateAuditTrail("Create", preliminary.PreliminaryID, "Preliminary", pr, preliminary, username); ReviewRelationMaster rrm = new ReviewRelationMaster(); string page = "prelim"; rrm.Description = page + preliminary.PreliminaryID; db.ReviewRelationMasters.Add(rrm); db.SaveChanges(); } else //Type == "Planned" { EngagementActivity engagement = new EngagementActivity(); preliminary.ActivityID = ActivityID.Value; preliminary.EngagementID = engid; preliminary.NomorPreliminarySurvey = noprelim; int i = 0; foreach (var file in files) { if (file != null) { i = i + 1; var pre = preliminary.NomorPreliminarySurvey.Split('/')[0]; var no = preliminary.NomorPreliminarySurvey.Split('/')[1]; bool addFile = filesTransact.addFile(pre + no, i, file, server); } } string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { preliminary.Status = "Draft"; } else if (submit == "Send Back") { preliminary.Status = HelperController.GetStatusSendback(db, "Preliminary Survey", preliminary.Status); } else if (submit == "Approve") { preliminary.Status = "Approve"; } else if (submit == "Submit For Review By" + user) { preliminary.Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { preliminary.Status = "Pending for Approve by" + user; string userToSentEmail = String.Empty; if (user.Trim() == "CIA") { userToSentEmail = preliminary.PICID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Pengawas") { userToSentEmail = preliminary.SupervisorID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Ketua Tim") { userToSentEmail = preliminary.TeamLeaderID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } else if (user.Trim() == "Member") { userToSentEmail = preliminary.MemberID; if (userToSentEmail != null) { sentSingleEmailPrelim(userToSentEmail, preliminary); } else { sentEmailPrelim(preliminary, user.Trim()); } } } db.Preliminaries.Add(preliminary); db.SaveChanges(); string username = User.Identity.Name; Preliminary pr = new Preliminary(); auditTransact.CreateAuditTrail("Create", preliminary.PreliminaryID, "Preliminary", pr, preliminary, username); ReviewRelationMaster rrm = new ReviewRelationMaster(); string page = "prelim"; rrm.Description = page + preliminary.PreliminaryID; db.ReviewRelationMasters.Add(rrm); db.SaveChanges(); } TempData["message"] = "Preliminary successfully created!"; return(RedirectToAction("Index")); } return(View(preliminary)); }
public ActionResult Create([Bind(Include = "LetterOfCommandID,NomorSP,Status,Remarks,AssuranceType,Date_Start,Date_End,Menimbang,Penutup,AuditPlanningMemorandumID,ActivityID,PICID,SupervisorID,TeamLeaderID,MemberID")] LetterOfCommand letterOfCommand, LetterOfCommandDetailDasar letterOfCommandDetailDasar, LetterOfCommandDetailUntuk letterOfCommandDetailUntuk, LetterOfCommandDetailTembusan letterOfCommandDetailTembusan, string letterno, string membernull, string activid, string[] members, string pic, string supervisor, string leader, string nomer, string submit, string[] dasar, string[] untuk, string[] tembusan) { if (ModelState.IsValid) { string username = User.Identity.Name; HttpServerUtilityBase server = Server; string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { letterOfCommand.Status = "Draft"; } else if (submit == "Send Back") { letterOfCommand.Status = HelperController.GetStatusSendback(db, "Surat Perintah", letterOfCommand.Status); } else if (submit == "Approve") { letterOfCommand.Status = "Approve"; } else if (submit == "Submit For Review By" + user) { letterOfCommand.Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { letterOfCommand.Status = "Pending for Approve by" + user; string userToSentEmail = String.Empty; if (user.Trim() == "CIA") { userToSentEmail = letterOfCommand.PICID; if (userToSentEmail != null) { sentSingleEmailSP(userToSentEmail, letterOfCommand); } else { sentEmailSP(letterOfCommand, user.Trim()); } } else if (user.Trim() == "Pengawas") { userToSentEmail = letterOfCommand.SupervisorID; if (userToSentEmail != null) { sentSingleEmailSP(userToSentEmail, letterOfCommand); } else { sentEmailSP(letterOfCommand, user.Trim()); } } else if (user.Trim() == "Ketua Tim") { userToSentEmail = letterOfCommand.TeamLeaderID; if (userToSentEmail != null) { sentSingleEmailSP(userToSentEmail, letterOfCommand); } else { sentEmailSP(letterOfCommand, user.Trim()); } } else if (user.Trim() == "Member") { userToSentEmail = letterOfCommand.MemberID; if (userToSentEmail != null) { sentSingleEmailSP(userToSentEmail, letterOfCommand); } else { sentEmailSP(letterOfCommand, user.Trim()); } } } IQueryable <AuditPlanningMemorandum> apm = db.AuditPlanningMemorandums.Where(p => p.NomerAPM.Equals(nomer)); int apmId = 0; if (apm.Count() > 0 || apm != null) { apmId = apm.Select(p => p.AuditPlanningMemorandumID).FirstOrDefault(); letterOfCommand.AuditPlanningMemorandumID = apmId; } letterOfCommand.SupervisorID = supervisor; letterOfCommand.TeamLeaderID = leader; letterOfCommand.PICID = pic; IQueryable <Activity> act = db.Activities.Where(p => p.Name.Equals(activid)); int activ = 0; if (act.Count() > 0 || act != null) { activ = act.Select(p => p.ActivityID).FirstOrDefault(); } letterOfCommand.ActivityID = activ; string tahun1 = letterOfCommand.Date_Start.ToShortDateString().Split('/')[2] + ";"; string tahun2 = letterOfCommand.Date_End.ToShortDateString().Split('/')[2] + ";"; Activity actLetter = db.Activities.Find(activ); if (actLetter.Tahun != null) { if (tahun1 != tahun2) { if (!actLetter.Tahun.Contains(tahun1)) { actLetter.Tahun += tahun1; } if (!actLetter.Tahun.Contains(tahun2)) { actLetter.Tahun += tahun2; } } else { if (!actLetter.Tahun.Contains(tahun1)) { actLetter.Tahun += tahun1; } } } else { if (tahun1 != tahun2) { actLetter.Tahun = tahun1 + tahun2; } else { actLetter.Tahun = tahun1; } } db.Entry(actLetter).State = EntityState.Modified; letterOfCommand.NomorSP = letterno; foreach (var mb in members) { letterOfCommand.MemberID += mb + ";"; } letterOfCommandDetailDasar.LetterOfCommandID = letterOfCommand.LetterOfCommandID; letterOfCommandDetailDasar.Dasar = null; foreach (var ds in dasar) { letterOfCommandDetailDasar.Dasar += ds + ";"; } letterOfCommandDetailUntuk.LetterOfCommandID = letterOfCommand.LetterOfCommandID; letterOfCommandDetailUntuk.Untuk = null; foreach (var utk in untuk) { letterOfCommandDetailUntuk.Untuk += utk + ";"; } letterOfCommandDetailTembusan.LetterOfCommandID = letterOfCommand.LetterOfCommandID; letterOfCommandDetailTembusan.Tembusan = null; foreach (var tmb in tembusan) { letterOfCommandDetailTembusan.Tembusan += tmb + ";"; } db.LetterOfCommandDetailDasars.Add(letterOfCommandDetailDasar); db.LetterOfCommandDetailTembusans.Add(letterOfCommandDetailTembusan); db.LetterOfCommandDetailUntuks.Add(letterOfCommandDetailUntuk); db.LetterOfCommands.Add(letterOfCommand); db.SaveChanges(); LetterOfCommand let = new LetterOfCommand(); LetterOfCommandDetailDasar letDasar = new LetterOfCommandDetailDasar(); LetterOfCommandDetailUntuk letUntuk = new LetterOfCommandDetailUntuk(); LetterOfCommandDetailTembusan letTembusan = new LetterOfCommandDetailTembusan(); auditTransact.CreateAuditTrail("Create", letterOfCommand.LetterOfCommandID, "LetterOfCommand", let, letterOfCommand, username); auditTransact.CreateAuditTrail("Create", letterOfCommandDetailDasar.ID, "LetterOfCommandDetailDasar", letDasar, letterOfCommandDetailDasar, username); auditTransact.CreateAuditTrail("Create", letterOfCommandDetailUntuk.ID, "LetterOfCommandDetailUntuk", letUntuk, letterOfCommandDetailUntuk, username); auditTransact.CreateAuditTrail("Create", letterOfCommandDetailTembusan.ID, "LetterOfCommandDetailTembusan", letTembusan, letterOfCommandDetailTembusan, username); ReviewRelationMaster rrm = new ReviewRelationMaster(); string page = "letter"; rrm.Description = page + letterOfCommand.LetterOfCommandID; db.ReviewRelationMasters.Add(rrm); db.SaveChanges(); TempData["message"] = "Letter Of Command successfully created!"; return(RedirectToAction("Index")); } ViewBag.PreliminaryID = new SelectList(db.Preliminaries, "PreliminaryID", "NomorPreliminarySurvey", letterOfCommand.PreliminaryID); return(View(letterOfCommand)); }
public ActionResult Create(string submit, string requester, [Bind(Include = "ConsultingRequestID,NoRequest,NoSurat,RequesterID,Date_Start,EvaluationResult,Status,ActivityStr")] ConsultingRequest consultingRequest, IEnumerable <HttpPostedFileBase> files) { if (ModelState.IsValid) { string username = User.Identity.Name; IQueryable <Employee> emp = db.Employees.Where(p => p.Name.Equals(requester)); int empId = 0; if (emp.Count() > 0 || emp != null) { empId = emp.Select(p => p.EmployeeID).FirstOrDefault(); } consultingRequest.RequesterID = empId; string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { consultingRequest.Status = "Draft"; } else if (submit == "Send Back") { consultingRequest.Status = HelperController.GetStatusSendback(db, "Consulting Request", consultingRequest.Status); } else if (submit == "Submit For Review By" + user) { consultingRequest.Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { consultingRequest.Status = "Pending for Approve by" + user; string baseUrl = Request.Url.GetLeftPart(UriPartial.Authority); List <string> CIAUserIds = Request.GetOwinContext().GetUserManager <ApplicationRoleManager>().Roles.Where(p => p.Name.Equals(user.Trim())).FirstOrDefault().Users.Select(p => p.UserId).ToList(); List <Employee> CIAEmpList = new List <Employee>(); if (CIAUserIds.Count() > 0) { var CIAUsers = Request.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.Where(p => (CIAUserIds.Contains(p.Id))).ToList(); foreach (var CIAUser in CIAUsers) { Employee empl = db.Employees.Where(p => p.Email.Equals(CIAUser.Email)).FirstOrDefault(); string emailContent = "Dear {0}, <BR/><BR/>Consulting Request : {1} need your approval. Please click on this <a href=\"{2}\" title=\"Consulting Request\">link</a> to show the Consulting Request.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string urlRequest = baseUrl + "/ConsultingRequests/Details/" + consultingRequest.ConsultingRequestID; emailTransact.SentEmailApproval(empl.Email, empl.Name, consultingRequest.NoRequest, emailContent, urlRequest); } } } HttpServerUtilityBase server = Server; //var createFile = UploadFile(1234); int i = 0; foreach (var file in files) { if (file != null) { i = i + 1; bool addFile = filesTransact.addFile(consultingRequest.NoRequest.Replace("/", ""), i, file, server); } } db.ConsultingRequests.Add(consultingRequest); db.SaveChanges(); ConsultingRequest conreq = new ConsultingRequest(); auditTransact.CreateAuditTrail("Create", consultingRequest.ConsultingRequestID, "Consulting Request", conreq, consultingRequest, username); ReviewRelationMaster rrm = new ReviewRelationMaster(); string page = "draft"; rrm.Description = page + consultingRequest.ConsultingRequestID; db.ReviewRelationMasters.Add(rrm); db.SaveChanges(); TempData["message"] = "Request successfully created!"; return(RedirectToAction("Index")); } //ViewBag.ActivityID = new SelectList(db.Activities, "ActivityID", "Name", consultingRequest.ActivityID); return(View(consultingRequest)); }
public ActionResult Create([Bind(Include = "ConsultingSuratPerintahID,NomorSP,ConsultingRequestID,EngagementName,EngagementID,StartDate,EndDate,PicID,SupervisorID,TeamLeaderID,Menimbang,Penutup,MemberID,Remarks")] ConsultingLetterOfCommand consultingletterofcommand, EngagementActivity engagementActivity, string ActivityName, string submit, string[] member, string ConsultingRequest, ConsultingLetterOfCommandDetailDasar Ldasar, ConsultingLetterOfCommandDetailTembusan Ltembusan, ConsultingLetterOfCommandDetailUntuk Luntuk, string[] dasar, string[] tembusan, string[] untuk) { if (ModelState.IsValid) { string username = User.Identity.Name; IQueryable <ConsultingRequest> cr = context.ConsultingRequests.Where(p => p.NoRequest.Equals(ConsultingRequest)); int ConsulId = 0; if (cr.Count() > 0 || cr != null) { ConsulId = cr.Select(p => p.ConsultingRequestID).FirstOrDefault(); } consultingletterofcommand.ConsultingRequestID = ConsulId; foreach (var mb in member) { consultingletterofcommand.MemberID += mb + ";"; } string user = submit.Contains("By") ? submit.Split('y')[1] : String.Empty; if (submit == "Save") { consultingletterofcommand.Status = "Draft"; } else if (submit == "Send Back") { consultingletterofcommand.Status = HelperController.GetStatusSendback(context, "Consulting Surat Perintah", consultingletterofcommand.Status); } else if (submit == "Approve") { consultingletterofcommand.Status = "Approve"; } else if (submit == "Submit For Review By" + user) { consultingletterofcommand.Status = "Pending for Review by" + user; } else if (submit == "Submit For Approve By" + user) { consultingletterofcommand.Status = "Pending for Approve by" + user; } context.ConsultingLetterOfCommands.Add(consultingletterofcommand); //Engagement Activity //IQueryable<Activity> act = context.Activities.Where(p => p.Name.Equals(ActivityName)); //int ActivityID = 0; //if (act.Count() > 0 || act != null) // ActivityID = act.Select(p => p.ActivityID).FirstOrDefault(); engagementActivity.ActivityStr = ActivityName; engagementActivity.Name = consultingletterofcommand.EngagementName; engagementActivity.PICID = consultingletterofcommand.PicID; engagementActivity.TeamLeaderID = consultingletterofcommand.TeamLeaderID; engagementActivity.SupervisorID = consultingletterofcommand.SupervisorID; engagementActivity.MemberID = consultingletterofcommand.MemberID; context.EngagementActivities.Add(engagementActivity); //Letter of Command Dasar Ldasar.ConsultingSuratPerintahID = consultingletterofcommand.ConsultingSuratPerintahID; Ldasar.Dasar = null; foreach (var ds in dasar) { Ldasar.Dasar += ds + ";"; } context.ConsultingLetterOfCommandDetailDasars.Add(Ldasar); //Letter of Command Untuk Luntuk.ConsultingSuratPerintahID = consultingletterofcommand.ConsultingSuratPerintahID; Luntuk.Untuk = null; foreach (var utk in untuk) { Luntuk.Untuk += utk + ";"; } context.ConsultingLetterOfCommandDetailUntuks.Add(Luntuk); //Letter of Command Tembusan Ltembusan.ConsultingSuratPerintahID = consultingletterofcommand.ConsultingSuratPerintahID; Ltembusan.Tembusan = null; foreach (var tmb in tembusan) { Ltembusan.Tembusan += tmb + ";"; } context.ConsultingLetterOfCommandDetailTembusans.Add(Ltembusan); context.SaveChanges(); //assign engagementID in consulting SP consultingletterofcommand.EngagementID = engagementActivity.EngagementID; context.Entry(consultingletterofcommand).State = EntityState.Modified; //Review Relation Master ReviewRelationMaster rrm = new ReviewRelationMaster(); string page = "conleterdetail"; rrm.Description = page + consultingletterofcommand.ConsultingSuratPerintahID; context.ReviewRelationMasters.Add(rrm); context.SaveChanges(); ConsultingLetterOfCommand conletcom = new ConsultingLetterOfCommand(); ConsultingLetterOfCommandDetailDasar conletdasar = new ConsultingLetterOfCommandDetailDasar(); ConsultingLetterOfCommandDetailUntuk conletuntuk = new ConsultingLetterOfCommandDetailUntuk(); ConsultingLetterOfCommandDetailTembusan conlettembusan = new ConsultingLetterOfCommandDetailTembusan(); ConsultingLetterOfCommand conletnew = context.ConsultingLetterOfCommands.Find(consultingletterofcommand.ConsultingSuratPerintahID); auditTransact.CreateAuditTrail("Create", consultingletterofcommand.ConsultingSuratPerintahID, "Consulting Letter Of Command", conletcom, conletnew, username); auditTransact.CreateAuditTrail("Create", Ldasar.ConsultingLetterOfCommandDetailDasarID, "Consulting Letter Of Command Dasar", conletdasar, Ldasar, username); auditTransact.CreateAuditTrail("Create", Luntuk.ConsultingLetterOfCommandDetailUntukID, "Consulting Letter Of Command Untuk", conletuntuk, Luntuk, username); auditTransact.CreateAuditTrail("Create", Ltembusan.ConsultingLetterOfCommandDetailTembusanID, "Consulting Letter Of Command Tembusan", conlettembusan, Ltembusan, username); TempData["message"] = "Consulting Letter Of Command successfully created!"; return(RedirectToAction("Index")); } return(View(consultingletterofcommand)); }
public ActionResult Edit([Bind(Include = "RCMDetailRiskControlIssueID,RCMDetailRiskControlID,NoRef,Title,Fact,Criteria,Impact,ImpactValue,Cause,Recommendation,ManagementResponse,FindingType,Status,Status_Approval,Status_App,Signification,Due_Date,Close_Date,CaseClose")] RCMDetailRiskControlIssue issue, IEnumerable <HttpPostedFileBase> files, string PICID) { if (ModelState.IsValid) { MonitoringTindakLanjut dbitem = db.MonitoringTindakLanjut.Where(d => d.RCMDetailRiskControlIssueID == issue.RCMDetailRiskControlIssueID).FirstOrDefault(); if (dbitem != null) { if (issue.CaseClose == "true") { dbitem.Status = "Close"; } else { dbitem.Status = "Open"; } db.Configuration.ProxyCreationEnabled = false; db.Entry(dbitem).State = EntityState.Modified; db.SaveChanges(); } string username = User.Identity.Name; db.Configuration.ProxyCreationEnabled = false; RCMDetailRiskControlIssue oldData = db.RCMDetailRiskControlIssue.AsNoTracking().Where(p => p.RCMDetailRiskControlIssueID.Equals(issue.RCMDetailRiskControlIssueID)).FirstOrDefault(); //auditTransact.CreateAuditTrail("Update", issue.RCMDetailRiskControlIssueID, "RCM Control Issue", oldData, issue, username); issue.PICID = PICID; db.Entry(issue).State = EntityState.Modified; db.SaveChanges(); int i = 0; HttpServerUtilityBase server = Server; List <string> newFilesName = new List <string>(); List <string> paths = new List <string>(); UrlHelper url = Url; List <string> keepImages = new List <string>(); //object imagesTemp = Session["Images"]; var sessionImages = Session["Images"]; if (sessionImages != null) { Array arrKeepImages = (Array)sessionImages; foreach (var arrKeepImage in arrKeepImages) { keepImages.Add(arrKeepImage.ToString()); } var iss = issue.NoRef.Split('/')[0] + issue.NoRef.Split('/')[1]; var no = issue.NoRef.Split('/')[2]; bool getFiles = filesTransact.getFiles(iss + no, out newFilesName, out paths, url, server); List <string> deletedFiles = paths.Except(keepImages).ToList(); bool deleteFiles = filesTransact.deleteFiles(deletedFiles, server); i = filesTransact.getLastNumberOfFiles(iss + no, server); } foreach (var file in files) { if (file != null) { i = i + 1; var iss = issue.NoRef.Split('/')[0] + issue.NoRef.Split('/')[1]; var no = issue.NoRef.Split('/')[2]; bool addFile = filesTransact.addFile(iss + no, i, file, server); } } Session.Remove("Images"); return(RedirectToAction("Index")); } return(View(issue)); }
public HttpResponseMessage PostPost(Post post) { //reviewrel.ReviewRelationMasterID = ReviewRelationMasterID; post.PostedBy = User.Identity.GetUserName(); // GetUserId(); post.PostedDate = DateTime.Now; ModelState.Remove("post.PostedBy"); ModelState.Remove("post.PostedDate"); string message = post.Message.Split(';')[0]; string Id = post.Message.Split(';')[1]; if (ModelState.IsValid) { db.Posts.Add(post); db.SaveChanges(); int lastId = db.Posts.OrderByDescending(p => p.PostId).Select(p => p.PostId).FirstOrDefault(); ReviewRelationDetail rrd = new ReviewRelationDetail(); rrd.PostId = lastId; int rrmId = db.ReviewRelationMasters.Where(p => p.Description.Equals(Id)).Select(p => p.ReviewRelationMasterID).FirstOrDefault(); rrd.ReviewRelationMasterID = rrmId; db.ReviewRelationDetails.Add(rrd); db.SaveChanges(); //var usr = db.UserProfiles.FirstOrDefault(x => x.UserProfileId == post.PostedBy); var ret = new { Message = message, PostedBy = post.PostedBy, PostedByName = User.Identity.GetUserName(), PostedByAvatar = imgFolder, //+ (String.IsNullOrEmpty(usr.AvatarExt) ? defaultAvatar : post.PostedBy + "." + post.UserProfile.AvatarExt), PostedDate = post.PostedDate, PostId = post.PostId }; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, ret); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = post.PostId })); var postBy = HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>().FindById(User.Identity.GetUserId()); string getInteger = new string(Id.Where(x => char.IsDigit(x)).ToArray()); int id = Convert.ToInt32(getInteger); var postById = db.Employees.Where(p => p.Email.Equals(postBy.Email)).Select(p => p.EmployeeID).FirstOrDefault(); Employee empl = db.Employees.Find(Convert.ToInt32(postById)); /*if (Id.Contains("apm")) { AuditPlanningMemorandum apm = db.AuditPlanningMemorandums.Find(id); string content = "Dear {0}, <BR/><BR/>You had posted a comment on APM : {1}. <BR/><BR/> Your comment : <i>\"{3}\"</i>.<BR/><BR/>Please click on this <a href=\"{2}\" title=\"your APM\">link</a> to show your comment for the APM.<BR/><BR/><BR/> Regards,<BR/><BR/><BR/> ePatria Team"; string postUrl = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/AuditPlanningMemorandums/Details/" + id; emailTransact.SentEmailToCommentedUser(empl.Email, empl.Name, apm.NomerAPM, content, postUrl, message); if (apm.PICID != null) { var employ = db.Employees.Where(p => p.Name.Equals(apm.PICID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Responsible person for APM : {1}. Someone has comment on this APM. Please click on this <a href=\"{2}\" title=\"your APM\">link</a> to show the APM.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/AuditPlanningMemorandums/Details/" + id; emailTransact.SentEmailAPM(emp.Email, emp.Name, apm.NomerAPM, emailContent, url); } if (apm.SupervisorID != null) { var employ = db.Employees.Where(p => p.Name.Equals(apm.SupervisorID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Supervisor for APM : {1}. Someone has comment on this APM. Please click on this <a href=\"{2}\" title=\"your APM\">link</a> to show the APM.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/AuditPlanningMemorandums/Details/" + id; emailTransact.SentEmailAPM(emp.Email, emp.Name, apm.NomerAPM, emailContent, url); } if (apm.TeamLeaderID != null) { var employ = db.Employees.Where(p => p.Name.Equals(apm.TeamLeaderID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Team Leader for APM : {1}. Someone has comment on this APM. Please click on this <a href=\"{2}\" title=\"your APM\">link</a> to show the APM.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/AuditPlanningMemorandums/Details/" + id; emailTransact.SentEmailAPM(emp.Email, emp.Name, apm.NomerAPM, emailContent, url); } if (apm.MemberID != null) { foreach (var mem in apm.MemberID.Split(';')) { if (!String.IsNullOrEmpty(mem)) { var employ = db.Employees.Where(p => p.Name.Equals(mem)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Member for APM : {1}. Someone has comment on this APM. Please click on this <a href=\"{2}\" title=\"your APM\">link</a> to show the APM.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/AuditPlanningMemorandums/Details/" + id; emailTransact.SentEmailAPM(emp.Email, emp.Name, apm.NomerAPM, emailContent, url); } } } } if (Id.Contains("letter")) { LetterOfCommand letter = db.LetterOfCommands.Find(id); string content = "Dear {0}, <BR/><BR/>You had posted a comment on SP : {1}. <BR/><BR/> Your comment : <i>\"{3}\"</i>.<BR/><BR/>Please click on this <a href=\"{2}\" title=\"your SP\">link</a> to show your comment for the SP.<BR/><BR/><BR/> Regards,<BR/><BR/><BR/> ePatria Team"; string postUrl = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/LetterOfCommands/Details/" + id; emailTransact.SentEmailToCommentedUser(empl.Email, empl.Name, letter.NomorSP, content, postUrl, message); if (letter.PICID != null) { var employ = db.Employees.Where(p => p.Name.Equals(letter.PICID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Responsible person for SP : {1}. Someone has comment on this SP. Please click on this <a href=\"{2}\" title=\"your SP\">link</a> to show the SP.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/LetterOfCommands/Details/" + id; emailTransact.SentEmailLetter(emp.Email, emp.Name, letter.NomorSP, emailContent, url); } if (letter.SupervisorID != null) { var employ = db.Employees.Where(p => p.Name.Equals(letter.SupervisorID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Supervisor for SP : {1}. Someone has comment on this SP. Please click on this <a href=\"{2}\" title=\"your SP\">link</a> to show the SP.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/LetterOfCommands/Details/" + id; emailTransact.SentEmailLetter(emp.Email, emp.Name, letter.NomorSP, emailContent, url); } if (letter.TeamLeaderID != null) { var employ = db.Employees.Where(p => p.Name.Equals(letter.TeamLeaderID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Team Leader for SP : {1}. Someone has comment on this SP. Please click on this <a href=\"{2}\" title=\"your SP\">link</a> to show the SP.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/LetterOfCommands/Details/" + id; emailTransact.SentEmailLetter(emp.Email, emp.Name, letter.NomorSP, emailContent, url); } if (letter.MemberID != null) { foreach (var mem in letter.MemberID.Split(';')) { if (!String.IsNullOrEmpty(mem)) { var employ = db.Employees.Where(p => p.Name.Equals(mem)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Member for SP : {1}. Someone has comment on this SP. Please click on this <a href=\"{2}\" title=\"your SP\">link</a> to show the SP.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/LetterOfCommands/Details/" + id; emailTransact.SentEmailLetter(emp.Email, emp.Name, letter.NomorSP, emailContent, url); } } } } if (Id.Contains("prelim")) { Preliminary pre = db.Preliminaries.Find(id); string content = "Dear {0}, <BR/><BR/>You had posted a comment on Prelim : {1}. <BR/><BR/> Your comment : <i>\"{3}\"</i>.<BR/><BR/>Please click on this <a href=\"{2}\" title=\"your Prelim\">link</a> to show your comment for the Prelim.<BR/><BR/><BR/> Regards,<BR/><BR/><BR/> ePatria Team"; string postUrl = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/Preliminaries/Details/" + id; emailTransact.SentEmailToCommentedUser(empl.Email, empl.Name, pre.NomorPreliminarySurvey, content, postUrl, message); if (pre.EngagementActivity.PICID != null) { var employ = db.Employees.Where(p => p.Name.Equals(pre.EngagementActivity.PICID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Responsible person for Prelim : {1}. Someone has comment on this Prelim. Please click on this <a href=\"{2}\" title=\"your Prelim\">link</a> to show the Prelim.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/Preliminaries/Details/" + id; emailTransact.SentEmailPrelim(emp.Email, emp.Name, pre.NomorPreliminarySurvey, emailContent, url); } if (pre.EngagementActivity.SupervisorID != null) { var employ = db.Employees.Where(p => p.Name.Equals(pre.EngagementActivity.SupervisorID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Supervisor for Prelim : {1}. Someone has comment on this Prelim. Please click on this <a href=\"{2}\" title=\"your Prelim\">link</a> to show the Prelim.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/Preliminaries/Details/" + id; emailTransact.SentEmailPrelim(emp.Email, emp.Name, pre.NomorPreliminarySurvey, emailContent, url); } if (pre.EngagementActivity.TeamLeaderID != null) { var employ = db.Employees.Where(p => p.Name.Equals(pre.EngagementActivity.TeamLeaderID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Team Leader for Prelim : {1}. Someone has comment on this Prelim. Please click on this <a href=\"{2}\" title=\"your Prelim\">link</a> to show the Prelim.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/Preliminaries/Details/" + id; emailTransact.SentEmailPrelim(emp.Email, emp.Name, pre.NomorPreliminarySurvey, emailContent, url); } if (pre.EngagementActivity.MemberID != null) { foreach (var mem in pre.EngagementActivity.MemberID.Split(';')) { if (!String.IsNullOrEmpty(mem)) { var employ = db.Employees.Where(p => p.Name.Equals(mem)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Member for Prelim : {1}. Someone has comment on this Prelim. Please click on this <a href=\"{2}\" title=\"your Prelim\">link</a> to show the Prelim.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/Preliminaries/Details/" + id; emailTransact.SentEmailPrelim(emp.Email, emp.Name, pre.NomorPreliminarySurvey, emailContent, url); } } } } if (Id.Contains("bpm")) { BPM bpm = db.BPMs.Find(id); string content = "Dear {0}, <BR/><BR/>You had posted a comment on BPM : {1}. <BR/><BR/> Your comment : <i>\"{3}\"</i>.<BR/><BR/>Please click on this <a href=\"{2}\" title=\"your SP\">link</a> to show your comment for the BPM.<BR/><BR/><BR/> Regards,<BR/><BR/><BR/> ePatria Team"; string postUrl = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/Walktroughs/CreateBusiness/" + id + "?walkid=" + bpm.WalktroughID; emailTransact.SentEmailToCommentedUser(empl.Email, empl.Name, bpm.Name, content, postUrl, message); if (bpm.Walktrough.Preliminary.EngagementActivity.PICID != null) { var employ = db.Employees.Where(p => p.Name.Equals(bpm.Walktrough.Preliminary.EngagementActivity.PICID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Responsible person for BPM : {1}. Someone has comment on this BPM. Please click on this <a href=\"{2}\" title=\"your BPM\">link</a> to show the BPM.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/Walktroughs/CreateBusiness/" + id + "?walkid=" + bpm.WalktroughID; emailTransact.SentEmailBPM(emp.Email, emp.Name, bpm.Name, emailContent, url); } if (bpm.Walktrough.Preliminary.EngagementActivity.SupervisorID != null) { var employ = db.Employees.Where(p => p.Name.Equals(bpm.Walktrough.Preliminary.EngagementActivity.SupervisorID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Supervisor for BPM : {1}. Someone has comment on this BPM. Please click on this <a href=\"{2}\" title=\"your BPM\">link</a> to show the BPM.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/Walktroughs/CreateBusiness/" + id + "?walkid=" + bpm.WalktroughID; emailTransact.SentEmailBPM(emp.Email, emp.Name, bpm.Name, emailContent, url); } if (bpm.Walktrough.Preliminary.EngagementActivity.TeamLeaderID != null) { var employ = db.Employees.Where(p => p.Name.Equals(bpm.Walktrough.Preliminary.EngagementActivity.TeamLeaderID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Team Leader for BPM : {1}. Someone has comment on this BPM. Please click on this <a href=\"{2}\" title=\"your BPM\">link</a> to show the BPM.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/Walktroughs/CreateBusiness/" + id + "?walkid=" + bpm.WalktroughID; emailTransact.SentEmailBPM(emp.Email, emp.Name, bpm.Name, emailContent, url); } if (bpm.Walktrough.Preliminary.EngagementActivity.MemberID != null) { foreach (var mem in bpm.Walktrough.Preliminary.EngagementActivity.MemberID.Split(';')) { if (!String.IsNullOrEmpty(mem)) { var employ = db.Employees.Where(p => p.Name.Equals(mem)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Member for BPM : {1}. Someone has comment on this BPM. Please click on this <a href=\"{2}\" title=\"your BPM\">link</a> to show the BPM.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/Walktroughs/CreateBusiness/" + id + "?walkid=" + bpm.WalktroughID; emailTransact.SentEmailBPM(emp.Email, emp.Name, bpm.Name, emailContent, url); } } } } if (Id.Contains("rcm")) { RiskControlMatrix rcm = db.RiskControlMatrixs.Find(id); string content = "Dear {0}, <BR/><BR/>You had posted a comment on RCM : {1}. <BR/><BR/> Your comment : <i>\"{3}\"</i>.<BR/><BR/>Please click on this <a href=\"{2}\" title=\"your RCM\">link</a> to show your comment for the RCM.<BR/><BR/><BR/> Regards,<BR/><BR/><BR/> ePatria Team"; string postUrl = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/Walktroughs/Create/" + rcm.WalktroughID; string names = db.BPMs.Where(p => p.BPMID.Equals(rcm.BusinessProces.BPMID)).Select(p => p.Name).FirstOrDefault(); emailTransact.SentEmailToCommentedUser(empl.Email, empl.Name, names, content, postUrl, message); if (rcm.Walktrough.Preliminary.EngagementActivity.PICID != null) { var employ = db.Employees.Where(p => p.Name.Equals(rcm.Walktrough.Preliminary.EngagementActivity.PICID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Responsible person for RCM : {1}. Someone has comment on this RCM. Please click on this <a href=\"{2}\" title=\"your RCM\">link</a> to show the RCM.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/Walktroughs/Create/" + rcm.WalktroughID; string name = db.BPMs.Where(p => p.BPMID.Equals(rcm.BusinessProces.BPMID)).Select(p => p.Name).FirstOrDefault(); emailTransact.SentEmailRCM(emp.Email, emp.Name, name, emailContent, url); } if (rcm.Walktrough.Preliminary.EngagementActivity.SupervisorID != null) { var employ = db.Employees.Where(p => p.Name.Equals(rcm.Walktrough.Preliminary.EngagementActivity.SupervisorID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Supervisor for RCM : {1}. Someone has comment on this RCM. Please click on this <a href=\"{2}\" title=\"your RCM\">link</a> to show the RCM.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/Walktroughs/Create/" + rcm.WalktroughID; string name = db.BPMs.Where(p => p.BPMID.Equals(rcm.BusinessProces.BPMID)).Select(p => p.Name).FirstOrDefault(); emailTransact.SentEmailRCM(emp.Email, emp.Name, name, emailContent, url); } if (rcm.Walktrough.Preliminary.EngagementActivity.TeamLeaderID != null) { var employ = db.Employees.Where(p => p.Name.Equals(rcm.Walktrough.Preliminary.EngagementActivity.TeamLeaderID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Team Leader for RCM : {1}. Someone has comment on this RCM. Please click on this <a href=\"{2}\" title=\"your RCM\">link</a> to show the RCM.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/Walktroughs/Create/" + rcm.WalktroughID; string name = db.BPMs.Where(p => p.BPMID.Equals(rcm.BusinessProces.BPMID)).Select(p => p.Name).FirstOrDefault(); emailTransact.SentEmailRCM(emp.Email, emp.Name, name, emailContent, url); } if (rcm.Walktrough.Preliminary.EngagementActivity.MemberID != null) { foreach (var mem in rcm.Walktrough.Preliminary.EngagementActivity.MemberID.Split(';')) { if (!String.IsNullOrEmpty(mem)) { var employ = db.Employees.Where(p => p.Name.Equals(mem)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Member for RCM : {1}. Someone has comment on this RCM. Please click on this <a href=\"{2}\" title=\"your RCM\">link</a> to show the RCM.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/Walktroughs/Create/" + rcm.WalktroughID; string name = db.BPMs.Where(p => p.BPMID.Equals(rcm.BusinessProces.BPMID)).Select(p => p.Name).FirstOrDefault(); emailTransact.SentEmailRCM(emp.Email, emp.Name, name, emailContent, url); } } } } if (Id.Contains("control")) { RCMDetailRiskControl control = db.RCMDetailRiskControls.Find(id); string content = "Dear {0}, <BR/><BR/>You had posted a comment on Control FieldWork : {1}. <BR/><BR/> Your comment : <i>\"{3}\"</i>.<BR/><BR/>Please click on this <a href=\"{2}\" title=\"your Control\">link</a> to show your comment for the Control.<BR/><BR/><BR/> Regards,<BR/><BR/><BR/> ePatria Team"; int IdFW = db.FieldWorks.Where(p => p.RiskControlMatrixID.Equals(control.RCMDetailRisk.RiskControlMatrix.RiskControlMatrixID)).Select(p => p.FieldWorkID).FirstOrDefault(); string postUrl = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/FieldWorks/Edit/" + IdFW; emailTransact.SentEmailToCommentedUser(empl.Email, empl.Name, control.ControlName, content, postUrl, message); if (control.RCMDetailRisk.RiskControlMatrix.Walktrough.Preliminary.EngagementActivity.PICID != null) { var employ = db.Employees.Where(p => p.Name.Equals(control.RCMDetailRisk.RiskControlMatrix.Walktrough.Preliminary.EngagementActivity.PICID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Responsible person for Control FieldWork : {1}. Someone has comment on this Control FieldWork. Please click on this <a href=\"{2}\" title=\"your Control\">link</a> to show the Control.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; int IdField = db.FieldWorks.Where(p => p.RiskControlMatrixID.Equals(control.RCMDetailRisk.RiskControlMatrix.RiskControlMatrixID)).Select(p => p.FieldWorkID).FirstOrDefault(); string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/FieldWorks/Edit/" + IdField; emailTransact.SentEmailControl(emp.Email, emp.Name, control.ControlName, emailContent, url); } if (control.RCMDetailRisk.RiskControlMatrix.Walktrough.Preliminary.EngagementActivity.SupervisorID != null) { var employ = db.Employees.Where(p => p.Name.Equals(control.RCMDetailRisk.RiskControlMatrix.Walktrough.Preliminary.EngagementActivity.SupervisorID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Supervisor for Control FieldWork : {1}. Someone has comment on this Control FieldWork. Please click on this <a href=\"{2}\" title=\"your Control\">link</a> to show the Control.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; int IdField = db.FieldWorks.Where(p => p.RiskControlMatrixID.Equals(control.RCMDetailRisk.RiskControlMatrix.RiskControlMatrixID)).Select(p => p.FieldWorkID).FirstOrDefault(); string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/FieldWorks/Edit/" + IdField; emailTransact.SentEmailControl(emp.Email, emp.Name, control.ControlName, emailContent, url); } if (control.RCMDetailRisk.RiskControlMatrix.Walktrough.Preliminary.EngagementActivity.TeamLeaderID != null) { var employ = db.Employees.Where(p => p.Name.Equals(control.RCMDetailRisk.RiskControlMatrix.Walktrough.Preliminary.EngagementActivity.TeamLeaderID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Team Leader for Control FieldWork : {1}. Someone has comment on this Control FieldWork. Please click on this <a href=\"{2}\" title=\"your Control\">link</a> to show the Control.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; int IdField = db.FieldWorks.Where(p => p.RiskControlMatrixID.Equals(control.RCMDetailRisk.RiskControlMatrix.RiskControlMatrixID)).Select(p => p.FieldWorkID).FirstOrDefault(); string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/FieldWorks/Edit/" + IdField; emailTransact.SentEmailControl(emp.Email, emp.Name, control.ControlName, emailContent, url); } if (control.RCMDetailRisk.RiskControlMatrix.Walktrough.Preliminary.EngagementActivity.MemberID != null) { foreach (var mem in control.RCMDetailRisk.RiskControlMatrix.Walktrough.Preliminary.EngagementActivity.MemberID.Split(';')) { if (!String.IsNullOrEmpty(mem)) { var employ = db.Employees.Where(p => p.Name.Equals(mem)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Member for Control FieldWork : {1}. Someone has comment on this Control FieldWork. Please click on this <a href=\"{2}\" title=\"your Control\">link</a> to show the Control.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; int IdField = db.FieldWorks.Where(p => p.RiskControlMatrixID.Equals(control.RCMDetailRisk.RiskControlMatrix.RiskControlMatrixID)).Select(p => p.FieldWorkID).FirstOrDefault(); string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/FieldWorks/Edit/" + IdField; emailTransact.SentEmailControl(emp.Email, emp.Name, control.ControlName, emailContent, url); } } } } if (Id.Contains("draft")) { ConsultingDraftAgreement cda = db.ConsultingDraftAgreements.Find(id); string content = "Dear {0}, <BR/><BR/>You had posted a comment on Draft Agreement : {1}. <BR/><BR/> Your comment : <i>\"{3}\"</i>.<BR/><BR/>Please click on this <a href=\"{2}\" title=\"your Draft \">link</a> to show your reply for the Draft Agreement.<BR/><BR/><BR/> Regards,<BR/><BR/><BR/> ePatria Team"; string postUrl = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/ConsultingDraftAgreements/Details/" + id; emailTransact.SentEmailToCommentedUser(empl.Email, empl.Name, cda.NoRequest, content, postUrl, message); } if (Id.Contains("conleterdetail")) { ConsultingLetterOfCommand letter = db.ConsultingLetterOfCommands.Find(id); string content = "Dear {0}, <BR/><BR/>You had posted a comment on SP : {1}. <BR/><BR/> Your comment : <i>\"{3}\"</i>.<BR/><BR/>Please click on this <a href=\"{2}\" title=\"your SP\">link</a> to show your comment for the SP.<BR/><BR/><BR/> Regards,<BR/><BR/><BR/> ePatria Team"; string postUrl = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/LetterOfCommands/Details/" + id; emailTransact.SentEmailToCommentedUser(empl.Email, empl.Name, letter.NomorSP, content, postUrl, message); if (letter.PicID != null) { var employ = db.Employees.Where(p => p.Name.Equals(letter.PicID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Responsible person for SP : {1}. Someone has comment on this SP. Please click on this <a href=\"{2}\" title=\"your SP\">link</a> to show the SP.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/LetterOfCommands/Details/" + id; emailTransact.SentEmailConsultingLetter(emp.Email, emp.Name, letter.NomorSP, emailContent, url); } if (letter.SupervisorID != null) { var employ = db.Employees.Where(p => p.Name.Equals(letter.SupervisorID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Supervisor for SP : {1}. Someone has comment on this SP. Please click on this <a href=\"{2}\" title=\"your SP\">link</a> to show the SP.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/LetterOfCommands/Details/" + id; emailTransact.SentEmailConsultingLetter(emp.Email, emp.Name, letter.NomorSP, emailContent, url); } if (letter.TeamLeaderID != null) { var employ = db.Employees.Where(p => p.Name.Equals(letter.TeamLeaderID)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Team Leader for SP : {1}. Someone has comment on this SP. Please click on this <a href=\"{2}\" title=\"your SP\">link</a> to show the SP.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/LetterOfCommands/Details/" + id; emailTransact.SentEmailConsultingLetter(emp.Email, emp.Name, letter.NomorSP, emailContent, url); } if (letter.MemberID != null) { foreach (var mem in letter.MemberID.Split(';')) { if (!String.IsNullOrEmpty(mem)) { var employ = db.Employees.Where(p => p.Name.Equals(mem)).Select(p => p.EmployeeID).FirstOrDefault(); Employee emp = db.Employees.Find(Convert.ToInt32(employ)); string emailContent = "Dear {0}, <BR/><BR/>You receive this email as you are registered as Member for SP : {1}. Someone has comment on this SP. Please click on this <a href=\"{2}\" title=\"your SP\">link</a> to show the SP.<BR/><BR/><BR/> Regards,<BR/><BR/> ePatria Team"; string url = Request.RequestUri.GetLeftPart(UriPartial.Authority) + "/LetterOfCommands/Details/" + id; emailTransact.SentEmailConsultingLetter(emp.Email, emp.Name, letter.NomorSP, emailContent, url); } } } }*/ return response; } else { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } }