Example #1
0
        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));
        }
Example #2
0
        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
            });
        }
Example #3
0
        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);
        }
Example #4
0
        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));
        }
Example #6
0
 public Result <Book> CancelAdmin(string id) => _bookUserService.Cancel(new Guid(id), true);
Example #7
0
 public Result <Book> Cancel(string id) => _bookUserService.Cancel(new Guid(id), false);