Exemple #1
0
        public ActionResult PaymentConfirmation(booking_details bd)
        {
            // Reference : https://docs.microsoft.com/en-us/visualstudio/data-tools/insert-new-records-into-a-database?view=vs-2019
            //connetionString = "data source = DESKTOP - 5TD9BOD; initial catalog = FlightBookingApp; integrated security = True; MultipleActiveResultSets = True; App = EntityFramework";

            //System.Data.SqlClient.SqlConnection sqlConnection1 = new System.Data.SqlClient.SqlConnection(connetionString);
            SqlConnection sqlConnection1 = new SqlConnection(connectionString);
            SqlCommand    cmd            = new SqlCommand();

            cmd.CommandType = System.Data.CommandType.Text;

            string sqlPattern = "INSERT into booking_details (customer_id, flight_id, payment, qty, status, passenger_id) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}'); SELECT SCOPE_IDENTITY()";

            cmd.CommandText = String.Format(sqlPattern, (int)Session["userId"], Session["flight_id"], bd.payment, bd.qty, "SUCCESS", bd.passenger_id);
            cmd.Connection  = sqlConnection1;
            System.Diagnostics.Debug.WriteLine(cmd.CommandText);
            sqlConnection1.Open();
            int a = cmd.ExecuteNonQuery();

            if (a > 0)
            {
                sqlConnection1.Close();
                return(Json(new { status = true }));
            }
            else
            {
                return(Json(new { status = false }));
            }
        }
 // GET: bookings/Details/5
 public ActionResult Details(int?id)
 {
     try
     {
         if (Session["user_role"] != null)
         {
             if (id == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             booking_details booking_details = db.booking_details.Find(id);
             if ((string)Session["user_role"] == "customer")
             {
                 if (booking_details != null)
                 {
                     // property props = db.properties.Find(booking_details.property_id);
                     return(View("BookedDetails", booking_details));
                 }
             }
             if (booking_details == null)
             {
                 return(HttpNotFound());
             }
             return(View(booking_details));
         }
         return(RedirectToAction("Index", "Home"));
     }
     catch (Exception)
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
        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 Book(int?si_no)
 {
     try
     {
         if (Session["user_role"] != null)
         {
             if (si_no == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             booking_details booking_details = db.booking_details.Find(si_no);
             if (booking_details == null)
             {
                 return(HttpNotFound());
             }
             if (booking_details.booking_status != "rejected")
             {
                 return(View(booking_details));
             }
             return(RedirectToAction("Index", "Bookings", new { property_id = booking_details.property_id }));
         }
         return(RedirectToAction("Index", "Home"));
     }
     catch (Exception)
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
 // GET: bookings/Edit/5
 public ActionResult Edit(int?id)
 {
     try
     {
         if (Session["user_role"] != null)
         {
             if (id == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             booking_details booking_details = db.booking_details.Find(id);
             if (booking_details == null)
             {
                 return(HttpNotFound());
             }
             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));
         }
         return(RedirectToAction("Index", "Home"));
     }
     catch (Exception)
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Exemple #6
0
        public ActionResult PassengerBook(booking_details booking_Details, string selectedFlight)
        {
            if (Request.IsAuthenticated)
            {
                string selec = selectedFlight.ToString();

                var selectedFlights = db.FlightSearchs.Where(x => x.FlightNo.Equals(selectedFlight)).FirstOrDefault();
                TempData["Flights"] = "Your flight from " + selectedFlights.From_City + " to " + selectedFlights.To_City;

                var passengerDetails = db.PassngerDetails.Where(x => x.UsersId.Equals(CurrentUser.Id)).Select(c => c.UsersId).FirstOrDefault();

                var passDetails = db.Users.Find(passengerDetails);

                var model = new UserViewModel
                {
                    FirstName = passDetails.FirstName,
                    LastName  = passDetails.LastName,
                    Phone     = passDetails.Phone,
                    Address   = passDetails.Address,
                    Email     = passDetails.Email,
                };

                return(View(model));
            }

            return(RedirectToAction("Login", "Account"));
        }
Exemple #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            booking_details booking_details = db.Booking_Details.Find(id);

            db.Booking_Details.Remove(booking_details);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: bookings/AD/5
        public ActionResult AD(int si_no = 0, int op = 0)
        {
            if (Session["seller_id"] != null)
            {
                booking_details booking_Details = db.booking_details.Find(si_no);
                int             flag            = 0;
                // var actions = "";
                if (op == 1 && booking_Details.booking_status != "accepted")
                {
                    booking_Details.booking_status = "accepted";
                    flag = 1;
                    // actions = "accepted";
                }
                else if (op == 0 && booking_Details.booking_status != "rejected")
                {
                    booking_Details.booking_status = "rejected";
                    flag = 1;
                    //actions = "rejected";
                }
                if (flag == 1)
                {
                    db.Entry(booking_Details).State = EntityState.Modified;

                    /*
                     *  var prop_name = db.properties.FirstOrDefault(s => s.property_id == booking_Details.property_id);
                     *  sellers_status sellers_Status = db.sellers_status.FirstOrDefault(s => s.customer_id == booking_Details.customer_id && s.property_id == booking_Details.property_id);
                     *  if(sellers_Status!=null)
                     *  {
                     *      sellers_Status.message = "Seller " + actions + " request for the property " + prop_name.property_name;
                     *      db.Entry(sellers_Status).State = EntityState.Modified;
                     *  }
                     *  else
                     *  {
                     *      sellers_status sellers_Status1 = new sellers_status()
                     *      {
                     *          customer_id = booking_Details.customer_id,
                     *          message = "Seller " + actions + " request for the property " + prop_name.property_name,
                     *          property_id = booking_Details.property_id
                     *      };
                     *      db.sellers_status.Add(sellers_Status1);
                     *  }
                     */
                    db.SaveChanges();
                    //Email the status to customer
                    var    cus_email  = db.customers.Find(booking_Details.customer_id);
                    var    property   = db.properties.Find(booking_Details.property_id);
                    string email_body = "Your request for the property \" " + CultureInfo.CurrentCulture.TextInfo.ToTitleCase(property.property_name) + " \" was " + booking_Details.booking_status + " by the seller.\n" +
                                        "For more information Contact seller :- \n Seller Name : " + CultureInfo.CurrentCulture.TextInfo.ToTitleCase(property.seller.seller_name) + " \n Contact No : " + property.seller.seller_phone;
                    string sendemail = ConfigurationManager.AppSettings["SendEmail"];
                    if (sendemail.ToLower() == "true")
                    {
                        SendEmail.Send(cus_email.customer_email, email_body);
                    }
                }
                return(RedirectToAction("Index", "Bookings", new { booking_Details.property_id }));
            }
            return(RedirectToAction("Index", "Home"));
        }
Exemple #9
0
 public ActionResult Edit([Bind(Include = "Id,UsersId,flight_SearchId,booking_Child,booking_Adults,booking_total,booking_status,Card_DetailsID")] booking_details booking_details)
 {
     if (ModelState.IsValid)
     {
         db.Entry(booking_details).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Card_DetailsID  = new SelectList(db.CardDetails, "Id", "CardName", booking_details.Card_DetailsID);
     ViewBag.flight_SearchId = new SelectList(db.FlightSearchs, "Id", "FlightNo", booking_details.flight_SearchId);
     return(View(booking_details));
 }
Exemple #10
0
        // GET: booking_details/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            booking_details booking_details = db.Booking_Details.Find(id);

            if (booking_details == null)
            {
                return(HttpNotFound());
            }
            return(View(booking_details));
        }
        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"));
            }
        }
Exemple #12
0
        // GET: booking_details/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            booking_details booking_details = db.Booking_Details.Find(id);

            if (booking_details == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Card_DetailsID  = new SelectList(db.CardDetails, "Id", "CardName", booking_details.Card_DetailsID);
            ViewBag.flight_SearchId = new SelectList(db.FlightSearchs, "Id", "FlightNo", booking_details.flight_SearchId);
            return(View(booking_details));
        }
        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");
             * }
             */
        }
 public ActionResult DeleteBooking(int?si_no)
 {
     try
     {
         if (Session["user_role"] != null)
         {
             if (si_no == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             booking_details booking_details = db.booking_details.Find(si_no);
             if (booking_details == null)
             {
                 return(HttpNotFound());
             }
             return(View(booking_details));
         }
         return(RedirectToAction("Index", "Home"));
     }
     catch (Exception)
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
 public ActionResult Edit([Bind(Include = "si_no,property_id,customer_id,booking_status,book_date")] booking_details booking_details)
 {
     try
     {
         if (Session["user_role"] != null)
         {
             if (ModelState.IsValid)
             {
                 booking_details.booking_status  = booking_details.booking_status.ToLower();
                 db.Entry(booking_details).State = EntityState.Modified;
                 db.SaveChanges();
                 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));
         }
         return(RedirectToAction("Index", "Home"));
     }
     catch (Exception)
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Exemple #16
0
        public ActionResult FlightDetails(flight_search search, booking_details booking_Details, string chk)
        {
            if (chk == "one way" || chk == null)
            {
                var Specificflights = db.FlightSearchs.Where(x => x.From_City.Equals(search.From_City) && x.To_City.Equals(search.To_City)).ToList();
                TempData["info"] = Specificflights;
                TempData["City"] = " from " + search.From_City + " to " + search.To_City;

                var flights = db.FlightSearchs.Where(x => x.From_City.Equals(search.From_City)).ToList();
                TempData["flights"] = flights;
            }
            else if (chk == "round trip")
            {
                var Specificflights = db.FlightSearchs.Where(x => x.From_City.Equals(search.From_City) && x.To_City.Equals(search.To_City)).ToList();
                TempData["info"] = Specificflights;
                TempData["City"] = " from " + search.From_City + " to " + search.To_City;

                var flights = db.FlightSearchs.Where(x => x.From_City.Equals(search.From_City)).ToList();
                TempData["flights"] = flights;
                var returnFlights = db.FlightSearchs.Where(x => x.From_City.Equals(search.To_City) && x.To_City.Equals(search.From_City)).FirstOrDefault();
            }

            return(RedirectToAction("Index", "Home"));
        }