Пример #1
0
 public Booking(decimal price, RealEstate realEstate, DateTime startDate, DateTime endDate)
 {
     EndDate = endDate;
     StartDate = startDate;
     RealEstate = realEstate;
     Price = price;
 }
        public ActionResult AddRealEstate(RealEstate re, HttpPostedFileBase mainPhoto, IEnumerable<HttpPostedFileBase> thumbnails)
        {
            if(!ModelState.IsValid)
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

            string rEstateImageDir = Path.Combine(Server.MapPath("~/images"), re.Name);
            string partialPhotoUri = Path.Combine("http://", HostingEnvironment.SiteName, "images", re.Name);

            if (mainPhoto != null)
            {
                Directory.CreateDirectory(rEstateImageDir);
                mainPhoto.SaveAs(Path.Combine(rEstateImageDir, mainPhoto.FileName));
                re.PhotoCollection.MainPhoto = Path.Combine(partialPhotoUri, mainPhoto.FileName);
            }
            if (thumbnails != null)
            {
                string thumbnailsDir = Path.Combine(rEstateImageDir, "Thumbnails");
                Directory.CreateDirectory(thumbnailsDir);

                partialPhotoUri = Path.Combine(partialPhotoUri, "Thumbnails");
                foreach(var photo in thumbnails) {
                    if (photo != null)
                    {
                        photo.SaveAs(Path.Combine(thumbnailsDir, photo.FileName));
                        re.PhotoCollection.Thumbnails.Add(Path.Combine(partialPhotoUri, photo.FileName));
                    }

                }
            }

            rel.AddRealEstate(re);
            return RedirectToAction("Detailed", "RealEstate", new { id = re.Id });
        }
 public DetailedRealEstate(RealEstate realEstate, IEnumerable<BookingDates> dates)
 {
     RealEstate = realEstate;
     BookingDates = dates;
 }
 public void Update(RealEstate obj)
 {
     throw new NotImplementedException();
 }
 public void Add(RealEstate objToAdd)
 {
     objToAdd.Id = _id++;
     RealEstates.Add(objToAdd);
 }
 public void AddRealEstate(RealEstate re)
 {
     realEstateDal.Add(re);
 }