Changeset d76b7ee for resTools_backend/backend/Services
- Timestamp:
- 05/12/22 16:36:14 (3 years ago)
- Branches:
- master
- Children:
- cc4db18
- Parents:
- 7a983b0
- Location:
- resTools_backend/backend/Services
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
resTools_backend/backend/Services/ReservationService.cs
r7a983b0 rd76b7ee 10 10 public Task CreateReservation(CreateReservationRequest req); 11 11 public Task ChangeReservationStatus(int resId, ReservationStatus status); 12 public Task<List<ReservationResponse>> GetReservatins(DateTime from, DateTime to); 12 13 } 13 14 public class ReservationService : IReservationService … … 48 49 await _context.SaveChangesAsync(); 49 50 } 51 52 public async Task<List<ReservationResponse>> GetReservatins(DateTime from, DateTime to) 53 { 54 Restaurant res = await _context.Restoraunts 55 .Include(x => x.Reservations 56 .Where(x => x.StartDate.CompareTo(from)>0 && x.StartDate.CompareTo(to)<=0)) 57 .FirstOrDefaultAsync(); 58 var reservations = res.Reservations.Select(t => new ReservationResponse() 59 { 60 ContactName = t.ContactName, 61 ContactNumber = t.ContactNumber, 62 Persons = t.Persons, 63 StartDate = t.StartDate, 64 ReservationStatus = t.ReservationStatus, 65 Id = t.Id, 66 ReservationPlace = t.ReservationPlace, 67 ReservationType = t.ReservationType 68 }).OrderByDescending(x => x.ReservationStatus == ReservationStatus.New).ToList(); 69 return reservations; 70 } 50 71 } 51 72 } -
resTools_backend/backend/Services/RestaurantService.cs
r7a983b0 rd76b7ee 30 30 { 31 31 RestaurantResponse res = await _context.Restoraunts 32 .Include(x => x.Reservations)33 32 .Select(x => new RestaurantResponse() 34 33 { … … 36 35 Name = x.Name, 37 36 OwnerId = x.OwnerFk, 38 Reservations = x.Reservations.Select(t => new ReservationResponse()39 {40 ContactName = t.ContactName,41 ContactNumber = t.ContactNumber,42 Persons = t.Persons,43 StartDate = t.StartDate,44 ReservationStatus = t.ReservationStatus,45 Id = t.Id,46 ReservationPlace = t.ReservationPlace,47 ReservationType = t.ReservationType48 }).ToList()49 37 }) 50 38 .FirstOrDefaultAsync();
Note:
See TracChangeset
for help on using the changeset viewer.