public ActionResult GetSeatsDictionary(PMSeatsVM model, int FillSeat, string SeatRowID, string JsonDict) { model.Seats = JsonConvert.DeserializeObject <Dictionary <string, List <string> > >(JsonDict); // if (!model.Seats.ContainsKey(SeatRowID)) // model.Seats[SeatRowID] = new List<string>(); int s = model.Seats[SeatRowID].Count(); if (FillSeat > s) { for (int i = s, j = 1; i < FillSeat; i++, j++) { model.Seats[SeatRowID].Add((s + j).ToString()); } } if (FillSeat < s) { for (int i = s; i > FillSeat; i--) { model.Seats[SeatRowID].RemoveAt(i - 1); } } return(PartialView("GetSeatsDictionary", model)); }
public ActionResult GetSeats(int?cinemaHallID) { PMSeatsVM model = new PMSeatsVM(); foreach (SeatRow sr in model.SeatRow) { model.Seats[sr.SeatRowID] = new List <string>(); } model.CinemaHall = principal.CinemaHalls.Where(x => x.CinemaHallID == cinemaHallID).First(); List <Seat> seats = principal.Seats.Where(x => x.CinemaHallID == cinemaHallID && !x.IsDeleted).ToList(); foreach (Seat s in seats) { model.Seats[s.SeatRowID].Add(s.SeatColumnID.ToString()); } if (cinemaHallID == null) { RedirectToAction("Index"); } return(PartialView("GetSeats", model)); }