Ignore:
Timestamp:
07/06/22 13:13:35 (2 years ago)
Author:
Danilo <danilo.najkov@…>
Branches:
master
Children:
899b19d
Parents:
d76b7ee
Message:

reservation module changes + contact module + menu module

File:
1 edited

Legend:

Unmodified
Added
Removed
  • resTools_backend/backend/Services/ReservationService.cs

    rd76b7ee rcc4db18  
    1111        public Task ChangeReservationStatus(int resId, ReservationStatus status);
    1212        public Task<List<ReservationResponse>> GetReservatins(DateTime from, DateTime to);
     13        public Task<List<ReservationResponse>> GetNewReservations();
     14        public Task AssignTable(int tableId, int reservationId);
    1315    }
    1416    public class ReservationService : IReservationService
     
    2123            _context = context;
    2224            _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();
    2333        }
    2434
     
    5060        }
    5161
     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
    5283        public async Task<List<ReservationResponse>> GetReservatins(DateTime from, DateTime to)
    5384        {
     
    6394                StartDate = t.StartDate,
    6495                ReservationStatus = t.ReservationStatus,
     96                Table = t.Table,
    6597                Id = t.Id,
    6698                ReservationPlace = t.ReservationPlace,
Note: See TracChangeset for help on using the changeset viewer.