public static Borrow MapDtoToBorrow(BorrowDto borrow) { return(new Borrow() { Id = borrow.Id.GetValueOrDefault(), DateOfBorrow = borrow.DateOfBorrow.GetValueOrDefault(), DateOfReturn = borrow.DateOfReturn.GetValueOrDefault() }); }
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); }
public async Task <BorrowedGameResponse> BorrowGame(BorrowDto borrowDto) { BorrowedGameDto borrowedGameDto = new BorrowedGameDto { IdFriend = borrowDto.IdFriend, IdGame = borrowDto.IdGame }; return(await Add(borrowedGameDto)); }
/// <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); }
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.")); }
public async Task <IActionResult> CreateBorrow([FromBody] BorrowDto borrow) { if (borrow == null) { return(BadRequest()); } await _borrowService.Add(borrow); return(Created("Created new borrow.", borrow)); }
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))); } }
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)); }
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); }
protected override void QueryData() { _borrowDto = base.AssetsOptionService.QueryBorrow(DoAssetsId); }