public ApartmentPhoto mainPhoto(DisplayDevice preferredDevice = DisplayDevice.ANY) { ApartmentPhoto theMainPhoto; if (this.ApartmentPhotoes.Count() == 0) { theMainPhoto = new ApartmentPhoto() { FilePath = "/images/missing landscape photo.jpg", Orientation = (short)OrientationType.Landscape, Type = (short)PhotoType.Main }; } else if (preferredDevice == DisplayDevice.ANY) { //Find any main photo, regardless of device theMainPhoto = this.ApartmentPhotoes.FirstOrDefault(aPhoto => aPhoto.Type == (short)PhotoType.Main); } else { //Find main photo for the preferred device if (preferredDevice == DisplayDevice.DESKTOP) { theMainPhoto = this.ApartmentPhotoes.FirstOrDefault(aPhoto => aPhoto.Type == (short)PhotoType.Main && aPhoto.ForDesktop == true); } else { //Find preferred main photo for mobile theMainPhoto = this.ApartmentPhotoes.FirstOrDefault(aPhoto => aPhoto.Type == (short)PhotoType.Main && aPhoto.ForMobile == true); } } return(theMainPhoto); }
/// <summary> /// Calculates the exact price to be paid for the stay in the apartment. It takes into account: /// number of adults, children, start date, end date, weekdays/weekends and discounts. /// OBSOLETE??? /// </summary> /// <param name="thePricing">the pricing record by which to claculate the price (based on number of adults and children)</param> /// <param name="currencyCode">currency by which to show the price</param> /// <param name="fromDate">date of entrance</param> /// <param name="toDate">date of exit</param> /// <returns></returns> //public int pricePerStay(Pricing thePricing, string currencyCode, DateTime fromDate, DateTime toDate) //{ // return 0;//TBD //} /// <summary> /// The method returns the main landscape photo of the apartment, if such exists, and null if none. If more than one photo is tagged /// as "main"and "landscape" - return the first one /// </summary> /// <returns>apartment main photo or null if nont exists</returns> public ApartmentPhoto MainPhotoLandscape() { ApartmentPhoto theMainPhoto; if (this.ApartmentPhotoes.Count() == 0) { theMainPhoto = new ApartmentPhoto() { FilePath = "/images/missing landscape photo.png", Orientation = (short)OrientationType.Landscape, Type = (short)PhotoType.Main }; } else { theMainPhoto = this.ApartmentPhotoes.FirstOrDefault(aPhoto => aPhoto.Type == (short)PhotoType.Main && aPhoto.Orientation == (short)OrientationType.Landscape); } return(theMainPhoto); }
/// <summary> /// The method returns the main portrait photo of the apartment, if such exists, and null if none. If more than one photo is tagged /// as "main" and "portrait" - return the first one /// </summary> /// <returns>apartment main photo or null if nont exists</returns> public ApartmentPhoto MainPhotoPortrait() { ApartmentPhoto theMainPhoto; if (this.ApartmentPhotoes.Count() == 0) { theMainPhoto = new ApartmentPhoto() { FilePath = "/images/missing portrait photo.jpg", Orientation = (short)OrientationType.Portrait, Type = (short)PhotoType.Main }; //theMainPhoto = this.ApartmentPhotoes.Single(aPhoto => aPhoto.filePath == "/images/missing portrait photo.jpg"); ; } else { citylifedb8_blContext db = new citylifedb8_blContext(); theMainPhoto = db.ApartmentPhoto.FirstOrDefault(aPhoto => aPhoto.Type == (short)PhotoType.Main && aPhoto.Orientation == (short)OrientationType.Portrait); } return(theMainPhoto); }