示例#1
0
        public async Task <StatusLogModel> Create(StatusLogModel model)
        {
            if (model != null)
            {
                var result = await _statusLogRepository.CreateStatusLog(model);

                return(result);
            }
            else
            {
                throw new Exception("Модель операции с книгой была равна нулю");
            }
        }
示例#2
0
        public async Task <BookModel> Return(Guid bookId, string userId, string url)
        {
            ActiveHolderModel holder = new ActiveHolderModel()
            {
                BookId        = bookId,
                UserId        = userId,
                DateOfReceipt = DateTime.Now
            };

            StatusLogModel newLog = new StatusLogModel()
            {
                BookId    = bookId,
                UserId    = userId,
                Date      = DateTime.Now,
                Operation = Operations.Returned
            };


            await _holdersService.Delete(holder);

            await _statusLogService.Create(newLog);

            var result = _bookService.ReturnBook(bookId);

            var listNotification = _notificationService.GetList(bookId);


            foreach (var notification in listNotification)
            {
                var user        = _userService.GetUserById(notification.UserId);
                var book        = _bookService.GetBook(bookId);
                var bookCardURL = url.Replace("UpdateBook", $"BookCard?bookId={book.Id}");
                await _requestClient.Create(new
                {
                    MailTo  = user.Email,
                    Subject = "Интересующая Вас книга появилась в наличии Библиотеки ММТР",
                    Body    = $"Уважаемый(ая) {user.SecondName} {user.FirstName}, книга {book.Title} {book.Author} появилась в библиотеке ММТР. Вы можете взять её по ссылке {bookCardURL}"
                }).GetResponse <IMailSent>();

                await _notificationService.Delete(notification);
            }

            return(result);
        }
示例#3
0
        public async Task <BookModel> Receiving(Guid bookId, string userId)
        {
            ActiveHolderModel newHolder = new ActiveHolderModel()
            {
                BookId        = bookId,
                UserId        = userId,
                DateOfReceipt = DateTime.Now
            };

            StatusLogModel newLog = new StatusLogModel()
            {
                BookId    = bookId,
                UserId    = userId,
                Date      = DateTime.Now,
                Operation = Operations.Take
            };

            await _holdersService.Create(newHolder);

            await _statusLogService.Create(newLog);

            return(_bookService.ReceivingBook(bookId));
        }