Esempio n. 1
0
        public async Task <IHttpActionResult> Put(Chore chore)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            chore.ObjectState = ObjectState.Modified;
            _choreService.Update(chore);

            try
            {
                await _unitOfWorkAsync.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ChoreExists(chore.Id))
                {
                    return(NotFound());
                }
                throw;
            }

            return(new NoContentActionResult(Request, Url.Link("GetChore", new { id = chore.Id })));
        }
Esempio n. 2
0
        public Response Update(Chore chore)
        {
            _choreService.Update(chore);

            return(new Response {
                Body = "success"
            });
        }
Esempio n. 3
0
        public IActionResult Put(int id, [FromBody] ChoreModel updatedChore)
        {
            var chore = _choreService.Update(updatedChore.ToDomainModel());

            if (chore == null)
            {
                return(NotFound());
            }
            //UNSURE
            return(Ok(chore.ToApiModel()));
        }
Esempio n. 4
0
        public Chore UpdateChore([FromBody] Chore chore, DayOfWeek?choreEditedDay = null)
        {
            if (chore == null)
            {
                throw new InvalidParameterException("Invalid parameters!");
            }

            chore = _choreService.Update(chore, choreEditedDay);

            if (chore.FrequencyType != FrequencyType.Once)
            {
                _recurringChoreService.UpdateRecurringChore(chore.Id, chore.FrequencyType, _currentUserService.FamilyID, choreEditedDay);
            }

            return(chore);
        }