public async Task <IList <Customer> > GetAsync() { using (var context = DiResolver.Resolve <IHotelContext>()) { return(await context.Customers.AsQueryable().ToListAsync()); } }
//private bool NameIsUnique(IHotelContext context, string name) //{ // var recs = context.Hotels.AsQueryable().Count(h => name.Trim().ToLower() == h.HotelName.Trim().ToLower()); // return recs == 0; //} public async Task DeleteAsync(int id) { using (var context = DiResolver.Resolve <IHotelContext>()) { context.Reservaitions.Delete(e => e.ReservationId == id); await context.ApplyChangesAsync(); } }
public async Task AddAsync(Reservation reservation) { using (var context = DiResolver.Resolve <IHotelContext>()) { context.Reservaitions.Add(reservation); await context.ApplyChangesAsync(); } }
public async Task AddAsync(Hotel hotel) { using (var context = DiResolver.Resolve <IHotelContext>()) { context.Hotels.Add(hotel); await context.ApplyChangesAsync(); } }
public async Task AddAsync(Customer customer) { using (var context = DiResolver.Resolve <IHotelContext>()) { context.Customers.Add(customer); await context.ApplyChangesAsync(); } }
public async Task AddAsync(Room room) { using (var context = DiResolver.Resolve <IHotelContext>()) { context.Rooms.Add(room); await context.ApplyChangesAsync(); } }
public async Task DeleteAsync(Guid id) { using (var context = DiResolver.Resolve <IExampleDomainContext>()) { context.Examples.Delete(e => e.Id == id); await context.ApplyChangesAsync(); } }
public async Task AddAsync(ExampleModel exampleModel) { using (var context = DiResolver.Resolve <IExampleDomainContext>()) { context.Examples.Add(exampleModel); await context.ApplyChangesAsync(); } }
public async Task <IList <Reservation> > GetAsync() { using (var context = DiResolver.Resolve <IHotelContext>()) { var rm = await context.Reservaitions.AsQueryable() .ToListAsync(); return(rm); } }
public async Task <IList <Reservation> > GetAsync(DateTime date) { using (var context = DiResolver.Resolve <IHotelContext>()) { var rm = await context.Reservaitions.AsQueryable() .Where(rv => rv.ReservedFrom <= date && rv.ReservedTo >= date) .ToListAsync(); return(rm); } }
private async Task <IList <ExampleModel> > Get(IList <Guid> ids) { List <ExampleModel> result; using (var context = DiResolver.Resolve <IExampleDomainContext>()) { result = await context.Examples.AsQueryable().Where(ent => ids.Contains(ent.Id)).ToListAsync(); } return(result); }
public async Task <IList <Room> > GetAsync() { using (var context = DiResolver.Resolve <IHotelContext>()) { var rm = await context.Rooms.AsQueryable() .Include(b => b.RoomBeds) .Include(b => b.Reservations) .ToListAsync(); return(rm); } }
public async Task UpdateAsync(Reservation reservation) { using (var context = DiResolver.Resolve <IHotelContext>()) { var existing = await context.Reservaitions.AsQueryable().SingleOrDefaultAsync(x => x.ReservationId == reservation.ReservationId); if (existing == null) { throw new KeyNotFoundException($"No record found with {nameof(Reservation.ReservationId)} {reservation.ReservationId}"); } existing.InjectFrom(reservation); await context.ApplyChangesAsync(); } }
public async Task UpdateAsync(Customer customer) { using (var context = DiResolver.Resolve <IHotelContext>()) { var existing = await context.Customers.AsQueryable().SingleOrDefaultAsync(x => x.CustomerId == customer.CustomerId); if (existing == null) { throw new KeyNotFoundException($"No record found with {nameof(customer.CustomerId)} {customer.CustomerId}"); } existing.InjectFrom(customer); await context.ApplyChangesAsync(); } }
public async Task <IList <Room> > GetAsync(DateTime from, DateTime to) { using (var context = DiResolver.Resolve <IHotelContext>()) { var rm = await context.Rooms.AsQueryable() .Include(b => b.RoomBeds) .Include(b => b.Reservations) .Where(r => (r.Reservations.Count == 0) || (!r.Reservations.Any(rv => (rv.ReservedTo >= from && rv.ReservedFrom <= to)))) .ToListAsync(); return(rm); } }
public async Task UpdateAsync(ExampleModel exampleModel) { using (var context = DiResolver.Resolve <IExampleDomainContext>()) { var existing = await context.Examples.AsQueryable().SingleOrDefaultAsync(x => x.Id == exampleModel.Id); if (existing == null) { throw new KeyNotFoundException($"No record found with {nameof(exampleModel.Id)} {exampleModel.Id}"); } existing.InjectFrom(exampleModel); await context.ApplyChangesAsync(); } }