public ActionResult Create([Bind(Include = "BlogId,Title,Description,Deleted")] Blog blog)
        {
            if (ModelState.IsValid)
            {
                db.Blogs.Add(blog);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(blog));
        }
        public ActionResult Create([Bind(Include = "PostId,Title,Body,Deleted,UserId")] Post post)
        {
            if (ModelState.IsValid)
            {
                db.Posts.Add(post);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(post));
        }
Beispiel #3
0
        public ActionResult Create([Bind(Include = "UserId,UserName,Email,Password,BirthDay,Avatar")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
Beispiel #4
0
        public ActionResult Create([Bind(Include = "RoleId,Name,Description,Deleted")] Role role)
        {
            if (ModelState.IsValid)
            {
                db.Roles.Add(role);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(role));
        }
        public ActionResult Create([Bind(Include = "CommentId,Body,UserId,Deleted,PostId")] Comment comment)
        {
            if (ModelState.IsValid)
            {
                db.Comments.Add(comment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PostId = new SelectList(db.Posts, "PostId", "Title", comment.PostId);
            return(View(comment));
        }
Beispiel #6
0
        public ActionResult Create([Bind(Include = "PostId,Title,Body,Deleted")] PostModel postModel)
        {
            var post = AutoMapper.Mapper.Map <PostModel, Post>(postModel) as Post;

            if (ModelState.IsValid)
            {
                db.Posts.Add(post);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(post));
        }
Beispiel #7
0
 public void Save()
 {
     _context.SaveChanges();
 }