示例#1
0
        // GET: Account
        public ActionResult Index()
        {
            if (Session["userId"] is null)
            {
                return(RedirectToAction("NotFound", "Home", new { id = "User not logged in" }));
            }

            UserBll userBll = new UserBll();

            MVCPAP.Models.User user = userBll.GetUserById(Session["userId"].ToString());

            VideoBll videoBll = new VideoBll();

            ViewBag.videos = videoBll.GetVideosByUserId(Session["userId"].ToString());

            return(View(user));
        }
示例#2
0
        public ActionResult profile(string id)
        {
            if (!id.Contains("-"))
            {
                Response.Redirect("PageNotFound...");
            }
            int    discriminator = int.Parse(id.Split('-')[0]);
            string username      = id.Split('-')[1];
            //  SqlConnection connection = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=PAP1;Integrated Security=True");

            //  SqlDataAdapter dataAdapter = new SqlDataAdapter(
            //"SELECT * FROM [User] Where username='******' And discriminator=" + discriminator, connection);
            //  DataSet dataSet = new DataSet();
            //  dataAdapter.Fill(dataSet);

            //  if(dataSet.Tables[0].Rows.Count<=0)
            //  {
            //      throw new Exception("User not found");
            //  }

            //  _User user = new _User();
            //  user.email = dataSet.Tables[0].Rows[0]["email"].ToString();
            //  user.username = username;
            //  user.discriminator = discriminator;
            //  user.profilePicture = dataSet.Tables[0].Rows[0]["profilePicture"].ToString();
            //  user.password = dataSet.Tables[0].Rows[0]["password"].ToString();

            UserBll userBll = new UserBll();

            try
            {
                ViewBag.user = userBll.GetUserById(id);
            }
            catch (Exception ex)
            {
                return(RedirectToAction("NotFound", "Home", new { message = ex.Message }));
            }


            // SqlDataAdapter dataAdapter2 = new SqlDataAdapter(
            //"SELECT * FROM Video Where username='******' And discriminator='" + discriminator + "'", connection);
            // DataSet dataSet2 = new DataSet();
            // dataAdapter2.Fill(dataSet2);

            // List<_Video> Videos = new List<_Video>();

            // foreach (DataRow row in dataSet2.Tables[0].Rows)
            // {
            //     _Video V = new _Video();
            //     V.id = int.Parse(row["id"].ToString());
            //     V.title = row["title"].ToString();
            //     V.username = row["username"].ToString();
            //     V.discriminator = int.Parse(row["discriminator"].ToString());
            //     V.videoFile = row["videoFile"].ToString();
            //     V.thumbnail = row["thumbnail"].ToString();
            //     Videos.Add(V);
            // }
            VideoBll videoBll = new VideoBll();

            ViewBag.Videos = videoBll.GetVideosByUserId(id);

            return(View());
        }