コード例 #1
0
        public HttpResponseMessage UpdateChoreUser(string AuthToken, int Id, string ChoreUserValues)
        {
            try
            {
                _User     User            = new _User(UserRepository.RefreshAuthToken(AuthToken));
                ChoreUser ChoreUserObject = JsonConvert.DeserializeObject <ChoreUser>(ChoreUserValues);

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

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

                //keep chore user as active
                ChoreUserObject.IsActive = true;

                return(OKResponse(new _ChoreUser(ChoreRepository.UpdateChoreUser(Id, ChoreUserObject))));
            }
            catch (Exception ex)
            {
                return(ErrorResponse(ex));
            }
        }