Example #1
0
        public ActionResult Create([Bind(Include = "User_Id,First_Name,Last_Name,E_Mail,Password,Profile_Picture,Phone_Number,Gender,Birthday,Marital_Status,About_me,HomeTown")] User user)
        {
            if (ModelState.IsValid)
            {
                if (ModelState.IsValid)
                {
                    user.Password = Crypto.HashPassword(user.Password);
                    user.Friends.Add(user);
                    db.Users.Add(user);
                    db.SaveChanges();
                    Session["ID"] = user.User_Id;
                    user.Posts.Add(new Post()
                    {
                        User_Id = user.User_Id, Caption = user.First_Name + " has created a profile", Private_Public = true, Time = DateTime.Now
                    });
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            return(View(user));
        }