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); }
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); }
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); }
public static List <Apartment> GetApartment() { XmlApartmentReader categoryReader = new XmlApartmentReader(ApartmentFile); return(categoryReader.GetApartments()); }
public static bool ApartmentExist(Apartment apartment) { XmlApartmentReader reader = new XmlApartmentReader(ApartmentFile); return(reader.Exist(apartment)); }