public Result <CancelBookDonationVM> CancelAdmin(string id) { var returnBook = _bookUserService.Cancel(new Guid(id), true).Value; var returnBookVm = _mapper.Map <CancelBookDonationVM>(returnBook); return(new Result <CancelBookDonationVM>(returnBookVm)); }
public override JobHistory Work() { var booksLate = _bookService.GetBooksChooseDateIsLate(); var refDate = DateTime.Today.AddDays(_maxLateDonationDaysAutoCancel * -1); var booksAbandoned = booksLate.Where(b => b.ChooseDate < refDate).ToList(); var details = $"Encontradas {booksAbandoned.Count} doações abandonadas com mais de {_maxLateDonationDaysAutoCancel} dias de atraso.\n\n"; foreach (var book in booksAbandoned) { var dto = new BookCancelationDTO { Book = book, CanceledBy = "ShareBot", Reason = $"Cancelamento automático de doação abandonada. Com mais de {_maxLateDonationDaysAutoCancel} dias de atraso.", }; _bookUserService.Cancel(dto); details += $"Doação do livro {book.Title} foi cancelada.\n"; } return(new JobHistory() { JobName = JobName, IsSuccess = true, Details = details }); }
private void CancelDonation(Book book) { var cancelationDTO = new BookCancelationDTO { Book = book, CanceledBy = "USUÁRIO ANONIMIZADO", Reason = "Doação cancelada porque o usuário removeu a própria conta." }; _bookUserService.Cancel(cancelationDTO); }
public IActionResult Cancel(string id) { if (!_IsBookOwner(new Guid(id))) { return(Unauthorized()); } var returnBook = _bookUserService.Cancel(new Guid(id), true).Value; var returnBookVm = _mapper.Map <CancelBookDonationVM>(returnBook); var result = new Result <CancelBookDonationVM>(returnBookVm); return(Ok(result)); }
public IActionResult Cancel(string id, [FromQuery] string reason = "") { if (!_IsBookOwner(new Guid(id))) { return(Unauthorized()); } var cancelationDTO = new BookCancelationDTO { Book = _service.Find(new Guid(id)), CanceledBy = GetSessionUser().Name, Reason = reason }; var returnBook = _bookUserService.Cancel(cancelationDTO).Value; var returnBookVm = _mapper.Map <CancelBookDonationVM>(returnBook); var result = new Result <CancelBookDonationVM>(returnBookVm); return(Ok(result)); }
public Result <Book> CancelAdmin(string id) => _bookUserService.Cancel(new Guid(id), true);
public Result <Book> Cancel(string id) => _bookUserService.Cancel(new Guid(id), false);