public ActionResult DeleteConfirmed(int id) { DetectorComment detectorComment = detectorCommentRepository.GetDetectorCommentByDetectorCommentID(id); detectorCommentRepository.Remove(detectorComment); return(RedirectToAction("Index")); }
public void Remove(DetectorComment detectorComment) { var g = (from r in db.DetectorComments where r.CommentID == detectorComment.CommentID select r).FirstOrDefault(); if (g != null) { try { db.DetectorComments.Remove(g); db.SaveChanges(); } catch (Exception ex) { var repository = ApplicationEventRepositoryFactory.Create(); var error = new ApplicationEvent(); error.ApplicationName = "MOE.Common"; error.Class = "Models.Repository.DetectorCommentRepository"; error.Function = "Delete"; error.Description = ex.Message; error.SeverityLevel = ApplicationEvent.SeverityLevels.High; error.Timestamp = DateTime.Now; repository.Add(error); throw; } } }
public void AddOrUpdate(DetectorComment detectorComment) { var g = (from r in db.DetectorComments where r.CommentID == detectorComment.CommentID select r).FirstOrDefault(); if (g != null) { db.Entry(g).CurrentValues.SetValues(detectorComment); } else { db.DetectorComments.Add(detectorComment); } try { db.SaveChanges(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } }
public ActionResult Edit([Bind(Include = "CommentID,ID,TimeStamp,CommentText")] DetectorComment detectorComment) { if (ModelState.IsValid) { detectorCommentRepository.AddOrUpdate(detectorComment); return(RedirectToAction("Index")); } return(View(detectorComment)); }
public ActionResult Create([Bind(Include = "CommentID, ID,TimeStamp,CommentText")] DetectorComment detectorComment) { if (ModelState.IsValid) { detectorComment.TimeStamp = DateTime.Now; detectorCommentRepository.AddOrUpdate(detectorComment); return(PartialView("~/Views/Signals/EditorTemplates/DetectorComment.cshtml", detectorComment)); } return(PartialView("~/Views/Signals/EditorTemplates/DetectorComment.cshtml", detectorComment)); }
public Models.DetectorComment GetMostRecentDetectorCommentByDetectorID(int ID) { DetectorComment comment = db.DetectorComments.Where(r => r.ID == ID).OrderBy(r => r.TimeStamp).FirstOrDefault(); if (comment != null) { return(comment); } else { return(null); } }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DetectorComment detectorComment = detectorCommentRepository.GetDetectorCommentByDetectorCommentID(id.Value); if (detectorComment == null) { return(HttpNotFound()); } return(View(detectorComment)); }
public ActionResult Create(int id) { MOE.Common.Models.DetectorComment dc = new DetectorComment(); dc.ID = id; return(PartialView(dc)); }