示例#1
0
        public IActionResult Post([FromBody] HallModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    model.Id = _hallService.Add(model);

                    if (!model.Id.Equals(Guid.Empty))
                    {
                        return(Created(string.Empty, model));
                    }
                    else
                    {
                        return(NoContent());
                    }
                }
                else
                {
                    return(BadRequest(ModelState));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
                return(BadRequest(ModelState));
            }
        }
示例#2
0
        public async Task <IActionResult> Post(HallModel hallModel)
        {
            var hall        = _mapper.Map <Hall>(hallModel);
            var createdHall = await _hallService.AddAsync(hall);

            return(Ok(createdHall));
        }
示例#3
0
        public HallModel GetHallByScreeningId(string screening_id)
        {
            string queryString = "select * from hall where screening_id=@screening_id";
            var    result      = new HallModel();

            using (MySqlConnection conn = new MySqlConnection(connectionstring))
            {
                conn.Open();
                using (MySqlCommand cmd = new MySqlCommand(queryString, conn))
                {
                    cmd.Parameters.Add(new MySqlParameter("@screening_id", screening_id));
                    MySqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        result = new HallModel()
                        {
                            screening_id = reader.GetString("screening_id"),
                            total        = reader.GetInt32("total"),
                            left         = reader.GetInt32("left"),
                            hall_id      = reader.GetString("hall_id"),
                        };
                    }
                    reader.Close();
                }
                conn.Close();
            }
            return(result);
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public HallModel Get(Guid id)
        {
            Hall      hall  = _hallRepository.Get(id);
            HallModel model = Mapper.Map <HallModel>(hall);

            model.Features = _hallRepository.GetFeatures(hall.Id).Select(f => Mapper.Map <FeatureModel>(f)).ToList();
            return(model);
        }
示例#5
0
        public async Task <IActionResult> Put(Guid hallId, HallModel hallModel)
        {
            var hall = await _hallService.GetAsync(hallId);

            _mapper.Map(hallModel, hall);
            var updatedHall = await _hallService.UpdateAsync(hallId, hall);

            return(Ok(updatedHall));
        }
示例#6
0
 public ActionResult EditHall(HallModel hall)
 {
     if (ModelState.IsValid)
     {
         _hallLogic.EditHall(_mapper.Map <HallModel>(hall));
         return(RedirectToAction("ListHalls"));
     }
     return(RedirectToAction("Error", "Home"));
 }
示例#7
0
 public static Hall GetHall(HallModel model)
 {
     return(model != null ? new Hall
     {
         Id = model.Id,
         Name = model.Name,
         PlaceId = model.PlaceId,
         ConcertPlace = GetConcertPlace(model.ConcertPlace)
     } : null);
 }
 public void AddHall(HallModel hall)
 {
     hallsTemp.Add(new HallDto
     {
         Id         = hall.Id,
         Seats      = hall.Seats,
         SeatsTaken = hall.SeatsTaken,
         ScreenType = hall.ScreenType,
         Price      = hall.Price
     });
 }
示例#9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        public void Update(HallModel model)
        {
            Hall   hall   = Mapper.Map <Hall>(model);
            string errors = Validate(hall);

            if (errors != null)
            {
                throw new ValidationException(errors);
            }

            _hallRepository.Update(hall);
        }
示例#10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Guid Add(HallModel model)
        {
            Hall   hall   = Mapper.Map <Hall>(model);
            string errors = Validate(hall);

            if (errors != null)
            {
                throw new ValidationException(errors);
            }

            _hallRepository.Insert(hall);
            return(hall.Id);
        }
示例#11
0
        public void AddHall(HallModel hall)
        {
            connection.Open();
            SqlCommand command = new SqlCommand("INSERT INTO Hall OUTPUT Inserted.ID VALUES (@Price, @ScreenType, @Seats, @SeatsTaken)", connection);

            command.Parameters.AddWithValue("@Price", hall.Price);
            command.Parameters.AddWithValue("@ScreenType", hall.ScreenType);
            command.Parameters.AddWithValue("@Seats", hall.Seats);
            command.Parameters.AddWithValue("@SeatsTaken", hall.SeatsTaken);
            HallModel newHall = new HallModel(((int)command.ExecuteScalar()), hall.Price, hall.ScreenType, hall.Seats, hall.SeatsTaken);

            connection.Close();
        }
