public async Task <ActionResult> f_SetSeat(Cl_Seat a_Seat) { if (a_Seat != null && a_Seat.p_Row > 0 && a_Seat.p_Number > 0) { Cl_Session session = m_AppDbContext.p_Sessions.FirstOrDefault(s => s.p_ID == a_Seat.p_SessionID); if (session != null) { Cl_Seat seat = m_AppDbContext.p_Seats.FirstOrDefault(s => s.p_SessionID == session.p_ID && s.p_Row == a_Seat.p_Row && s.p_Number == a_Seat.p_Number); if (seat == null) { seat = a_Seat; m_AppDbContext.p_Seats.Add(seat); } else { seat.p_UserFIO = a_Seat.p_UserFIO; seat.p_Mobile = a_Seat.p_Mobile; seat.p_Price = a_Seat.p_Price; seat.p_TypeEmployment = a_Seat.p_TypeEmployment; seat.p_Comment = a_Seat.p_Comment; } await m_AppDbContext.SaveChangesAsync(); return(Json(seat)); } else { throw new Exception("Сеанс не найден"); } } else { throw new Exception("Место неопределено"); } }
private void f_SetSeatsForNewHall(Cl_Session a_Session, Cl_Seat.E_Type a_Type) { for (int i = 0; i < a_Session.p_Hall.f_GetRowsCount(a_Type); i++) { for (int y = 0; y < a_Session.p_Hall.f_GetRowNumbersCount(a_Type); y++) { m_AppDbContext.p_Seats.Add(new Cl_Seat() { p_SessionID = a_Session.p_ID, p_Type = a_Type, p_Row = i + 1, p_Number = y + 1, p_Price = a_Session.f_GetPrice(a_Type) }); } } }
public ActionResult Session(Guid a_SessionID) { Cl_Session session = m_AppDbContext.p_Sessions.Include(s => s.p_Hall).Include(s => s.p_Seats).ThenInclude(s => s.p_PromoCode).FirstOrDefault(s => s.p_ID == a_SessionID); if (session != null) { if (Request.IsAjaxRequest()) { return(PartialView("~/Areas/Admin/Views/Sessions/Session.cshtml", session)); } else { return(View("~/Areas/Admin/Views/Sessions/Session.cshtml", session)); } } else { throw new Exception("Сеанс не найден"); } }