public async Task <ActionResult> f_RemoveSeats(Guid[] a_SeatsID) { List <Cl_Seat> seats = new List <Cl_Seat>(); foreach (Guid seatID in a_SeatsID) { Cl_Seat seat = m_AppDbContext.p_Seats.Include(s => s.p_PromoCode).FirstOrDefault(s => s.p_ID == seatID); if (seat != null) { Cl_LogsHalls log = new Cl_LogsHalls(); log.p_UserID = m_AppDbContext.p_Users.First(u => u.UserName == User.Identity.Name).p_ID; log.p_SeatID = seat.p_ID; log.p_Date = DateTime.Now; log.p_TypeEmployment = Cl_Seat.E_TypeEmployment.Free; log.p_PromoCodeID = seat.p_PromoCodeID; log.p_Price = seat.p_TotalPrice; seat.p_UserFIO = ""; seat.p_Mobile = ""; seat.p_PromoCodeID = null; seat.p_TypeEmployment = Cl_Seat.E_TypeEmployment.Free; seat.p_Comment = ""; seats.Add(seat); m_AppDbContext.p_LogsHalls.Add(log); } } await m_AppDbContext.SaveChangesAsync(); return(Json(seats)); }
public async Task <ActionResult> f_ActionSeat(Guid[] a_SeatsID, string a_UserFIO, string a_Mobile, Guid?a_PromoCodeID, string a_Comment, Cl_Seat.E_TypeEmployment a_TypeEmployment) { List <Cl_Seat> seats = new List <Cl_Seat>(); foreach (Guid seatID in a_SeatsID) { Cl_Seat seat = m_AppDbContext.p_Seats.Include(s => s.p_PromoCode).FirstOrDefault(s => s.p_ID == seatID); if (seat != null) { Cl_LogsHalls log = new Cl_LogsHalls(); log.p_UserID = m_AppDbContext.p_Users.First(u => u.UserName == User.Identity.Name).p_ID; log.p_SeatID = seat.p_ID; log.p_Date = DateTime.Now; if (a_TypeEmployment == Cl_Seat.E_TypeEmployment.Free) { seat.p_UserFIO = ""; seat.p_Mobile = ""; seat.p_TypeEmployment = Cl_Seat.E_TypeEmployment.Free; seat.p_Comment = ""; } else { seat.p_UserFIO = a_UserFIO; seat.p_Mobile = a_Mobile; seat.p_PromoCodeID = a_PromoCodeID; seat.p_TypeEmployment = a_TypeEmployment; seat.p_Comment = a_Comment; } log.p_TypeEmployment = seat.p_TypeEmployment; if (a_PromoCodeID != null) { Cl_PromoCode pcode = await m_AppDbContext.p_PromoCodes.FirstOrDefaultAsync(p => p.p_ID == a_PromoCodeID); if (pcode != null) { seat.p_PromoCode = pcode; } } log.p_PromoCodeID = seat.p_PromoCodeID; log.p_Price = seat.p_TotalPrice; seats.Add(seat); m_AppDbContext.p_LogsHalls.Add(log); } } await m_AppDbContext.SaveChangesAsync(); m_AppDbContext.p_Seats.Include(s => s.p_PromoCode).Load(); return(Json(seats)); }