public ActionResult Edit([Bind(Exclude = "seller_id", Include = "property_id,property_type,property_name,property_address,property_state,property_city,property_pin,bhk,floor,total_floor,bathroom,bedroom,property_age,facing,property_size,lease,expected_rent,expected_deposit,preferred_tenants,furnishing,parking,description,property_status,balcony,water_supply,gated_security,available_date")] property property,
                                 HttpPostedFileBase[] property_image)
        {
            try {
                if (ModelState.IsValid)
                {
                    int id = (int)Session["seller_id"];
                    property.seller_id         = id;
                    property.property_type     = property.property_type.ToLower();
                    property.property_name     = property.property_name.ToLower();
                    property.property_address  = property.property_address.ToLower();
                    property.property_state    = property.property_state.ToLower();
                    property.property_city     = property.property_city.ToLower();
                    property.facing            = property.facing.ToLower();
                    property.lease             = property.lease.ToLower();
                    property.preferred_tenants = property.preferred_tenants.ToLower();
                    property.furnishing        = property.furnishing.ToLower();
                    property.parking           = property.parking.ToLower();
                    var datetime = DateTime.Today.ToString("G");
                    property.post_date       = DateTime.Parse(datetime);
                    property.property_status = "available";
                    property.gated_security  = property.gated_security.ToLower();
                    property.water_supply    = property.water_supply.ToLower();

                    db.Entry(property).State = EntityState.Modified;
                    db.SaveChanges();
                    if (property_image.Length > 0)
                    {
                        foreach (var image in property_image)
                        {
                            if (image != null && image.ContentLength > 0)
                            {
                                BinaryReader    binaryReader    = new BinaryReader(image.InputStream);
                                property_images property_Images = new property_images
                                {
                                    property_id      = property.property_id,
                                    property_images1 = binaryReader.ReadBytes(image.ContentLength)
                                };
                                db.Entry(property_Images).State = EntityState.Added;
                            }
                        }
                    }
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception)
            {
                //return Content(e.Message);
                return(RedirectToAction("Index", "Home"));
            }
            ViewBag.seller_id = new SelectList(db.sellers, "seller_id", "seller_name", property.seller_id);
            return(View(property));
        }
        public ActionResult Create([Bind(Include = "property_id,property_type,property_name,property_address,property_state,property_city,property_pin,bhk,floor,total_floor,bathroom,bedroom,property_age,facing,property_size,lease,expected_rent,expected_deposit,preferred_tenants,furnishing,parking,description,property_status,post_date,balcony,gated_security,water_supply,available_date")] property property,
                                   HttpPostedFileBase[] property_image)
        {
            try
            {
                int id = (int)Session["seller_id"];
                property.seller_id         = id;
                property.property_type     = property.property_type.ToLower();
                property.property_name     = property.property_name.ToLower();
                property.property_address  = property.property_address.ToLower();
                property.property_state    = property.property_state.ToLower();
                property.property_city     = property.property_city.ToLower();
                property.facing            = property.facing.ToLower();
                property.lease             = property.lease.ToLower();
                property.preferred_tenants = property.preferred_tenants.ToLower();
                property.furnishing        = property.furnishing.ToLower();
                property.parking           = property.parking.ToLower();
                var datetime = DateTime.Now.ToString("dd/MM/yyyy");
                property.post_date       = DateTime.Parse(datetime);
                property.property_status = "available";
                property.gated_security  = property.gated_security.ToLower();
                property.water_supply    = property.water_supply.ToLower();

                db.properties.Add(property);
                db.SaveChanges();
                var lastproperty_id = db.properties.OrderByDescending(pid => pid.property_id).FirstOrDefault(pid => pid.seller_id == id);
                int lastpid         = lastproperty_id.property_id;
                if (property_image.GetValue(0) != null)
                {
                    foreach (var item in property_image)
                    {
                        BinaryReader    binaryReader    = new BinaryReader(item.InputStream);
                        property_images property_Images = new property_images
                        {
                            property_id      = lastpid,
                            property_images1 = binaryReader.ReadBytes((int)item.ContentLength)
                        };
                        db.property_images.Add(property_Images);
                    }
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                // return Content(e.Message);
                return(RedirectToAction("Index", "Home"));
            }
        }
 public ActionResult DeleteImage(int id, int propertyid)
 {
     try
     {
         int             sid             = (int)Session["seller_id"];
         property_images property_Images = db.property_images.Find(id);
         db.property_images.Remove(property_Images);
         db.SaveChanges();
         return(RedirectToAction("Edit", "Prop", new { id = propertyid }));
     }
     catch (Exception)
     {
         return(RedirectToAction("Index", "Home"));
     }
 }