public void DeleteCommentOnTheVisit(int id) { CommentOnTheVisit commentOnTheVisit = db.CommentOnTheVisits.Find(id); db.CommentOnTheVisits.Remove(commentOnTheVisit); db.SaveChanges(); }
public ActionResult DeleteConfirmed(int id) { CommentOnTheVisit commentOnTheVisit = db.CommentOnTheVisits.Find(id); db.CommentOnTheVisits.Remove(commentOnTheVisit); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "CommentOnTheVisitID,TypeOfComment,Comment")] CommentOnTheVisit commentOnTheVisit) { if (ModelState.IsValid) { db.Entry(commentOnTheVisit).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(commentOnTheVisit)); }
public ActionResult Create([Bind(Include = "CommentOnTheVisitID,TypeOfComment,Comment")] CommentOnTheVisit commentOnTheVisit) { if (ModelState.IsValid) { db.CommentOnTheVisits.Add(commentOnTheVisit); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(commentOnTheVisit)); }
// GET: CommentOnTheVisits/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CommentOnTheVisit commentOnTheVisit = db.CommentOnTheVisits.Find(id); if (commentOnTheVisit == null) { return(HttpNotFound()); } return(View(commentOnTheVisit)); }
public void CommentOnTheVisitTest1() { CommentOnTheVisit commentOnTheVisit; int id; using (var db = new ApplicationDbContext("DefaultConnection")) { var ctrl = new MedHairController(db); commentOnTheVisit = new CommentOnTheVisit() { Comment = "Comment", TypeOfComment = TypeOfComment.AdministratoroTheDoctor, }; id = ctrl.CreateCommentOnTheVisit(commentOnTheVisit); var commentOnTheVisitRes = ctrl.GetCommentOnTheVisit(id); Assert.IsNotNull(commentOnTheVisitRes); Assert.AreEqual("Comment", commentOnTheVisitRes.Comment); Assert.AreEqual(TypeOfComment.AdministratoroTheDoctor, commentOnTheVisitRes.TypeOfComment); } using (var db = new ApplicationDbContext("DefaultConnection")) { var ctrl = new MedHairController(db); commentOnTheVisit.CommentOnTheVisitID = id; commentOnTheVisit.Comment = "Comment1"; ctrl.EditCommentOnTheVisit(commentOnTheVisit); var commentOnTheVisitRes = ctrl.GetCommentOnTheVisit(id); Assert.IsNotNull(commentOnTheVisitRes); Assert.AreEqual("Comment1", commentOnTheVisitRes.Comment); Assert.AreEqual(TypeOfComment.AdministratoroTheDoctor, commentOnTheVisitRes.TypeOfComment); } using (var db = new ApplicationDbContext("DefaultConnection")) { var ctrl = new MedHairController(db); ctrl.DeleteCommentOnTheVisit(commentOnTheVisit.CommentOnTheVisitID); var commentOnTheVisitRes = ctrl.GetCommentOnTheVisit(id); Assert.IsNull(commentOnTheVisitRes); } }
public int CreateCommentOnTheVisit(CommentOnTheVisit commentOnTheVisit) { db.CommentOnTheVisits.Add(commentOnTheVisit); db.SaveChanges(); return(commentOnTheVisit.CommentOnTheVisitID); }
public void EditCommentOnTheVisit(CommentOnTheVisit commentOnTheVisit) { db.Entry(commentOnTheVisit).State = EntityState.Modified; db.SaveChanges(); }