public IActionResult AddNotification([FromBody] NotificationForCreationDto notificationFromBody) { if (!_userService.CheckIfUserExists(notificationFromBody.TargetUserId) || !_offerService.CheckIfOfferExists(notificationFromBody.OfferId)) { return(NotFound()); } if (notificationFromBody.Type == NotificationType.RentRequest) { if (!_offerService.CheckIfOfferIsActive(notificationFromBody.OfferId)) { return(BadRequest("Oferta nieaktywna.")); } else if (_notificationService.CheckIfUserAlreadySendRentRequest( notificationFromBody.TargetUserId, notificationFromBody.OfferId)) { return(BadRequest("Proœba o wypo¿yczenie dla tej oferty ju¿ zosta³a przes³ana.")); } else if (!_rentService.CheckIfUserHasEnoughPoints(notificationFromBody.TargetUserId)) { return(BadRequest("Niewystarczaj¹ca iloœæ punktów na zrealizowanie wypo¿yczenia.")); } } var offerToReturn = _notificationService.AddNotification(notificationFromBody); return(Ok(offerToReturn)); }
public IActionResult ActivateOffer(Guid id) { if (!_offerService.CheckIfOfferExists(id)) { return(NotFound()); } var offer = _offerService.ActivateOffer(id); return(Ok(offer)); }
public IActionResult AddRent([FromBody] RentDto rentFromBody) { if (!_userService.CheckIfUserExists(rentFromBody.BorrowerId) || !_offerService.CheckIfOfferExists(rentFromBody.OfferId)) { return(NotFound()); } //if(!_rentService.CheckIfUserHasEnoughPoints(rentFromBody.BorrowerId)) //{ // return BadRequest("Niewystarczająca ilość punktów na zrealizowanie wypożyczenia."); //} if (!_offerService.CheckIfOfferIsActive(rentFromBody.OfferId)) { return(BadRequest("Oferta nieaktywna.")); } _rentService.AddRent(rentFromBody); return(NoContent()); }