Exemple #1
0
        public HttpResponseMessage UpdateChore(string AuthToken, int Id, string ChoreValues)
        {
            try
            {
                _User User = new _User(UserRepository.RefreshAuthToken(AuthToken));

                //get chore from Id
                Chore ChoreObject = JsonConvert.DeserializeObject <Chore>(ChoreValues);

                //get ChoreList from Choreobject
                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.UpdateChore(Id, ChoreObject))));
            }
            catch (Exception ex)
            {
                return(ErrorResponse(ex));
            }
        }