示例#1
0
        public HttpResponseMessage GetChore(string AuthToken, int Id)
        {
            try
            {
                _User User = new _User(UserRepository.RefreshAuthToken(AuthToken));

                //get chore from Id
                var ChoreObject = new _Chore(ChoreRepository.GetChore(Id));

                //get ChoreList from Choreobject
                var ChoreList = new _ChoreList(ChoreRepository.GetChoreList(ChoreObject.ChoreListId));

                if (User.Id != ChoreList.UserId)
                {
                    throw new Exception("Unauthorized");
                }

                return(OKResponse(ChoreObject));
            }
            catch (Exception ex)
            {
                return(ErrorResponse(ex));
            }
        }