Esempio n. 1
0
        public HttpResponseMessage AddChore(string AuthToken, string ChoreValues)
        {
            try
            {
                _User User        = new _User(UserRepository.RefreshAuthToken(AuthToken));
                Chore ChoreObject = JsonConvert.DeserializeObject <Chore>(ChoreValues);

                var ChoreList = new _ChoreList(ChoreRepository.GetChoreList((int)ChoreObject.ChoreListId));

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

                ChoreObject.IsActive = true;

                return(OKResponse(new _Chore(ChoreRepository.AddChore(ChoreObject))));
            }
            catch (Exception ex)
            {
                return(ErrorResponse(ex));
            }
        }