public async Task CreateAsync(Reservation entity) { var reservation = new Reservation { ReservationDate = entity.ReservationDate, NumberOfTickets = entity.NumberOfTickets, CustomerId = entity.CustomerId, MatchSectionId = entity.MatchSectionId, Price = entity.Price }; _dbContext.Entry(reservation).State = EntityState.Added; var matchSection = await _dbContext.MatchSections.FirstOrDefaultAsync(s => s.Id == entity.MatchSectionId); matchSection.OccupiedReservationSeats += reservation.NumberOfTickets; try { await _dbContext.SaveChangesAsync(); } catch (Exception ex) { throw ex; } }
public async Task CreateAsync(Subscription subscription) { _dbContext.Entry(subscription).State = EntityState.Added; var section = await _dbContext.Sections.FirstOrDefaultAsync(s => s.Id == subscription.SectionId); section.OccupiedSubscriptionSeats++; try { await _dbContext.SaveChangesAsync(); } catch (Exception ex) { throw ex; } }
public async Task AddAsync(Customer entity) { _dbContext.Entry(entity).State = EntityState.Added; try { await _dbContext.SaveChangesAsync(); }catch (Exception ex) { throw ex; } }