Пример #1
0
        public static uint EmptyApartmentCountForDate(DateTime from, DateTime till)
        {
            XmlApartmentReader reader = new XmlApartmentReader(ApartmentFile);
            var apartmentsBooking     = GetApartmentsBooking();

            uint emptyApartmentCount = 0;

            foreach (var apartmentBookingResponse in apartmentsBooking)
            {
                if (apartmentBookingResponse.Apartment.Booked == false)
                {
                    emptyApartmentCount++;
                }
                else if (apartmentBookingResponse.Booking.From > till)
                {
                    emptyApartmentCount++;
                }
                else if (apartmentBookingResponse.Booking.Till < from)
                {
                    emptyApartmentCount++;
                }
            }

            return(emptyApartmentCount);
        }
Пример #2
0
        public static List <ApartmentBookingResponse> GetApartmentsBooking()
        {
            var apartments = new XmlApartmentReader(ApartmentFile).GetApartments();
            var bookings   = new XmlBookingReader(BookingFile).GetBookings();

            var apartmentBookings = (from apartment in apartments
                                     join booking in bookings on apartment.Id equals booking.ApartmentId
                                     into joinBookings
                                     from jBooking in joinBookings.DefaultIfEmpty()
                                     select new ApartmentBookingResponse(apartment, jBooking)).ToList();

            return(apartmentBookings);
        }
Пример #3
0
        public static bool ApartmentBooked(Apartment apartment)
        {
            XmlApartmentReader reader        = new XmlApartmentReader(ApartmentFile);
            XmlNode            apartmentNode = reader.FindNode(apartment);

            XDocument xDoc   = XDocument.Load(ApartmentFile);
            bool      booked = bool.Parse(xDoc
                                          .Element("Apartments")
                                          .Elements("Apartment")
                                          .Single(XElement => XElement.Element("Id").Value == apartment.Id.ToString())
                                          .Element("Booked").Value);

            return(booked);
        }
Пример #4
0
        public static List <Apartment> GetApartment()
        {
            XmlApartmentReader categoryReader = new XmlApartmentReader(ApartmentFile);

            return(categoryReader.GetApartments());
        }
Пример #5
0
        public static bool ApartmentExist(Apartment apartment)
        {
            XmlApartmentReader reader = new XmlApartmentReader(ApartmentFile);

            return(reader.Exist(apartment));
        }