public ActionResult DeleteConfirmed(long id)
        {
            passenger passenger = db.passengers.Find(id);

            db.passengers.Remove(passenger);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "passengerId,passengerAge,PassengerCount,passengerUIN,Luguagge")] passenger passenger)
 {
     if (ModelState.IsValid)
     {
         db.Entry(passenger).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.passengerId = new SelectList(db.Registrations, "Id", "Id", passenger.passengerId);
     return(View(passenger));
 }
        public ActionResult Create([Bind(Include = "passengerId,passengerAge,PassengerCount,passengerUIN,Luguagge")] passenger passenger)
        {
            if (ModelState.IsValid)
            {
                db.passengers.Add(passenger);
                db.SaveChanges();
                return(RedirectToAction("Create", "Bookings"));
            }

            ViewBag.passengerId = new SelectList(db.Registrations, "Id", "Id", passenger.passengerId);
            return(View(passenger));
        }
        // GET: passengers1/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            passenger passenger = db.passengers.Find(id);

            if (passenger == null)
            {
                return(HttpNotFound());
            }
            return(View(passenger));
        }
        // GET: passengers1/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            passenger passenger = db.passengers.Find(id);

            if (passenger == null)
            {
                return(HttpNotFound());
            }
            ViewBag.passengerId = new SelectList(db.Registrations, "Id", "Id", passenger.passengerId);
            return(View(passenger));
        }
Ejemplo n.º 6
0
        private void btnBuy_Click(object sender, EventArgs e)
        {
            passenger passengerItem = new passenger();

            passengerItem.documentNumber = txtDocument.Text;
            passengerItem.email          = txtMail.Text;
            passengerItem.familyName     = txtSecondName.Text;
            passengerItem.givenName      = txtFirstName.Text;
            passengerItem.middleName     = txtMiddleName.Text;
            passengerItem.phone          = txtPhone.Text;

            long placeId = Convert.ToInt64(comboPlaces.SelectedValue);

            client.buyTicket(flight.id, placeId, passengerItem, txtAddInfo.Text);

            Close();
        }
Ejemplo n.º 7
0
        public JsonResult PassengerInsert(passenger p)
        {
            //p.passenger_id = (int)Session["username"];
            p.passenger_id = (int)Session["userId"];
            System.Diagnostics.Debug.WriteLine("passenger id is " + p.passenger_id);
            System.Diagnostics.Debug.WriteLine(p.GetType());
            SqlConnection sqlConnection1 = new SqlConnection(connectionString);
            SqlCommand    cmd            = new SqlCommand();

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

            string sqlPattern = "INSERT into passenger ([passport_number], [passenger_address], [passenger_postalCode], [passenger_Country]," +
                                "[passenger_phoneNumber],[passenger_emailAddress],[passenger_DOB],[passenger_gender],[passenger_name],[passport_expiry])" +
                                " VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}'); SELECT SCOPE_IDENTITY()";

            cmd.CommandText = String.Format(sqlPattern, p.passport_number, p.passenger_address, p.passenger_postalCode, p.passenger_Country,
                                            p.passenger_phoneNumber, p.passenger_emailAddress, p.passenger_DOB, p.passenger_gender, p.passenger_name, p.passenger_expiry);
            cmd.Connection = sqlConnection1;
            System.Diagnostics.Debug.WriteLine(cmd.CommandText);
            sqlConnection1.Open();
            try
            {
                //cmd.ExecuteNonQuery();
                //int id = (int)cmd.ExecuteScalar();
                //System.Diagnostics.Debug.WriteLine(cmd.ExecuteScalar());
                JsonResult a = Json(new { status = true, pass_id = cmd.ExecuteScalar() });

                sqlConnection1.Close();
                return(a);
            }
            catch (Exception e)
            {
                sqlConnection1.Close();
                System.Diagnostics.Debug.WriteLine(e.Message);
                return(Json(new { status = false }));
            }
        }
        public ActionResult cnfrm()
        {
            passenger p = new passenger();

            p.passnegerName = Convert.ToString(Session["name"]);
            dc.passengers.InsertOnSubmit(p);
            dc.SubmitChanges();
            Session["pid"] = p.passengerId;
            var id = Convert.ToString(Session["id"]);

            tStatus s = dc.tStatus.First(std => std.trainId == id);

            var    clss = Convert.ToString(Session["class"]);
            ticket t    = new ticket();

            if (clss == "businessSeats")
            {
                s.businessSeats -= 1;
                t.ticketClass    = "Business";
            }
            else
            {
                s.economySeats -= 1;
                t.ticketClass   = "Economy";
            }

            dc.SubmitChanges();

            t.trainId     = id;
            t.passengerId = p.passengerId;
            t.ticketPrice = (int)Session["price"];
            dc.tickets.InsertOnSubmit(t);
            dc.SubmitChanges();

            return(RedirectToAction("csst", t));
        }
        public ActionResult updated()
        {
            string source      = Request["source"];
            string destination = Request["destination"];
            string name        = Request["pname"];
            string clss        = Request["classs"];
            var    x           = dc.trains.FirstOrDefault(c => c.sourceCity == source && c.destinationCity == destination);

            if (x == null)
            {
                Session["error"] = "Sorry! No train is available at the moment for selected route.";
                return(RedirectToAction("error2"));
            }

            var sel = dc.tStatus.First(c => c.trainId == x.trainId);

            if (clss == "businessSeats")
            {
                if (sel.businessSeats <= 0)
                {
                    Session["error"] = "Sorry! No business class seat is available for the selected train.";
                    return(RedirectToAction("error2"));
                }
            }
            else
            {
                if (sel.economySeats <= 0)
                {
                    Session["error"] = "Sorry! No economy class seat is available for the selected train.";
                    return(RedirectToAction("error2"));
                }
            }
            string pid          = Convert.ToString(Session["pid"]);
            string source1      = Request["source"];
            string destination1 = Request["destination"];
            string name1        = Request["pname"];
            string clss1        = Request["classs"];
            var    price        = 0;
            var    p            = dc.tchecks.First(c => c.trainId == x.trainId);

            if (clss == "businessSeats")
            {
                price = p.bticket;
            }

            else
            {
                price = p.eticket;
            }
            ticket    s  = dc.tickets.First(std => std.passengerId == int.Parse(pid));
            passenger ss = dc.passengers.First(std => std.passengerId == int.Parse(pid));

            ss.passnegerName = name1;

            if (clss1 == "businessSeats")
            {
                s.ticketClass = "Business";
            }
            else
            {
                s.ticketClass = "Economy";
            }

            s.trainId     = x.trainId;
            s.ticketPrice = price;

            dc.SubmitChanges();
            Session["Error"] = "Ticket updated Successfully";
            return(RedirectToAction("error2"));
        }
