public ActionResult Create([Bind(Include = "Id,FirstUser,SecondUser,Accepted")] Friendship friendship)
        {
            if (ModelState.IsValid)
            {
                db.FriendshipSet.Add(friendship);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(friendship));
        }
        public ActionResult Create([Bind(Include = "Id,Date,ProfileId")] Share share)
        {
            if (ModelState.IsValid)
            {
                db.ShareSet.Add(share);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProfileId = new SelectList(db.ProfileSet, "Id", "Email", share.ProfileId);
            return(View(share));
        }
Example #3
0
        public ActionResult Create([Bind(Include = "Id,Liked,ProfileId,PostId")] Like like)
        {
            if (ModelState.IsValid)
            {
                db.LikeSet.Add(like);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProfileId = new SelectList(db.ProfileSet, "Id", "Email", like.ProfileId);
            ViewBag.PostId    = new SelectList(db.PostSet, "Id", "Text", like.PostId);
            return(View(like));
        }
Example #4
0
        public ActionResult Create([Bind(Include = "Id,Text,Date,ProfileId,PostId")] Comment comment)
        {
            if (ModelState.IsValid)
            {
                db.CommentSet.Add(comment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProfileId = new SelectList(db.ProfileSet, "Id", "Email", comment.ProfileId);
            ViewBag.PostId    = new SelectList(db.PostSet, "Id", "Text", comment.PostId);
            return(View(comment));
        }
Example #5
0
        public ActionResult Create([Bind(Include = "Id,Text,Date,Media,ProfileId,ShareId")] Post post)
        {
            if (ModelState.IsValid)
            {
                post.ProfileId = (int)Session["ProfileId"];
                if (post.ShareId == null)
                {
                    post.ShareId = 00000;
                }
                db.PostSet.Add(post);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProfileId = new SelectList(db.ProfileSet, "Id", "Email", post.ProfileId);
            ViewBag.ShareId   = new SelectList(db.ShareSet, "Id", "Id", post.ShareId);
            return(View(post));
        }
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,BirthDate")] Profile profile, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file != null && file.ContentLength > 0)
                {
                    try
                    {
                        //string pic = Path.GetFileName(file.FileName);
                        //string path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Images"),
                        // pic);
                        //file.SaveAs(path);

                        string path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Images/"), file.FileName);//mandando a pasta para o diretório
                        file.SaveAs(path);
                        //File.Delete(imgpath);
                        profile.PictureUrl = file.FileName;

                        ViewBag.Message = "File uploaded successfully";
                    }
                    catch (Exception ex)
                    {
                        ViewBag.Message = "ERROR:" + ex.Message.ToString();
                    }
                }
                else
                {
                    ViewBag.Message = "You have not specified a file.";
                }
                profile.Email      = User.Identity.GetEmailAdress();
                profile.PictureUrl = file.FileName;
                db.ProfileSet.Add(profile);
                db.SaveChanges();
                return(RedirectToAction("Index", "Feed"));
            }

            return(View(profile));
        }