コード例 #1
0
        public virtual ActionResult GetLikelyThief(LikelyThief likelyThief)
        {
            SetNavigationHierarchy(GetLikelyThiefNavigationItems(likelyThief));

            var getLikelyThiefViewModel = new GetLikelyThiefViewModel(
                likelyThief, HasRightToEditLikelyThief(likelyThief));

            return View(getLikelyThiefViewModel);
        }
コード例 #2
0
        public virtual ActionResult AddLikelyThief(AddLikelyThiefFormViewModel form)
        {
            return Handle(
                () =>
                {
                    var likelyThief = new LikelyThief(UserIdOrDefault, UserNameOrDefault, LikelyThiefStatus.Added,
                                                      form.Name, form.Position, form.Description);

                    _documentSession.Store(likelyThief);
                },
                success: () => MVC.LieDetectorOrThief.LikelyThief.Index());
        }
コード例 #3
0
        public virtual ActionResult EditLikelyThief(LikelyThief likelyThief)
        {
            SetNavigationHierarchy(GetLikelyThiefNavigationItems(likelyThief), "Редактировать");

            var hasRightToEdit = HasRightToEditLikelyThief(likelyThief);
            if (!hasRightToEdit)
                return RedirectToAction(MVC.Home.Index());

            var form = new EditLikelyThiefFormViewModel(
                likelyThief.Name, likelyThief.Position, likelyThief.Description);

            return View(form);
        }
コード例 #4
0
        public virtual ActionResult EditLikelyThief(LikelyThief likelyThief, EditLikelyThiefFormViewModel form)
        {
            return Handle(() =>
                              {
                                  var hasRightToEdit = HasRightToEditLikelyThief(likelyThief);
                                  if (!hasRightToEdit)
                                      throw new SecurityAccessDeniedException();

                                  likelyThief.Name = form.Name;
                                  likelyThief.Position = form.Position;
                                  likelyThief.Description = form.Description;

                                  _documentSession.Store(likelyThief);
                              },
            success: () => MVC.LieDetectorOrThief.LikelyThief.GetLikelyThief());
        }
コード例 #5
0
 private IEnumerable<NavigationItem> GetLikelyThiefNavigationItems(LikelyThief likelyThief)
 {
     return new List<NavigationItem>(GetLikelyThievesNavigationItems())
                {
                    new NavigationItem(likelyThief.Name, MVC.LieDetectorOrThief.LikelyThief.GetLikelyThief(likelyThief))
                };
 }
コード例 #6
0
 private bool HasRightToEditLikelyThief(LikelyThief likelyThief)
 {
     var hasRightToEditLikelyThiefSuggestion = UserIdOrDefault != null && likelyThief.UserId == UserIdOrDefault;
     return hasRightToEditLikelyThiefSuggestion;
 }
コード例 #7
0
        public virtual ActionResult SwitchLikelyThiefStatus(LikelyThief likelyThief, LikelyThiefStatus status)
        {
            return Handle(() =>
                              {
                                  likelyThief.Status = status;

                                  _documentSession.Store(likelyThief);
                              });
        }