Ejemplo n.º 1
0
        public HttpResponseMessage AddChoreUser(string AuthToken, 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");
                }

                //set Chore User as Active
                ChoreUserObject.IsActive = true;

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