- Timestamp:
- 07/06/22 13:13:35 (2 years ago)
- Branches:
- master
- Children:
- 899b19d
- Parents:
- d76b7ee
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
resTools_backend/backend/Services/ReservationService.cs
rd76b7ee rcc4db18 11 11 public Task ChangeReservationStatus(int resId, ReservationStatus status); 12 12 public Task<List<ReservationResponse>> GetReservatins(DateTime from, DateTime to); 13 public Task<List<ReservationResponse>> GetNewReservations(); 14 public Task AssignTable(int tableId, int reservationId); 13 15 } 14 16 public class ReservationService : IReservationService … … 21 23 _context = context; 22 24 _smsService = smsService; 25 } 26 27 public async Task AssignTable(int tableId, int reservationId) 28 { 29 var reservation = await _context.Reservations.FindAsync(reservationId); 30 reservation.Table = tableId; 31 _context.Update(reservation); 32 await _context.SaveChangesAsync(); 23 33 } 24 34 … … 50 60 } 51 61 62 public async Task<List<ReservationResponse>> GetNewReservations() 63 { 64 Restaurant res = await _context.Restoraunts 65 .Include(x => x.Reservations 66 .Where(x => x.ReservationStatus == ReservationStatus.New)) 67 .FirstOrDefaultAsync(); 68 var reservations = res.Reservations.Select(t => new ReservationResponse() 69 { 70 ContactName = t.ContactName, 71 ContactNumber = t.ContactNumber, 72 Persons = t.Persons, 73 StartDate = t.StartDate, 74 ReservationStatus = t.ReservationStatus, 75 Table = t.Table, 76 Id = t.Id, 77 ReservationPlace = t.ReservationPlace, 78 ReservationType = t.ReservationType 79 }).OrderByDescending(x => x.ReservationStatus == ReservationStatus.New).ToList(); 80 return reservations; 81 } 82 52 83 public async Task<List<ReservationResponse>> GetReservatins(DateTime from, DateTime to) 53 84 { … … 63 94 StartDate = t.StartDate, 64 95 ReservationStatus = t.ReservationStatus, 96 Table = t.Table, 65 97 Id = t.Id, 66 98 ReservationPlace = t.ReservationPlace,
Note:
See TracChangeset
for help on using the changeset viewer.