Skip to content

Commit

Permalink
Merge pull request #168 from raffacabofrio/master
Browse files Browse the repository at this point in the history
Apagando incêndio.
  • Loading branch information
raffacabofrio authored Dec 8, 2018
2 parents 869cd5b + c923f85 commit 7240dc1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ShareBook/ShareBook.Api/Controllers/BookController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public IActionResult RequestBook([FromBody] RequestBookVM requestBookVM)
_bookUserService.Insert(requestBookVM.BookId, requestBookVM.Reason);
var result = new Result
{
SuccessMessage = "Pedido realizo com sucesso!",
SuccessMessage = "Pedido realizado com sucesso!",
};
return Ok(result);
}
Expand Down
10 changes: 6 additions & 4 deletions ShareBook/ShareBook.Service/Book/BookService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public BookService(IBookRepository bookRepository,
_booksEmailService = booksEmailService;
}

public Result<Book> Approve(Guid bookId, DateTime? chooseDate)
public Result<Book> Approve(Guid bookId, DateTime? chooseDate = null)
{
var book = _repository.Find(bookId);
if (book == null)
Expand All @@ -43,6 +43,9 @@ public Result<Book> Approve(Guid bookId, DateTime? chooseDate)
book.ChooseDate = chooseDate?.Date ?? DateTime.Today.AddDays(5);
_repository.Update(book);

// TODO: obter o usuário doador. Não o usuário logado.
// Github issue: https://github.com/SharebookBR/sharebook-backend/issues/139
book.UserId = new Guid(Thread.CurrentPrincipal?.Identity?.Name);
_booksEmailService.SendEmailBookApproved(book).Wait();

return new Result<Book>(book);
Expand Down Expand Up @@ -146,11 +149,10 @@ public override Result<Book> Update(Book entity)
result.Value = _repository.UpdateAsync(entity).Result;
result.Value.ImageBytes = null;

//Se livro já foi aprovado não enviar e-mail
// TODO: pedir pro pessoal de front usar o endpoint correto de aprovação.
if (!bookAlreadyApproved && entity.Approved)
{
entity.UserId = new Guid(Thread.CurrentPrincipal?.Identity?.Name);
_booksEmailService.SendEmailBookApproved(entity);
this.Approve(entity.Id);
}


Expand Down

0 comments on commit 7240dc1

Please sign in to comment.