public IActionResult Post([FromBody] RentalBO rentalbo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(facade.RentalServices.Create(rentalbo))); }
public RentalBO Add(RentalBO rental) { using (var uow = _facade.UnitOfWork) { var rentalEntity = uow.RentalRepository.Add(conv.Convert(rental)); uow.Complete(); return(conv.Convert(rentalEntity)); } }
internal Rental convert(RentalBO rental) { return(new Rental() { Id = rental.Id, From = rental.From, To = rental.To }); }
public RentalBO Create(RentalBO Ren) { using (var uow = _facade.UnitOfWork) { var rentalEntity = uow.RentalRepository.Create(conv.Convert(Ren)); uow.Complete(); return(conv.Convert(rentalEntity)); } }
public IActionResult Post([FromBody] RentalBO Ren) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var Rental = facade.RentalService.Create(Ren); return(Ok(Rental)); }
public Rental Convert(RentalBO rental) { return(new Rental() { RentalId = rental.Id, DeliveryDate = rental.DeliveryDate, OrderDate = rental.OrderDate, MovieID = rental.MovieID }); }
public IActionResult Put(int id, [FromBody] RentalBO rental) { try { return(Ok(_facade.RentalService.Update(rental))); } catch (Exception) { return(BadRequest($"Couldn't update the rental with the id {rental.Id}.")); } }
public RentalBO Create(RentalBO rental) { if (rental == null) { return(null); } using (var unitOfWork = _facade.UnitOfWork) { var createdRental = unitOfWork.RentalRepository.Create(_converter.Convert(rental)); unitOfWork.Complete(); return(_converter.Convert(createdRental)); } }
internal Rental Convert(RentalBO Ren) { if (Ren == null) { return(null); } return(new Rental() { Id = Ren.Id, From = Ren.From, To = Ren.To, Video = new VideoConverter().Convert(Ren.Video) }); }
public IActionResult Put(int id, [FromBody] RentalBO rentalbo) { if (id != rentalbo.Id) { return(StatusCode(405, "Path id does not match rental ID json object")); } try { return(Ok(facade.RentalServices.Update(rentalbo))); } catch (InvalidOperationException e) { return(StatusCode(404, e.Message)); } }
public RentalBO Update(RentalBO rental) { using (var uow = _facade.UniteOfWork) { var rentalEntity = uow.RentalRepository.Get(rental.Id); if (rentalEntity == null) { throw new InvalidOperationException("rental not found"); } rentalEntity.From = rentalEntity.From; rentalEntity.To = rentalEntity.To; uow.Complete(); return(conv.convert(rentalEntity)); } }
public IActionResult Put(int id, [FromBody] RentalBO rental) { if (id != rental.Id) { return(BadRequest("Path ID does not match video ID in JSON object.")); } try { return(Ok(facade.RentalService.Update(rental))); } catch (InvalidOperationException e) { return(StatusCode(404, e.Message)); } }
public IActionResult Put(int id, [FromBody] RentalBO Ren) { if (id != Ren.Id) { return(BadRequest("Path id does not match rental Id in json")); } try { var rental = facade.RentalService.Update(Ren); return(Ok(rental)); } catch (InvalidOperationException e) { return(StatusCode(404, e.Message)); } }
public IActionResult Put(int id, [FromBody] RentalBO rental) { if (id != rental.Id) { return(BadRequest("Path id does not match a movie")); } try { var rentalUpdated = facade.RentalService.Update(rental); return(Ok(rentalUpdated)); } catch (InvalidOperationException e) { return(StatusCode(404, e.Message)); } }
public Rental Convert(RentalBO rental) { if (rental == null) { return(null); } return(new Rental { Id = rental.Id, From = rental.From, To = rental.To, UserId = rental.UserId, VideoId = rental.VideoId }); }
public RentalBO Update(RentalBO rentalToUpdate) { using (var unitOfWork = _facade.UnitOfWork) { var rental = unitOfWork.RentalRepository.GetById(rentalToUpdate.Id); if (rental == null) { return(null); } rental.From = rentalToUpdate.From; rental.To = rentalToUpdate.To; unitOfWork.RentalRepository.Update(rental); return(_converter.Convert(rental)); } }
public IActionResult Post([FromBody] RentalBO rental) { if (!TryValidateModel(rental)) { return(BadRequest(ModelState.IsValid)); } var rent = facade.RentalService.Add(rental); if (rent != null) { return(Ok(rent)); } else { return(BadRequest("ID already exists.")); } }
internal Rental Convert(RentalBO rental) { if (rental != null) { return(new Rental() { Id = rental.Id, RentalDate = rental.RentalDate, DeliveryDate = rental.DeliveryDate, VideoId = rental.VideoId }); } else { return(null); } }
public RentalBO Update(RentalBO rental) { using (var uow = _facade.UnitOfWork) { var rentalEntity = uow.RentalRepository.Get(rental.Id); if (rentalEntity == null) { throw new InvalidOperationException("Rental not found"); } rentalEntity.DeliveryDate = rental.DeliveryDate; rentalEntity.OrderDate = rental.OrderDate; rentalEntity.MovieID = rentalEntity.MovieID; uow.Complete(); rentalEntity.Movie = uow.MovieRepository.Get(rentalEntity.MovieID); return(conv.Convert(rentalEntity)); } }
public RentalBO Update(RentalBO rental) { using (var uow = _facade.UnitOfWork) { var RentalEntity = uow.RentalRepository.Get(rental.Id); if (RentalEntity != null) { uow.RentalRepository.Get(RentalEntity.Id).DeliveryDate = rental.DeliveryDate; uow.RentalRepository.Get(RentalEntity.Id).RentalDate = rental.RentalDate; uow.RentalRepository.Get(RentalEntity.Id).VideoId = rental.VideoId; uow.Complete(); RentalEntity.Video = uow.VideoRepository.Get(RentalEntity.VideoId); return(conv.Convert(RentalEntity)); } else { throw new InvalidOperationException("Rental not found."); } } }