Ejemplo n.º 10
0
        public DataTable PsngrDetails(passenger y)
        {
            DataTable      dt          = new DataTable();
            LogTraceWriter traceWriter = new LogTraceWriter();
            SqlConnection  conn        = new SqlConnection();
            StringBuilder  str         = new StringBuilder();

            try
            {
                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "PsngrDetails....");

                str.Append("Fname:" + y.Fname + ",");
                str.Append("Pnr_No:" + y.Pnr_No + ",");
                str.Append("Identityproof:" + y.Identityproof + ",");
                str.Append("Sex:" + y.Sex + ",");
                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "Input sent...." + str.ToString());

                conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["btposdb"].ToString();

                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "PSsp_InsPassengerDetails";

                cmd.Connection = conn;



                SqlParameter q = new SqlParameter("@Fname", SqlDbType.VarChar, 30);
                q.Value = y.Fname;
                cmd.Parameters.Add(q);

                SqlParameter q1 = new SqlParameter("@Lname", SqlDbType.VarChar, 30);
                q1.Value = y.Lname;
                cmd.Parameters.Add(q1);

                SqlParameter e = new SqlParameter("@Age", SqlDbType.Int);
                e.Value = y.Age;
                cmd.Parameters.Add(e);

                SqlParameter c = new SqlParameter("@Sex", SqlDbType.Int);
                c.Value = y.Sex;
                cmd.Parameters.Add(c);

                SqlParameter b = new SqlParameter("@datetime", SqlDbType.VarChar, 30);
                b.Value = y.datetime;
                cmd.Parameters.Add(b);

                SqlParameter p = new SqlParameter("@Pnr_Id", SqlDbType.Int);
                p.Value = y.Pnr_Id;
                cmd.Parameters.Add(p);

                SqlParameter m = new SqlParameter("@Pnr_No", SqlDbType.VarChar, 20);
                m.Value = y.Pnr_No;
                cmd.Parameters.Add(m);

                SqlParameter t = new SqlParameter("@Identityproof", SqlDbType.VarChar, 30);
                t.Value = y.Identityproof;
                cmd.Parameters.Add(t);

                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);
                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "PsngrDetails successful....");
            }
            catch (Exception ex)
            {
                traceWriter.Trace(Request, "0", TraceLevel.Error, "{0}", "PsngrDetails...." + ex.Message.ToString());
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
            }
            finally
            {
                conn.Close();
                conn.Dispose();
                SqlConnection.ClearPool(conn);
            }
            return(dt);

            //Verify Passwordotp
        }
Ejemplo n.º 11
0
        public IHttpActionResult PostTransaction(Transaction_n_Passenger trans_pass)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                Transaction transaction = new Transaction();

                credit_card card = new credit_card();
                var         user = db.User_Master.Where(x => x.email_id == trans_pass.email).FirstOrDefault();
                if (user == null)
                {
                    return(BadRequest("User does not Exists"));
                }

                transaction.flight_number   = trans_pass.flight_number;
                transaction.booking_date    = trans_pass.booking_date;
                transaction.number_of_seats = trans_pass.number_of_seats;
                transaction.seat_type       = trans_pass.seat_type;
                transaction.travel_date     = trans_pass.travel_date;
                transaction.amount          = trans_pass.amount;
                transaction.user_Id         = user.userid;
                db.Transactions.Add(transaction);
                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    return(BadRequest(ex.ToString()));
                }

                card        = trans_pass.carddetails;
                card.userid = user.userid;
                db.credit_card.Add(card);

                var last_trans = db.Transactions.ToList().Last();
                for (int i = 0; i < trans_pass.passengers.Length; i++)
                {
                    passenger Passenger_obj = new passenger();
                    Passenger_obj.transaction_id = last_trans.transaction_id;
                    Passenger_obj.email          = trans_pass.contact_email;
                    Passenger_obj.contact        = trans_pass.contact_no;
                    Passenger_obj.seatno         = trans_pass.seatarray[i];
                    Passenger_obj.Name           = trans_pass.passengers[i].firstname;
                    Passenger_obj.age            = trans_pass.passengers[i].age;
                    db.passengers.Add(Passenger_obj);
                }
                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    return(BadRequest(ex.ToString()));
                }

                return(CreatedAtRoute("DefaultApi", new { id = transaction.transaction_id }, transaction));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.ToString()));
            }
        }