示例#12
0
        public void Should_ReturnAHall_WhenGettingAHallById()
        {
            //Arrange
            hallLogic.AddHall(new HallModel {
                Id = 5, Price = 5, ScreenType = "GetByIdTest", Seats = 30, SeatsTaken = 0
            });

            //Act
            HallModel hall = hallLogic.GetHallById(5);

            //Assert
            Assert.True(hall.Id == 5 && hall.ScreenType == "GetByIdTest");
        }
示例#13
0
        public void Should_EditAHall_WhenEditingAnHall()
        {
            //Arrange
            HallModel hall = new HallModel {
                Id = 1, Price = 5, ScreenType = "EditTest", Seats = 30, SeatsTaken = 0
            };

            //Act
            hallLogic.EditHall(hall);

            //Assert
            Assert.True(hallLogic.GetHalls()[0].ScreenType == "EditTest");
        }
示例#14
0
        public void AddHall(HallModel hall)
        {
            using (SqlConnection conn = new SqlConnection(_connection.connectionString))
            {
                conn.Open();

                SqlCommand command = new SqlCommand("INSERT INTO Hall OUTPUT Inserted.ID VALUES (@Price, @ScreenType, @Seats, @SeatsTaken)", conn);
                command.Parameters.AddWithValue("@Price", hall.Price);
                command.Parameters.AddWithValue("@ScreenType", hall.ScreenType);
                command.Parameters.AddWithValue("@Seats", hall.Seats);
                command.Parameters.AddWithValue("@SeatsTaken", hall.SeatsTaken);
                command.ExecuteNonQuery();
            }
        }
示例#15
0
        public void EditHall(HallModel hall)
        {
            connection.Open();
            SqlCommand command = new SqlCommand("UPDATE Hall SET Price = @Price, ScreenType = @ScreenType, Seats = @Seats, " +
                                                "SeatsTaken = @SeatsTaken WHERE Id = @Id", connection);

            command.Parameters.AddWithValue("@Id", hall.Id);
            command.Parameters.AddWithValue("@Price", hall.Price);
            command.Parameters.AddWithValue("@ScreenType", hall.ScreenType);
            command.Parameters.AddWithValue("@Seats", hall.Seats);
            command.Parameters.AddWithValue("@SeatsTaken", hall.SeatsTaken);

            command.ExecuteNonQuery();

            connection.Close();
        }
示例#16
0
        public IHttpActionResult Post([FromBody] HallModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var succes = ServiceResponce.FromSuccess().Result("Concert schedules save complete");
            var error  = ServiceResponce.FromFailed().Result($"Error save concert schedules");
            var res    = _concertService.SaveHall(model);

            if (res != null)
            {
                succes.Add("ConcertPlaceId", res.Id);
            }
            return(Ok(res != null ? succes.Response() : error.Response()));
        }
 public static List <HallModel> GetHallModelList()
 {
     using (CinemaDbEntities c = new CinemaDbEntities())
     {
         List <HallModel> hallModels = new List <HallModel>();
         List <Hall>      halls      = GetHallList();
         foreach (var item in halls)
         {
             HallModel hallModel = new HallModel();
             hallModel.HallId = item.HallId;
             hallModel.Name   = item.Name;
             hallModel.Movie  = HelperMovie.GetMovieById(item.MovieId);
             hallModels.Add(hallModel);
         }
         return(hallModels);
     }
 }
示例#18
0
        //other things
        //List
        //Add
        //details
        //Edit
        //Delete

        public List <HallModel> GetHalls()
        {
            //using ASPNETCinema.Models; added
            halls = new List <HallModel>();
            connection.Open();
            SqlCommand command = new SqlCommand("SELECT * FROM Hall", connection);

            using (SqlDataReader reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    HallModel hall = new HallModel(reader.GetInt32(0), reader.GetDecimal(1), reader.GetString(2), reader.GetInt32(3), reader.GetInt32(4));
                    halls.Add(hall);
                }
            }

            connection.Close();
            return(halls);
        }
示例#19
0
        public void Should_GetHallsFromTheList_WhenGettingHalls()
        {
            //Arrange
            var       hallLogic = new HallLogic(new HallContextMock(), _mapper);
            HallModel hall      = new HallModel {
                Id = 10, Price = 5, ScreenType = "GetTest", Seats = 30, SeatsTaken = 0
            };

            hallLogic.AddHall(hall);
            bool found = false;

            //Act
            if (hallLogic.GetHalls()[4].Id == 10 && hallLogic.GetHalls()[4].ScreenType == "GetTest")
            {
                found = true;
            }

            //Assert
            Assert.True(found);
        }
