public async Task <Event> GetEventById(int eventId) { var eventById = await _dataContext.Events.FirstOrDefaultAsync(x => x.EventId == eventId); if (eventById == null) { throw new NullReferenceException("Selected event doesn't exist"); } _dataContext.Entry(eventById).Reference(e => e.Place).Load(); _dataContext.Entry(eventById).Collection(e => e.SeatStatuses).Load(); return(eventById); }
public Business Get(int id) { Business business = _context.Businesses.SingleOrDefault(x => x.Id == id); _context.Entry(business).Reference(b => b.Address).Load(); return(business); }
public async Task <bool> UpdateCustomer(Customer customer) { _context.Entry(_context.Customer.FirstOrDefault(c => c.CustomerId == customer.CustomerId)).CurrentValues.SetValues(customer); if (await _context.SaveChangesAsync() > 0) { return(true); } return(false); }
public async Task <bool> UpdatePricePerPeople(PricePerPeople pricePerPeople) { _context.Entry(await _context.PricePerPeople.FirstOrDefaultAsync(c => c.PricePerPeopleId == pricePerPeople.PricePerPeopleId)).CurrentValues.SetValues(pricePerPeople); if (await _context.SaveChangesAsync() > 0) { return(true); } return(false); }
public async Task <bool> UpdateObjectForRent(ObjectForRent objectForRent) { _context.Entry(_context.ObjectForRent.FirstOrDefault(c => c.ObjectForRentId == objectForRent.ObjectForRentId)).CurrentValues.SetValues(objectForRent); if (await _context.SaveChangesAsync() > 0) { return(true); } return(false); }
public async Task <List <Ticket> > GetTickets() { var tickets = await _dataContext.Tickets.ToListAsync(); foreach (var item in tickets) { _dataContext.Entry(item).Reference(t => t.SeatStatus).Load(); _dataContext.Entry(item.SeatStatus).Reference(ss => ss.Seat).Load(); _dataContext.Entry(item.SeatStatus).Reference(ss => ss.Event).Load(); _dataContext.Entry(item.SeatStatus).Reference(ss => ss.SectorPrice).Load(); } return(tickets); }
public async Task <bool> UpdateReservation(Reservation reservation) { var Reservations = await _context.Reservation.FirstOrDefaultAsync(c => c.ReservationId == reservation.ReservationId); Reservations.ObjectForRent = reservation.ObjectForRent; Reservations.Customer = reservation.Customer; _context.Entry(Reservations).CurrentValues.SetValues(reservation); if (await _context.SaveChangesAsync() > 0) { return(true); } return(false); }