public ActionResult AddSeat() { List <Hall> hall = db.Halls.ToList(); List <Seat> seats = db.Seats.ToList(); AddSeatViewModel addSeatViewModel = new AddSeatViewModel() { Halls = hall, Seats = seats }; return(View(addSeatViewModel)); }
public ActionResult AddSeat(Seat seat) { if (seat.HallId != 0 && seat.Row != null && seat.Column != 0) { List <Seat> seat1 = db.Seats.ToList(); if (seat1.Count != 0) { foreach (Seat item in seat1) { if (seat.Column == item.Column && seat.Row == item.Row) { return(Content("Bu yer doludur")); } else { db.Seats.Add(seat); db.SaveChanges(); List <Seat> seats = db.Seats.ToList(); List <Hall> hall = db.Halls.ToList(); AddSeatViewModel addSeatViewModel = new AddSeatViewModel() { Halls = hall, Seats = seats }; return(View(addSeatViewModel)); } } } else { db.Seats.Add(seat); db.SaveChanges(); List <Seat> seats = db.Seats.ToList(); List <Hall> hall = db.Halls.ToList(); AddSeatViewModel addSeatViewModel = new AddSeatViewModel() { Halls = hall, Seats = seats }; return(View(addSeatViewModel)); } } ; return(Content("Xanalari doldurun")); }