public void Update(SeatNo seatno) { _seatnoRepository.Update(seatno); }
public HttpResponseMessage Create(HttpRequestMessage request, CarViewModel carVm) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } else { var crSeat = new Seat(); var crSeatNo = new SeatNo(); string[] seat = new string[] { "A", "B", "C", "D", "E", "G", "H", "I", "K" }; var newCar = new Car(); newCar.UpdateCar(carVm); newCar.CreatedDate = DateTime.Now; _carService.Add(newCar); _carService.Save(); for (int i = 0; i < 9; i++) { crSeat.IDCar = newCar.ID; crSeat.Row = seat[i]; crSeat.isDel = false; _seatService.Add(crSeat); _seatService.Save(); if (seat[i] == "K") //Hàng cuối luôn 5 ghế { for (int n = 1; n <= 10; n++) { var date1 = DateTime.Now; var date = date1.AddDays(n); for (int j = 1; j < 6; j++) { crSeatNo.IDSeat = crSeat.ID; crSeatNo.SeatNb = j; crSeatNo.Status = false; crSeatNo.DateBook = date; _seatnoService.Add(crSeatNo); _seatnoService.Save(); } } } else //Các hàng còn lại 4 ghế { for (int n = 1; n <= 10; n++) { var date1 = DateTime.Now; var date = date1.AddDays(n); for (int j = 1; j < 5; j++) { crSeatNo.IDSeat = crSeat.ID; crSeatNo.SeatNb = j; crSeatNo.Status = false; crSeatNo.DateBook = date; _seatnoService.Add(crSeatNo); _seatnoService.Save(); } } } } var responseData = Mapper.Map <Car, CarViewModel>(newCar); response = request.CreateResponse(HttpStatusCode.Created, responseData); } return response; })); }
public SeatNo Add(SeatNo seatno) { return(_seatnoRepository.Add(seatno)); }
public static void UpdateStatusSeatNo(this SeatNo seatno, SeatNoViewModel seatnoVM) { seatno.ID = seatnoVM.ID; seatno.Status = seatnoVM.Status; }