public ActionResult Edit(Post post)
        {
            data.Entry(post).State = EntityState.Modified;
            data.SaveChanges();

            return RedirectToAction("Index", "Blog");
        }
示例#2
0
        public ActionResult Create(Post post)
        {
            if (ModelState.IsValid)
            {
                db.Posts.Add(post);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(post);
        }
示例#3
0
 public PostService(string parUserId)
 {
     _post = new Post();
     _post.ApplicationUserId = parUserId;
     _post.Tittle = "";
     _post.PostComments = new Collection<PostComment>();
     _post.PostViews = new Collection<PostView>();
     _post.PostTags = new Collection<PostTag>();
     _post.PostContents = new Collection<PostContent>();
     // _post.PostContents.Add(new PostContent() { ContentDataType = parContentDataType, ContentData = new byte[0] });
 }
示例#4
0
        public ActionResult Create(Post post)
        {
            try
            {
                post.PostID = _blogDataContext.Posts.OrderByDescending(x => x.PostID).First().PostID + 1;
                _blogDataContext.Posts.InsertOnSubmit(post);
                _blogDataContext.SubmitChanges();

                return RedirectToAction("Index");
            }
            catch
            {
                return View(post);
            }
        }
        public ActionResult Create(Post post)
        {
            if(!ModelState.IsValid)
            {
                return View(post);
            }

            var user = data.Users.FirstOrDefault(x => x.Username == User.Identity.Name);

            post.UserId = user.Id;
            post.CreatedOn = DateTime.Now;
            data.Posts.Add(post);
            data.SaveChanges();

            return RedirectToAction("Index", "Blog");
        }
示例#6
0
 public ActionResult Create(Post post)
 {
     db.Posts.Add(post);
     db.SaveChanges();
     return RedirectToAction("Index");
 }
示例#7
0
 public PostService(Post Post)
 {
     _post = Post;
 }
示例#8
0
 public ActionResult Edit(Post post)
 {
     if (ModelState.IsValid)
     {
         db.Entry(post).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(post);
 }
示例#9
0
		private void detach_Posts(Post entity)
		{
			this.SendPropertyChanging();
			entity.Category = null;
		}
示例#10
0
 partial void DeletePost(Post instance);
示例#11
0
		private void attach_Posts(Post entity)
		{
			this.SendPropertyChanging();
			entity.Category = this;
		}
示例#12
0
 partial void UpdatePost(Post instance);
示例#13
0
 partial void InsertPost(Post instance);
示例#14
0
        public ActionResult Edit(Post post)
        {
            //Custom form validation
            if (post.Title.Length == 1)
                ModelState.AddModelError("Title", "Your title has to be a little bit longer");

            ViewData["Categories"] = _blogDataContext.Categories.ToSelectList("CategoryID", "CategoryName");

            if (ModelState.IsValid)
            {
                var p = _blogDataContext.Posts.SingleOrDefault(x => x.PostID == post.PostID);
                UpdateModel(p);

                _blogDataContext.SubmitChanges();
            }

            return View(post);
        }