public async Task <BookFeedbackDto> EditFeedback(int bookId, int personId, EditFeedbackCommand command) { var feedback = await this.Context.BookFeedback.Where(x => x.BookId == bookId && x.PersonId == personId).Include(x => x.Person).SingleAsync(); //if (feedback == null) throw new NotFoundException($"the requested item with bookId: {bookId} and personId: {personId} could not be found"); // All units, concentrate all available resources to the target that needs amending... feedback.Rating = command.Rating > 0 ? command.Rating.Value : feedback.Rating; feedback.Text = string.IsNullOrEmpty(command.Text) ? feedback.Text : command.Text; // Mission succesfull var updatedFeedback = await this.Update(feedback); return(updatedFeedback.ToDto()); }
public async Task <IHttpActionResult> Update(int id, EditFeedbackCommand command) { var personAuthDto = await this.GetAuthorizedMember(this._authRepository); return(await this.Try(() => this._bookFeedbackRepository.EditFeedback(id, personAuthDto.PersonDto.Id, command))); }