Пример #1
0
 public RoomsController(HotelDbContext context)
 {
     _context                   = context;
     _repo                      = new RoomCRUDRepository(_context);
     _reservationRepo           = new ReservationCRUDRepository(_context);
     _roomIndexViewModels.Items = _repo.GetAll().Select(x => new RoomViewModel()
     {
         Id = x.Id,
         BedPriceForAdult = x.BedPriceForAdult,
         BedPriceForKid   = x.BedPriceForKid,
         Capacity         = x.Capacity,
         IsFree           = x.IsFree,
         Number           = x.Number,
         Type             = x.Type,
         ReservationId    = x.ReservationId,
     });
 }
 public ReservationsController(HotelDbContext context)
 {
     _context                   = context;
     _reservationRepo           = new ReservationCRUDRepository(_context);
     _roomRepo                  = new RoomCRUDRepository(_context);
     _roomIndexViewModels.Items = _roomRepo.GetAll().Select(x => new RoomViewModel()
     {
         Id = x.Id,
         BedPriceForAdult = x.BedPriceForAdult,
         BedPriceForKid   = x.BedPriceForKid,
         Capacity         = x.Capacity,
         IsFree           = x.IsFree,
         Number           = x.Number,
         Type             = x.Type,
         ReservationId    = x.ReservationId
     });
     _reservationIndexViewModels.Items = _reservationRepo.GetAll().Select(x => new ReservationViewModel()
     {
         Id = x.Id,
         AccommodationDate = x.AccommodationDate,
         LeaveDate         = x.LeaveDate,
         AllInclusive      = x.AllInclusive,
         BreakfastIncluded = x.AllInclusive,
         Cost              = x.Cost,
         UserId            = x.UserId,
         RoomViewModel     = _roomIndexViewModels.Items.FirstOrDefault(r => r.Id == x.RoomId),
         ClientsViewModels = (IQueryable <ClientViewModel>)x.Clients.Select(c => new ClientViewModel()
         {
             Id            = c.Id,
             Email         = c.Email,
             FirstName     = c.FirstName,
             IsAdult       = c.IsAdult,
             LastName      = c.LastName,
             PhoneNumber   = c.PhoneNumber,
             ReservationId = c.ReservationId
         })
     });
 }