public async Task <NewReservationSummary> New(IReservationCreation reservation) { IProjection projection = await this.projRepo.GetById(reservation.ProjectionId); await this.projRepo.DecreaseAvailableSeats(projection.Id); string movieName = await this.movieRepo.GetMovieNameById(projection.MovieId); var room = await this.roomRepo.GetById(projection.RoomId); string cinemaName = await this.cinemaRepo.GetCinemaNameById(room.CinemaId); var newReservation = new Reservation( projection.StartDate, movieName, cinemaName, room.Number, reservation.Row, reservation.Column, projection.Id); await this.reservationRepo.Insert(newReservation); newReservation.Id = newReservation.Id; var result = new NewReservationSummary(true) { Reservation = newReservation }; return(result); }
public IHttpActionResult Index(ReservationCreationModel model) { NewReservationSummary summary = newRes.New(new Reservation(model.ProjectionIdNumber, model.Row, model.Column)); if (summary.IsCreated) { IReservationDto reservation = reservationRepo.CreateReservationTicket(model.ProjectionIdNumber, model.Column, model.Row); return(Ok(reservation)); } return(BadRequest(summary.Message)); }
public async Task <IHttpActionResult> Index(ReservationCreationModel model) { NewReservationSummary summary = await this.newReservation.New( new Reservation(model.ProjectionId, model.Row, model.Column)); if (summary.IsCreated) { //DONE: add ticket object. var ticketObj = this.modelFactory.Create(summary.Reservation); return(Ok(ticketObj)); } else { return(BadRequest(summary.Message)); } }
public async Task <IHttpActionResult> Create(ReservationCreationModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } NewReservationSummary summary = await newReservation .NewAsync(new Reservation(model.ProjectionId, model.Row, model.Column)); if (summary.IsCreated) { return(Ok(summary.ReservationTicket)); } else { return(BadRequest(summary.Message)); } }
public HttpResponseMessage Index(ReservationCreationModel model) { NewReservationSummary summary = newReservation.New(new Reservation(model.Row, model.Column, model.ProjectionId)); return(Request.CreateResponse(summary.StatusCode, summary.Message)); // TODO: fix null send to client when status is 200 OK }