示例#20
0
 public IActionResult Get(Guid id)
 {
     try
     {
         if (ModelState.IsValid)
         {
             HallModel HallModel = _hallService.Get(id);
             return(Ok(HallModel));
         }
         else
         {
             return(BadRequest(ModelState));
         }
     }
     catch (Exception ex)
     {
         ModelState.AddModelError(string.Empty, ex.Message);
         return(BadRequest(ModelState));
     }
 }
示例#21
0
 public IActionResult Put([FromBody] HallModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _hallService.Update(model);
             return(Ok());
         }
         else
         {
             return(BadRequest(ModelState));
         }
     }
     catch (Exception ex)
     {
         ModelState.AddModelError(string.Empty, ex.Message);
         return(BadRequest(ModelState));
     }
 }
示例#22
0
        public ActionResult Save(HallModel model)
        {
            try
            {
                var hallService    = new SYS_HALL_DAL();
                var monHallService = new MON_HALL_DAL();

                hallService.UpdatePictUrl(model.HallNo, model.ImageUrl);


                #region 保存详细数据

                if (model.RemoveHallConfigs != null)
                {
                    foreach (var item in model.RemoveHallConfigs)
                    {
                        if (item.Type == 1)
                        {
                            monHallService.RemoveHallTabDef(item.HallNo, item.Id);
                        }
                        else
                        {
                            monHallService.RemoveHallCameraDef(item.Id);
                        }
                    }
                }

                if (model.HallTabConfigs != null)
                {
                    monHallService.DeleteHallTabDef(model.HallNo);
                    foreach (var tab in model.HallTabConfigs.Select(item => new MON_HALL_TAB_DEF()
                    {
                        COUNTER_ID = item.Id,
                        HALL_NO = item.HallNo,
                        HORIZ_SIGN = item.X,
                        VERTI_SIGN = item.Y,
                        ICON_URL = item.IconUrl
                    }))
                    {
                        MonHallTabDefDao.AddObject(tab);
                    }
                }
                if (model.HallCameraConfigs != null)
                {
                    foreach (var camera in model.HallCameraConfigs.Select(item => new MON_HALL_CAMERA_DEF()
                    {
                        DIR_TYP = (byte?)item.DirType,
                        SEQ = item.Id,
                        HALL_NO = item.HallNo,
                        HORIZ_SIGN = item.X,
                        VERTI_SIGN = item.Y,
                        ICON_URL = item.IconUrl,
                        CGI_PROTOCOL = item.CgiProtpcpl,
                        CHANNEL_ID = item.ChannelId,
                        HTTP_PROTOCOL = item.HttpProtocol,
                        IP_ADDRESS = item.Ip,
                        IPORT = item.Iport,
                        MON_COUNTER = item.MonCounter,
                        RTSP_PORT = item.RtspPort,
                        STRING_TYP = item.StringType,
                        USER_NAME = item.UserName,
                        USER_PASSWORD = item.Password,
                        ZERO_CHANNEL_IND = item.ZeroChannelInd,
                        CAMERA_TYP = item.CameraType,
                        MON_SHOW_IND = item.MonShowing,
                        CAMERA_NAM = item.CameraName
                    }))
                    {
                        monHallService.SaveHallCameraDef(camera);
                    }
                }

                #endregion

                return(Json(new { success = 0, JsonRequestBehavior.AllowGet }));
            }
            catch
            {
                return(Json(new { success = 1, JsonRequestBehavior.AllowGet }));
            }
        }
示例#23
0
 public void AddHall(HallModel hall)
 {
     _context.AddHall(hall);
 }
示例#24
0
 public void EditHall(HallModel hall)
 {
     _context.EditHall(hall);
 }
示例#25
0
 /// <see cref="IConcertService.SaveHall"/>
 public HallModel SaveHall(HallModel model)
 {
     return(ConcertModelHelper.GetHallModel(_concertRepository.SaveHall(ConcertModelHelper.GetHall(model))));
 }
示例#26
0
 public void EditHall(HallModel hall)
 {
     Repository.EditHall(hall);
 }
示例#27
0
 public void EditHall(HallModel hall)
 {
     edit     = hall.Id;
     editName = hall.ScreenType;
 }
示例#28
0
 public void AddHall(HallModel hall)
 {
     Repository.AddHall(hall);
 }