Ejemplo n.º 1
0
        public ActionResult ImageRecordDetails(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ImageRecordViewModel irVM = new ImageRecordViewModel();

            irVM.image        = db.images.Find(id);
            irVM.current_user = CurrentUser;
            return(View(irVM));
        }
Ejemplo n.º 2
0
        //GET: Images/ImageRecordEdit
        public ActionResult ImageRecordEdit(int?id)
        {
            ImageRecordViewModel irVM = new ImageRecordViewModel();

            //前端的東西透過image的外鍵屬性來取得
            irVM.image        = db.images.Find(id);
            irVM.current_user = CurrentUser;

            List <SelectListItem> r_statusList = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text  = "Report drafted",
                    Value = "Report drafted",
                },
                new SelectListItem
                {
                    Text  = "Report finalized",
                    Value = "Report finalized",
                }
            };

            ViewBag.ReportStatusSelectList = new SelectList(r_statusList, "Value", "Text");

            List <SelectListItem> c_statusList = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text  = "Comment drafted",
                    Value = "Comment drafted",
                },
                new SelectListItem
                {
                    Text  = "Comment finalized",
                    Value = "Comment finalized",
                },
                new SelectListItem
                {
                    Text  = "Closed",
                    Value = "Closed",
                }
            };

            ViewBag.CommentStatusSelectList = new SelectList(c_statusList, "Value", "Text");
            return(View(irVM));
        }
Ejemplo n.º 3
0
        public ActionResult ImageRecordEdit(ImageRecordViewModel irVM)
        {
            if (ModelState.IsValid)
            {
                //在controller這裡撈出該model,並把前端更改的東西放在這裡輸入 就不用從前端傳整個model的properties過來了
                var report = db.reports.FirstOrDefault(r => r.id == irVM.image.report_id);
                if (irVM.image.report.annotation != report.annotation)
                {
                    report.annotation      = irVM.image.report.annotation;
                    report.status.status1  = irVM.image.report.status.status1;
                    db.Entry(report).State = EntityState.Modified;
                    db.SaveChanges();
                }


                var comment = db.comments.FirstOrDefault(c => c.id == irVM.image.comment_id);
                if (irVM.image.comment.content != comment.content)
                {
                    comment.content         = irVM.image.comment.content;
                    comment.status.status1  = irVM.image.comment.status.status1;
                    db.Entry(comment).State = EntityState.Modified;
                    db.SaveChanges();
                }
                return(RedirectToAction("Index", WebSiteHelper.CurrentUserRole + "s", new { CurrentUser.id }));
            }
            List <SelectListItem> r_statusList = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text  = "Report drafted",
                    Value = "Report drafted",
                },
                new SelectListItem
                {
                    Text  = "Report finalized",
                    Value = "Report finalized",
                }
            };

            ViewBag.ReportStatusSelectList = new SelectList(r_statusList, "Value", "Text");

            List <SelectListItem> c_statusList = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text  = "Comment drafted",
                    Value = "Comment drafted",
                },
                new SelectListItem
                {
                    Text  = "Comment finalized",
                    Value = "Comment finalized",
                },
                new SelectListItem
                {
                    Text  = "Closed",
                    Value = "Closed",
                }
            };

            ViewBag.CommentStatusSelectList = new SelectList(c_statusList, "Value", "Text");
            string role = CurrentUser.role.ToString();

            return(RedirectToAction("Index", role + "s", new { id = CurrentUser.id }));
        }