Ejemplo n.º 1
0
        public ActionResult ProfileOfTraveller(string searchBy, string search)
        {
            if (getSessionId() == 0)
            {
                return(Content("<script language='javascript' type='text/javascript'>alert('u Must Login !!');</script>"));
            }
            else
            {
                db.ConnsectionString();
                String sql = "SELECT * FROM [dbo].[tripposts] WHERE active LIKE '" + 1 + "'";
                if (searchBy == "agencyname")
                {
                    sql = "SELECT * FROM [dbo].[tripposts] WHERE [agencyname] LIKE'%" + search + "%' AND active LIKE '" + 1 + "'";
                }
                else if (searchBy == "tripdestination")
                {
                    sql = "SELECT * FROM [dbo].[tripposts] WHERE [tripdestination] LIKE'%" + search + "%' AND active LIKE '" + 1 + "'";
                }
                else if (searchBy == "tripdate")
                {
                    sql = "SELECT * FROM [dbo].[tripposts] WHERE [tripdate] LIKE'%" + search + "%' AND active LIKE '" + 1 + "'";
                }
                SqlCommand cmd = new SqlCommand(sql, db.sqlConnection);

                SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(cmd);
                DataSet        ds             = new DataSet();
                sqlDataAdapter.Fill(ds);

                var model = new List <tripposts>();
                model2 = model;

                db.sqlConnection.Open();
                foreach (DataRow rdr in ds.Tables[0].Rows)
                {
                    var post = new tripposts();

                    post.id              = (int)rdr["id"];
                    post.agencyname      = (string)rdr["agencyname"];
                    post.triptitle       = (string)rdr["triptitle"];
                    post.tripdesctiption = (string)rdr["tripdesctiption"];
                    post.tripdate        = (string)rdr["tripdate"];
                    post.tripdestination = (string)rdr["tripdestination"];
                    post.tripimage       = (string)rdr["tripimage"];


                    model.Add(post);
                }

                ModelState.Clear();
                db.sqlConnection.Close();

                return(View(model));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Login(string searchBy, string search)
        {
            db.ConnsectionString();
            String sql = "SELECT * FROM [dbo].[tripposts] WHERE active LIKE '" + 1 + "'";

            if (searchBy == "agencyname")
            {
                sql = "SELECT * FROM [dbo].[tripposts] WHERE [agencyname] LIKE'%" + search + "%' AND active LIKE '" + 1 + "'";
            }
            else if (searchBy == "tripdestination")
            {
                sql = "SELECT * FROM [dbo].[tripposts] WHERE [tripdestination] LIKE'%" + search + "%' AND active LIKE '" + 1 + "'";
            }
            else if (searchBy == "tripdate")
            {
                sql = "SELECT * FROM [dbo].[tripposts] WHERE [tripdate] LIKE'%" + search + "%' AND active LIKE '" + 1 + "'";
            }
            SqlCommand cmd = new SqlCommand(sql, db.sqlConnection);

            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(cmd);
            DataSet        ds             = new DataSet();

            sqlDataAdapter.Fill(ds);

            var model = new List <tripposts>();

            db.sqlConnection.Open();
            foreach (DataRow rdr in ds.Tables[0].Rows)
            {
                var post = new tripposts();

                post.id              = (int)rdr["id"];
                post.agencyname      = (string)rdr["agencyname"];
                post.triptitle       = (string)rdr["triptitle"];
                post.tripdesctiption = (string)rdr["tripdesctiption"];
                post.tripdate        = (string)rdr["tripdate"];
                post.tripdestination = (string)rdr["tripdestination"];
                post.tripimage       = (string)rdr["tripimage"];

                db.sqlConnection.Close();

                post.numOflikes    = getlikes(post.id);
                post.numOfdislikes = getdislikes(post.id);


                model.Add(post);
            }

            ModelState.Clear();
            db.sqlConnection.Close();

            return(View(model));
        }
Ejemplo n.º 3
0
        public ActionResult AddPosts(tripposts post, HttpPostedFileBase doc)
        {
            db.ConnsectionString();

            if (doc != null)
            {
                var filename  = Path.GetFileName(doc.FileName);
                var extension = Path.GetExtension(filename).ToLower();
                if (extension == ".jpg" || extension == ".png")
                {
                    var path = HostingEnvironment.MapPath(Path.Combine("~/Content/Images/", filename));
                    doc.SaveAs(path);

                    post.tripimage = "~/Content/Images/" + filename;

                    db.sqlConnection.Open();
                    sqlCommand.Connection  = db.sqlConnection;
                    sqlCommand.CommandText =

                        "INSERT INTO tripposts VALUES(@agencyname,@triptitle,@tripdesctiption,@tripdate,@tripdestination,@tripimage,@active)";

                    post.active = 1;
                    sqlCommand.Parameters.Add("@agencyname", post.agencyname);
                    sqlCommand.Parameters.Add("@triptitle", post.triptitle);
                    sqlCommand.Parameters.Add("@tripdesctiption", post.tripdesctiption);
                    sqlCommand.Parameters.Add("@tripdate", post.tripdate);
                    sqlCommand.Parameters.Add("@tripdestination", post.tripdestination);

                    sqlCommand.Parameters.Add("@tripimage", post.tripimage);
                    sqlCommand.Parameters.Add("@active", post.active);

                    sqlCommand.ExecuteReader();
                    db.sqlConnection.Close();

                    return(RedirectToAction("ViewAllPosts"));
                }
                else
                {
                    return(Content("<script language='javascript' type='text/javascript'>alert('Document size must be less then 5MB');</script>"));

                    db.sqlConnection.Close();

                    return(RedirectToAction("AddPosts"));
                }
            }
            return(Content("<script language='javascript' type='text/javascript'>alert('Photo is required');</script>"));

            return(RedirectToAction("AddPosts"));

            db.sqlConnection.Close();

            return(View("AddPosts"));
        }
Ejemplo n.º 4
0
        public ActionResult accept(tripposts post)
        {
            db.ConnsectionString();
            db.sqlConnection.Open();
            sqlCommand.Connection  = db.sqlConnection;
            sqlCommand.CommandText =
                "UPDATE tripposts SET active=" + 1 + " WHERE id='" + post.id + "'";

            sqlCommand.ExecuteReader();
            db.sqlConnection.Close();

            return(RedirectToAction("reviewPosts"));
        }
Ejemplo n.º 5
0
        public ActionResult Edit(tripposts post)
        {
            db.ConnsectionString();
            db.sqlConnection.Open();
            sqlCommand.Connection  = db.sqlConnection;
            sqlCommand.CommandText =
                "UPDATE tripposts SET agencyname=@agencyname ,triptitle = @triptitle,tripdesctiption=@tripdesctiption,tripdate=@tripdate,tripdestination=@tripdestination WHERE id='" + post.id + "'";

            sqlCommand.Parameters.AddWithValue("@agencyname", post.agencyname);
            sqlCommand.Parameters.AddWithValue("@triptitle", post.triptitle);
            sqlCommand.Parameters.AddWithValue("@tripdesctiption", post.tripdesctiption);
            sqlCommand.Parameters.AddWithValue("@tripdate", post.tripdate);
            sqlCommand.Parameters.AddWithValue("@tripdestination", post.tripdestination);


            sqlCommand.ExecuteReader();
            db.sqlConnection.Close();
            return(RedirectToAction("ViewAllPosts"));
        }
Ejemplo n.º 6
0
        public ActionResult showfavoriteposts()
        {
            if (getSessionId() == 0)
            {
                return(Content("<script language='javascript' type='text/javascript'>alert('u Must Login !!');</script>"));
            }
            else
            {
                string value = "";
                foreach (string key in Session.Contents)
                {
                    value = Session[key].ToString();
                }
                db.ConnsectionString();

                String     sql = "SELECT * FROM tripposts INNER JOIN Cart ON cart.postId = tripposts.id WHERE cart.travellerId ='" + int.Parse(value) + "'";
                SqlCommand cmd = new SqlCommand(sql, db.sqlConnection);

                var model = new List <tripposts>();

                db.sqlConnection.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    var post = new tripposts();

                    post.id              = (int)rdr["id"];
                    post.agencyname      = (string)rdr["agencyname"];
                    post.triptitle       = (string)rdr["triptitle"];
                    post.tripdesctiption = (string)rdr["tripdesctiption"];
                    post.tripdate        = (string)rdr["tripdate"];
                    post.tripdestination = (string)rdr["tripdestination"];


                    model.Add(post);
                }

                db.sqlConnection.Close();
                return(View(model));
            }
        }
Ejemplo n.º 7
0
        public ActionResult reviewPosts()
        {
            if (getSessionId() == 0)
            {
                return(Content("<script language='javascript' type='text/javascript'>alert('u Must Login !!');</script>"));
            }
            else
            {
                db.ConnsectionString();

                String     sql = "SELECT * FROM tripposts WHERE active LIKE'" + 0 + "'";
                SqlCommand cmd = new SqlCommand(sql, db.sqlConnection);

                var model = new List <tripposts>();

                db.sqlConnection.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    var post = new tripposts();

                    post.id              = (int)rdr["id"];
                    post.agencyname      = (string)rdr["agencyname"];
                    post.triptitle       = (string)rdr["triptitle"];
                    post.tripdesctiption = (string)rdr["tripdesctiption"];
                    post.tripdate        = (string)rdr["tripdate"];
                    post.tripdestination = (string)rdr["tripdestination"];


                    model.Add(post);
                }

                db.sqlConnection.Close();

                return(View(model));
            }
        }