public ActionResult DeleteConfirmed(int id)
        {
            DetectorComment detectorComment = detectorCommentRepository.GetDetectorCommentByDetectorCommentID(id);

            detectorCommentRepository.Remove(detectorComment);
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        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;
                }
            }
        }
Esempio n. 3
0
        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));
        }
Esempio n. 6
0
        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));
 }