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)); } }
public async Task <IActionResult> Post(HallModel hallModel) { var hall = _mapper.Map <Hall>(hallModel); var createdHall = await _hallService.AddAsync(hall); return(Ok(createdHall)); }
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); }
/// <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); }
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)); }
public ActionResult EditHall(HallModel hall) { if (ModelState.IsValid) { _hallLogic.EditHall(_mapper.Map <HallModel>(hall)); return(RedirectToAction("ListHalls")); } return(RedirectToAction("Error", "Home")); }
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 }); }
/// <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); }
/// <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); }
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(); }
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"); }
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"); }
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(); } }
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(); }
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); } }
//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); }
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); }
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)); } }
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)); } }
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 })); } }
public void AddHall(HallModel hall) { _context.AddHall(hall); }
public void EditHall(HallModel hall) { _context.EditHall(hall); }
/// <see cref="IConcertService.SaveHall"/> public HallModel SaveHall(HallModel model) { return(ConcertModelHelper.GetHallModel(_concertRepository.SaveHall(ConcertModelHelper.GetHall(model)))); }
public void EditHall(HallModel hall) { Repository.EditHall(hall); }
public void EditHall(HallModel hall) { edit = hall.Id; editName = hall.ScreenType; }
public void AddHall(HallModel hall) { Repository.AddHall(hall); }