示例#1
0
        public void CreateSeance(SeancesVM seances)
        {
            var cinemaRes = unitOfWork.Cinemas.GetCount(seances.cinemaId);

            if (cinemaRes.CountSeats.CompareTo(null) != 0)
            {
                //TimeSpan hour = TimeSpan.FromTicks();
                Seances seance = new Seances();
                var     datas  = unitOfWork.Films.Get(seances.cinemaId);
                {
                    seance.SeanceName = seances.seanceName;
                    seance.CinemaId   = seances.cinemaId;
                    seance.FilmId     = seances.filmId;
                    seance.SeanceDate = seances.seanceDate;

                    seance.Price      = seances.price;
                    seance.CountSeats = cinemaRes.CountSeats;
                    seance.AllSeats   = cinemaRes.CountSeats;
                    unitOfWork.Seances.Create(seance);

                    var thisseance = unitOfWork.Seances.GetId(seances.cinemaId, seances.filmId, seances.seanceDate, seances.price).Id;
                    if (thisseance.CompareTo(null) != 0)
                    {
                        var       COUNTSEATS = unitOfWork.Seances.Get(thisseance).AllSeats;
                        BusySeats busy       = new BusySeats();
                        busy.SeanceId   = thisseance;
                        busy.SeatNumber = COUNTSEATS;

                        _busyseatService.CreateSeatBusy(busy);
                    }
                }
            }
        }
        public async Task <IActionResult> PostSeances([FromBody] SeancesVM seances)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            await Task.Run(() => _seanceService.CreateSeance(seances));

            return(Ok(seances));

            //
        }