コード例 #1
0
        public ActionResult Create(int id)
        {
            if (Session["uid"] != null)
               {
               //Hämta session-id
               theUser = Convert.ToInt64(Session["uid"].ToString());
               }

               CaseComment casecomment = new CaseComment();
               casecomment.caseID = id;
               casecomment.userID = theUser; //TODO actual user-id
               if (Request["comment"] != null && Request["comment"] != "")
               {
               casecomment.commentStr = Request["comment"];
               }
               else
               {
               casecomment.commentStr = "asdf";
               }

               if (ModelState.IsValid)
               {
               casecommentRepository.InsertOrUpdate(casecomment);
               casecommentRepository.Save();
               }
               return View();
        }
コード例 #2
0
        public ActionResult CreateComment(CaseComment caseComment)
        {
            if (ModelState.IsValid)
            {
                var casecommentRepository = new CaseCommentRepository();
                casecommentRepository.InsertOrUpdate(caseComment);
                casecommentRepository.Save();

                return RedirectToAction("Details", new { id = caseComment.caseID });
            }
            return RedirectToAction("Index");
        }
コード例 #3
0
 public ActionResult Edit(CaseComment casecomment)
 {
     if (ModelState.IsValid) {
         casecommentRepository.InsertOrUpdate(casecomment);
         casecommentRepository.Save();
         return RedirectToAction("Index");
     } else {
         return View();
     }
 }
コード例 #4
0
 public void InsertOrUpdate(CaseComment casecomment)
 {
     if (casecomment.commentID == default(int)) {
         // New entity
         context.CaseComments.Add(casecomment);
     } else {
         // Existing entity
         context.Entry(casecomment).State = EntityState.Modified;
     }
 }