/// <summary> /// Inserts or updates showing. If id isn't set (the value is equal 0) the showing is insterted. Otherwise the showing is updated. /// </summary> /// <param name="item">showingDto object</param> /// <returns>Id of interted showing or number of affected rows.</returns> public int InsertOrUpdate(ShowingDto item) { var movie = _movieRepository.Get(item.MovieId); var showing = _mapper.Map <Showing>(item); var theatre = _theatreRepository.Get(item.TheatreId); showing.MovieId = movie; return(_repository.InsertOrUpdate(showing)); }
public void AddShowing() { var showingDto = new ShowingDto() { MovieId = 20, MovieTitle = "Lewiatan", TheatreId = 1, ShowingDateTime = new DateTime(2019, 8, 15, 20, 30, 0) }; addedShowingId = _services.InsertOrUpdate(showingDto); var showingDb = _services.Get(addedShowingId); Assert.ReferenceEquals(showingDb, showingDto); }
public TicketDto GetTicket(ReservationDto reservation) { ShowingDto showing = _mapper.Map <ShowingDto>(_showingRepository.Get(reservation.ShowingId)); RowSeatDto seat = _mapper.Map <RowSeatDto>(_rowSeatRepository.Get(reservation.RowSeatId)); TicketDto ticket = new TicketDto() { Id = reservation.Id, MovieTitle = showing.MovieTitle, RowNumber = seat.RowNumber, SeatNumber = seat.SeatNumber, ShowingDateTime = showing.ShowingDateTime, TheatreId = showing.TheatreId }; return(ticket); }
public IHttpActionResult Delete([FromBody] ShowingDto showing) { _showingService.Remove(showing.Id); return(Json(true)); }
public IHttpActionResult Post([FromBody] ShowingDto showing) { _showingService.InsertOrUpdate(showing); return(Json(true)); }