Esempio n. 1
0
        public HttpResponseMessage GetChoreUser(string AuthToken, int Id)
        {
            try
            {
                //get user from auth token
                _User User = new _User(UserRepository.RefreshAuthToken(AuthToken));

                //get chore user object from id
                var ChoreUserObject = new _ChoreUser(ChoreRepository.GetChoreUser(Id));

                //get chorelist from chore user object
                var ChoreList = ChoreRepository.GetChoreList(ChoreUserObject.ChoreListId);

                //check if userid matches chore list object user
                if (User.Id != ChoreList.UserId)
                {
                    throw new Exception("Unathorized");
                }

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