public ActionResult RequestCancel(int?si_no)
        {
            booking_details booking_details = db.booking_details.Find(si_no);

            db.booking_details.Remove(booking_details);
            var prop_name     = db.properties.FirstOrDefault(s => s.property_id == booking_details.property_id);
            var seller        = db.sellers.FirstOrDefault(s => s.seller_id == prop_name.seller_id);
            var customer_name = db.customers.FirstOrDefault(s => s.customer_id == booking_details.customer_id);
            customers_status customers_Status = db.customers_status.FirstOrDefault(s => s.customer_id == booking_details.customer_id && s.property_id == prop_name.property_id);

            if (customers_Status != null)
            {
                customers_Status.message         = customer_name.customer_name + " Cancelled the Booking for the property " + prop_name.property_name;
                db.Entry(customers_Status).State = EntityState.Modified;
                db.SaveChanges();
            }
            else
            {
                customers_status customers_Status1 = new customers_status()
                {
                    customer_id = booking_details.customer_id,
                    seller_id   = seller.seller_id,
                    message     = customer_name.customer_name + " Cancelled the Booking for the property " + prop_name.property_name,
                    property_id = prop_name.property_id
                };
                db.customers_status.Add(customers_Status1);
                db.SaveChanges();
            }
            DeletionOfCancelledBookings(booking_details.property_id);
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            try
            {
                if (Session["user_role"] != null)
                {
                    booking_details booking_details = db.booking_details.Find(id);

                    //Deletion of all cutomer req action in booking details
                    var customer_actions = db.booking_details.Where(s => s.customer_id == booking_details.customer_id && s.property_id == booking_details.property_id);
                    db.booking_details.RemoveRange(customer_actions);

                    var prop_name     = db.properties.FirstOrDefault(s => s.property_id == booking_details.property_id);
                    var seller        = db.sellers.FirstOrDefault(s => s.seller_id == prop_name.seller_id);
                    var customer_name = db.customers.FirstOrDefault(s => s.customer_id == booking_details.customer_id);
                    customers_status customers_Status = db.customers_status.FirstOrDefault(s => s.customer_id == booking_details.customer_id && s.property_id == prop_name.property_id);
                    if (customers_Status != null)
                    {
                        customers_Status.message         = customer_name.customer_name + " Cancelled the request for the property " + prop_name.property_name;
                        db.Entry(customers_Status).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    else
                    {
                        customers_status customers_Status1 = new customers_status()
                        {
                            customer_id = booking_details.customer_id,
                            seller_id   = seller.seller_id,
                            property_id = prop_name.property_id,
                            message     = customer_name.customer_name + " Cancelled the request for the property " + prop_name.property_name
                        };
                        db.customers_status.Add(customers_Status1);
                        db.SaveChanges();
                    }

                    //Email the status to seller or Email the status to customer
                    //Also have the table to pass msg to seller [Booking canceled by the customer..]

                    return(RedirectToAction("Index"));
                }
                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception)
            {
                // return Content(e.Message);
                return(RedirectToAction("Index", "Home"));
            }
        }
        public ActionResult Create([Bind(Include = "property_id")] booking_details booking_details)
        {
            if (ModelState.IsValid)
            {
                int id = (int)Session["customer_id"];
                booking_details.customer_id    = id;
                booking_details.booking_status = "requested";
                var cbd = db.booking_details.Count(cus => cus.property_id == booking_details.property_id && cus.customer_id == booking_details.customer_id && (cus.booking_status != null));
                if (cbd == 0)
                {
                    var datetime = DateTime.Today.ToString("G");
                    booking_details.book_date = DateTime.Parse(datetime);
                    db.booking_details.Add(booking_details);
                    db.SaveChanges();
                    var customer_set  = db.customers.FirstOrDefault(item => item.customer_id == booking_details.customer_id);
                    var customer_name = customer_set.customer_name;
                    var prop_set      = db.properties.FirstOrDefault(item => item.property_id == booking_details.property_id);
                    var prop_name     = prop_set.property_name;
                    customers_status customers_Status = new customers_status()
                    {
                        customer_id = booking_details.customer_id,
                        message     = customer_name + " requested for the property " + prop_name,
                        seller_id   = prop_set.seller_id,
                        property_id = prop_set.property_id
                    };
                    db.customers_status.Add(customers_Status);
                    db.SaveChanges();
                    TempData["request"] = "true";
                }
                else
                {
                    TempData["request"] = "false";
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.customer_id = new SelectList(db.customers, "customer_id", "customer_name", booking_details.customer_id);
            ViewBag.property_id = new SelectList(db.properties, "property_id", "property_type", booking_details.property_id);
            return(View(booking_details));

            /*}
             * catch(Exception)
             * {
             *  return RedirectToAction("Index", "Home");
             * }
             */
        }