public ActionResult DeleteComments(string ID) { TestOutputRemarks delRemarks = pdDBContext.Remarks.Find(ID); //.Movies.Find(id); if (delRemarks == null) { return(HttpNotFound()); } pdDBContext.Remarks.Remove(delRemarks); pdDBContext.SaveChanges(); var r = "success"; return(Json(r, JsonRequestBehavior.AllowGet)); }
public ActionResult AddTestOutComments(TestOutputRemarks details) { TestOutputRemarks saveComments = pdDBContext.Remarks.FirstOrDefault(d => d.TestOutputID == details.TestOutputID); //var chckRemarks = saveComments[0].Remarks; HistoricalRemarks addRemarksLogs = new HistoricalRemarks(); if (details.Remarks != null) { addRemarksLogs.GUID = System.Guid.NewGuid().ToString().ToUpper(); addRemarksLogs.Department = "TEST"; addRemarksLogs.Operation = "MovesToFG"; addRemarksLogs.ConnectorID = details.TestOutputID; addRemarksLogs.OriginalRemarks = details.Remarks; addRemarksLogs.UpdatedRemarks = null; addRemarksLogs.CreatedBy = Common.GetWebCurrentUser(Common.WebUserInformation.Username); addRemarksLogs.DateAdded = DateTime.Now; pdDBContext.RemarksLogs.Attach(addRemarksLogs); pdDBContext.RemarksLogs.Add(addRemarksLogs); pdDBContext.SaveChanges(); } if (saveComments == null) { if (ModelState.IsValid) { details.CreatedBy = Common.GetWebCurrentUser(Common.WebUserInformation.Username); details.DateCreated = DateTime.Now; pdDBContext.Remarks.Attach(details); pdDBContext.Remarks.Add(details); pdDBContext.SaveChanges(); } } else { return(RedirectToAction("UpdateComments", details)); } return(View()); }
public ActionResult UpdateComments(TestOutputRemarks comments) { TestOutputRemarks updateComments = pdDBContext.Remarks.FirstOrDefault(c => c.TestOutputID == comments.TestOutputID); HistoricalRemarks addRemarksLogs = new HistoricalRemarks(); if (comments.Remarks != null) { addRemarksLogs.GUID = System.Guid.NewGuid().ToString().ToUpper(); addRemarksLogs.Department = "TEST"; addRemarksLogs.Operation = "MovesToFG"; addRemarksLogs.ConnectorID = comments.TestOutputID; addRemarksLogs.UpdatedRemarks = comments.Remarks; addRemarksLogs.OriginalRemarks = updateComments.Remarks; addRemarksLogs.CreatedBy = Common.GetWebCurrentUser(Common.WebUserInformation.Username); addRemarksLogs.DateAdded = DateTime.Now; pdDBContext.RemarksLogs.Attach(addRemarksLogs); pdDBContext.RemarksLogs.Add(addRemarksLogs); pdDBContext.SaveChanges(); } if (updateComments != null) { updateComments.ModifiedBy = Common.GetWebCurrentUser(Common.WebUserInformation.Username); updateComments.DateModified = DateTime.Now; updateComments.Remarks = comments.Remarks; } using (var dbContext = new ProductionDashboardDBContext()) { dbContext.Entry(updateComments).State = System.Data.EntityState.Modified; dbContext.SaveChanges(); } return(View()); }