コード例 #1
0
 public static Borrow MapDtoToBorrow(BorrowDto borrow)
 {
     return(new Borrow()
     {
         Id = borrow.Id.GetValueOrDefault(),
         DateOfBorrow = borrow.DateOfBorrow.GetValueOrDefault(),
         DateOfReturn = borrow.DateOfReturn.GetValueOrDefault()
     });
 }
コード例 #2
0
        public async Task Update(BorrowDto borrow)
        {
            Borrow entity = BorrowMapper.MapDtoToBorrow(borrow);

            entity.Movie = await _iMovieRepository.GetById(borrow.MovieId.GetValueOrDefault());

            entity.Client = await _iClientRepository.GetById(borrow.ClientId.GetValueOrDefault());

            await _iBorrowRepository.Update(entity);
        }
コード例 #3
0
        public async Task <BorrowedGameResponse> BorrowGame(BorrowDto borrowDto)
        {
            BorrowedGameDto borrowedGameDto = new BorrowedGameDto
            {
                IdFriend = borrowDto.IdFriend,
                IdGame   = borrowDto.IdGame
            };

            return(await Add(borrowedGameDto));
        }
コード例 #4
0
        /// <summary>
        /// 查询借用详情
        /// </summary>
        /// <param name="borrowId"></param>
        /// <returns></returns>
        public BorrowDto QueryBorrow(int borrowId)
        {
            var result = new BorrowDto();

            result.BorrowInfo = _borrowRep.Find(borrowId);
            if (null != result.BorrowInfo)
            {
                result.Details = _borrowDetailRep.QueryDto(borrowId);
            }
            return(result);
        }
コード例 #5
0
        public async Task <IActionResult> UpdateBorrow([FromBody] BorrowDto borrow)
        {
            if (borrow == null)
            {
                return(BadRequest());
            }

            await _borrowService.Update(borrow);

            return(Ok($"Borrow with id = {borrow.Id} updated."));
        }
コード例 #6
0
        public async Task <IActionResult> CreateBorrow([FromBody] BorrowDto borrow)
        {
            if (borrow == null)
            {
                return(BadRequest());
            }

            await _borrowService.Add(borrow);

            return(Created("Created new borrow.", borrow));
        }
コード例 #7
0
        public async Task <IActionResult> ReturnGame(BorrowDto borrowDto)
        {
            try
            {
                var response = await _serviceBorrowedGame.ReturnGame(borrowDto);

                return(Ok(response));
            }
            catch (Exception)
            {
                return(BadRequest(new GameResponse(NotificacaoDto.ErroPadrao)));
            }
        }
コード例 #8
0
        public async Task <BorrowedGameResponse> ReturnGame(BorrowDto borrowDto)
        {
            BorrowedGame borrowedGame = await _repositoryBorrowedGame.GetByGameAndFriend(borrowDto.IdGame, borrowDto.IdFriend);

            if (borrowedGame != null)
            {
                return(await Delete(borrowedGame.Id));
            }

            return(new BorrowedGameResponse(new List <NotificacaoDto>()
            {
                new NotificacaoDto(NotificacaoDto.TipoMensagem.Atencao, "Nenhum emprestimo encontrado!")
            }, true));
        }
コード例 #9
0
        public void Post(BorrowDto borrow)
        {
            string   format    = "ddd MMM dd yyyy HH:mm:ss 'GMT'K";
            var      newborrow = new Borrow();
            DateTime borrowback;
            DateTime borrowin;

            DateTime.TryParseExact(borrow.BorrowBack, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out borrowback);
            DateTime.TryParseExact(borrow.BorrowIn, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out borrowin);

            newborrow.Book       = bookServ.GetBookById(Convert.ToInt32(borrow.Id));
            newborrow.BorrowBack = borrowback;
            newborrow.BorrowIn   = borrowin;
            bookServ.CreateBorrow(newborrow);
        }
コード例 #10
0
 protected override void QueryData()
 {
     _borrowDto = base.AssetsOptionService.QueryBorrow(DoAssetsId);
 }