コード例 #1
0
        public void DeleteCommentOnTheVisit(int id)
        {
            CommentOnTheVisit commentOnTheVisit = db.CommentOnTheVisits.Find(id);

            db.CommentOnTheVisits.Remove(commentOnTheVisit);
            db.SaveChanges();
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            CommentOnTheVisit commentOnTheVisit = db.CommentOnTheVisits.Find(id);

            db.CommentOnTheVisits.Remove(commentOnTheVisit);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
 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));
 }
コード例 #4
0
        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));
        }
コード例 #5
0
        // 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));
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
 public int CreateCommentOnTheVisit(CommentOnTheVisit commentOnTheVisit)
 {
     db.CommentOnTheVisits.Add(commentOnTheVisit);
     db.SaveChanges();
     return(commentOnTheVisit.CommentOnTheVisitID);
 }
コード例 #8
0
 public void EditCommentOnTheVisit(CommentOnTheVisit commentOnTheVisit)
 {
     db.Entry(commentOnTheVisit).State = EntityState.Modified;
     db.SaveChanges();
 }