示例#1
0
        public async Task <IActionResult> EditSeanceAsync(UpsertSeanceRequest request)
        {
            if (!await _seanceService.CheckId(request.Id))
            {
                return(BadRequest());
            }

            try
            {
                IReadOnlyCollection <ServicePriceModel> services = request.Services.Adapt <IReadOnlyCollection <ServicePriceModel> >();

                IReadOnlyCollection <SeatPriceModel> seatPrices = request.SeatPrices.Adapt <IReadOnlyCollection <SeatPriceModel> >();

                SeanceModel seanceModel = new SeanceModel(
                    request.Id,
                    request.DateTime,
                    request.FilmId,
                    request.HallId,
                    services,
                    seatPrices
                    );

                await _seanceService.UpsertSeanceAsync(seanceModel);

                return(NoContent());
            }
            catch (Exception e)
            {
                return(Conflict(e.Message));
            }
        }
示例#2
0
        public SeanceModel GetSeanceById(int id)
        {
            _theaterServices = new TheaterServices();
            _hallServices    = new CinemaHallServices();
            _movieServices   = new MovieServices();
            var model = new SeanceModel();

            using (SqlConnection con = new SqlConnection(connect))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("GetSeanceById", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@id", id);
                _adapter = new SqlDataAdapter(cmd);
                _ds      = new DataSet();
                _adapter.Fill(_ds);
                if (_ds.Tables.Count > 0 && _ds.Tables[0].Rows.Count > 0)
                {
                    model.Id         = Convert.ToInt32(_ds.Tables[0].Rows[0]["Id"]);
                    model.Theater    = _theaterServices.GetTheaterBySeance(model.Id);
                    model.CinemaHall = _hallServices.GetCinemaHallById(model.Id);
                    model.Movie      = _movieServices.GetMovieBySeance(model.Id);
                    model.Date       = Convert.ToDateTime(_ds.Tables[0].Rows[0]["Date"]);
                    model.Time       = Convert.ToDateTime((_ds.Tables[0].Rows[0]["Time"]).ToString());
                }
            }
            return(model);
        }
示例#3
0
        public IList <SeanceModel> GetSeanceList()
        {
            _movieServices   = new MovieServices();
            _hallServices    = new CinemaHallServices();
            _theaterServices = new TheaterServices();
            IList <SeanceModel> SeanceList = new List <SeanceModel>();

            _ds = new DataSet();

            using (SqlConnection con = new SqlConnection(connect))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("GetAllSeance", con);
                cmd.CommandType = CommandType.StoredProcedure;
                _adapter        = new SqlDataAdapter(cmd);
                _adapter.Fill(_ds);
                if (_ds.Tables.Count > 0)
                {
                    for (int i = 0; i < _ds.Tables[0].Rows.Count; i++)
                    {
                        SeanceModel obj = new SeanceModel();
                        obj.Id         = Convert.ToInt32(_ds.Tables[0].Rows[i]["Id"]);
                        obj.Theater    = _theaterServices.GetTheaterBySeance(obj.Id);
                        obj.CinemaHall = _hallServices.GetCinemaHallBySeance(obj.Id);
                        obj.Movie      = _movieServices.GetMovieBySeance(obj.Id);
                        obj.Date       = Convert.ToDateTime(_ds.Tables[0].Rows[i]["Date"]);
                        obj.Time       = Convert.ToDateTime((_ds.Tables[0].Rows[i]["Time"]).ToString());
                        SeanceList.Add(obj);
                    }
                }
            }

            return(SeanceList);
        }
示例#4
0
        public ActionResult AddSeance(SeanceModel model)
        {
            _seanceServices = new SeanceServices();
            _seanceServices.InsertSeance(model);

            return(RedirectToAction("ListSeance"));
        }
示例#5
0
 public SeanceData(SeanceModel model)
 {
     SeanceID        = model.SeanceID;
     MovieID         = model.MovieID;
     Title           = model.MovieInfo.Title;
     SeanceDate      = model.SeanceDate;
     SalaID          = model.CinemaHallID;
     AreFreePosition = ComplexQueries.AreFreePositions(model.SeanceID, model.CinemaHallID);
 }
示例#6
0
 public void InsertSeance(SeanceModel model)
 {
     using (SqlConnection con = new SqlConnection(connect))
     {
         con.Open();
         SqlCommand cmd = new SqlCommand("AddSeance", con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@id_cinema_hall", model.CinemaHall.Id);
         cmd.Parameters.AddWithValue("@id_movie", model.Movie.Id);
         cmd.Parameters.AddWithValue("@date", model.Date);
         cmd.Parameters.AddWithValue("@time", model.Time);
         cmd.ExecuteNonQuery();
     }
 }
        public async Task UpsertSeanceAsync(SeanceModel seanceModel)
        {
            try
            {
                using (OperationContext context = _seanceRepository.GetOperationContext())
                {
                    int id = await _seanceRepository.UpsertSeanceAsync(
                        seanceModel.Adapt <SeanceEntity>(),
                        context
                        );

                    TypeAdapterConfig <SeatPriceModel, SeatPriceEntity>
                    .NewConfig()
                    .Map(dest => dest.SeanceId, sourse => id);

                    await _seanceRepository.AddSeanceSeatPricesAsync(
                        seanceModel
                        .SeatPrices
                        .Adapt <IReadOnlyCollection <SeatPriceEntity> >(),
                        context
                        );

                    TypeAdapterConfig <ServicePriceModel, ServicePriceEntity>
                    .NewConfig()
                    .Map(dest => dest.SeanceId, sourse => id);

                    await _seanceRepository.AddSeanceAdditionalServicesAsync(
                        seanceModel
                        .Services
                        .Adapt <IReadOnlyCollection <ServicePriceEntity> >(),
                        context
                        );

                    context.Apply();
                }
            }
            catch (UniqueIndexException e)
            {
                throw new ConflictException(e);
            }
        }
示例#8
0
 public ActionResult EditSeance(SeanceModel model)
 {
     _seanceServices = new SeanceServices();
     _seanceServices.UpdateSeance(model);
     return(RedirectToAction("ListSeance"));
 }
示例#9
0
 public ActionResult GenerateSeances(SeanceModel model)
 {
     _seanceServices = new SeanceServices();
     _seanceServices.GenereateSeances(model.Date, model.Theater.Id);
     return(RedirectToAction("GenerateSeances"));
 }