Exemple #1
0
        public ActionResult EditChoreList(int Id = 0)
        {
            if (Session["User"] == null)
            {
                return(RedirectToAction("Index", "Register"));
            }

            var User = (_User)Session["User"];

            User            = new _User(UserRepository.RefreshAuthToken(User.AuthToken));
            Session["User"] = User;
            ViewBag.User    = User;

            if (!ChoreRepository.CanEditChoreList(User.Id, Id))
            {
                throw new Exception("Unauthorized to edit chorelist");
            }

            _ChoreList ChoreList = new _ChoreList(ChoreRepository.GetChoreList(Id));

            if (ChoreList.StatusId == 2)
            {
                List <string> Reasons = ChoreRepository.GetInActiveReasons(Id);
                ViewBag.InActiveReasons = Reasons;
            }

            ViewBag.User      = User;
            ViewBag.ChoreList = ChoreList;

            return(View());
        }
Exemple #2
0
        public HttpResponseMessage DeleteChoreList(string AuthToken, int Id)
        {
            try
            {
                var User = UserRepository.RefreshAuthToken(AuthToken);

                if (!ChoreRepository.CanEditChoreList(User.Id, Id))
                {
                    throw new Exception("Not Authorized");
                }

                return(OKResponse(new _ChoreList(ChoreRepository.DeleteChoreList(Id))));
            }
            catch (Exception ex)
            {
                return(ErrorResponse(ex));
            }
        }