コード例 #1
0
        public ActionResult FollowUpStatusEdit(int id, FollowUpStatusEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.FollowUpStatusTypeID != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new FollowUpStatusService(userId);

            if (service.UpdateFollowUpStatus(model))
            {
                TempData["SaveResult"] = "Your Status Type was updated.";
                return(RedirectToAction("FollowUpStatusIndex"));
            }

            ModelState.AddModelError("", "Your Status Type could not be updated.");
            return(View(model));
        }
コード例 #2
0
        public bool UpdateFollowUpStatus(FollowUpStatusEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .FollowUpStatusTypes
                    .Single(e => e.FollowUpStatusTypeID == model.FollowUpStatusTypeID && e.OwnerId == _userId);

                entity.Status      = model.Status;
                entity.Description = model.Description;
                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #3
0
        public ActionResult FollowUpStatusEdit(int id)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new FollowUpStatusService(userId);
            var detail  = service.GetFollowUpStatusById(id);
            var model   =
                new FollowUpStatusEdit
            {
                FollowUpStatusTypeID = detail.FollowUpStatusTypeID,
                Status      = detail.Status,
                Description = detail.Description
            };

            return(View(model));
        }