Exemplo n.º 1
0
        public ActionResult Edit(Post post)
        {
            data.Entry(post).State = EntityState.Modified;
            data.SaveChanges();

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

            return View(post);
        }
Exemplo n.º 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] });
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 5
0
        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");
        }
Exemplo n.º 6
0
 public ActionResult Create(Post post)
 {
     db.Posts.Add(post);
     db.SaveChanges();
     return RedirectToAction("Index");
 }
Exemplo n.º 7
0
 public PostService(Post Post)
 {
     _post = Post;
 }
Exemplo n.º 8
0
 public ActionResult Edit(Post post)
 {
     if (ModelState.IsValid)
     {
         db.Entry(post).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(post);
 }
Exemplo n.º 9
0
		private void detach_Posts(Post entity)
		{
			this.SendPropertyChanging();
			entity.Category = null;
		}
Exemplo n.º 10
0
 partial void DeletePost(Post instance);
Exemplo n.º 11
0
		private void attach_Posts(Post entity)
		{
			this.SendPropertyChanging();
			entity.Category = this;
		}
Exemplo n.º 12
0
 partial void UpdatePost(Post instance);
Exemplo n.º 13
0
 partial void InsertPost(Post instance);
Exemplo n.º 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);
        }