async Task <BorrowResponseModel> IBikeApplicationService.Borrow(Guid bikeId, Guid userId) { var bike = await _bikeRepository.GetBikeBy(bikeId); var responseModel = new BorrowResponseModel(); if (bike != null) { responseModel.MarkAsFound(); if (bike.IsActive) { responseModel.MarkAsBorrowable(); bike.BorrowBike(); var price = _priceRepository.GetLastPrice(); await _borrowRepository.AddBorrow(Borrow.Create(bikeId, userId, price.Id)); await _bikeRepository.UpdateBike(bike); } } return(responseModel); }
public IActionResult Post(Borrow borrow) { var currentUserProfile = GetCurrentProfile(); borrow.UserProfileId = currentUserProfile.Id; borrow.StartDate = DateTime.Now; _borrowRepository.AddBorrow(borrow); return(NoContent()); }