public ViewResult SaveRSVP(Invite invite) { ViewData["SelectedLink"] = "WeddingRSVP"; foreach (Guest guestData in invite.Guests) { Guest guest = db.Guests.Single(x => x.GuestID == guestData.GuestID); if (guest.InvitedToCeremony) { guest.ConfirmCeremony = guestData.ConfirmCeremony; } guest.ConfirmReception = guestData.ConfirmReception; } db.SaveChanges(); ViewBag.InviteId = invite.Id; return(View("RSVPThankYou")); }
public ViewResult AddBlogPost(BlogPost blogPost) { ViewData["type"] = "add"; blogPost.FriendlyUrl = Url.ToFriendlyUrl(blogPost.Title); blogPost.Author = User.Identity.Name; blogPost.Date = DateTime.Now; if (!ModelState.IsValid) { return(View("ManageBlogPost")); } db.BlogPosts.AddObject(blogPost); db.SaveChanges(); ViewData["message"] = "Blog post added successfully."; ViewData["returnUrl"] = Url.Action("ManageBlogPosts"); return(View("Result")); }
public RedirectToRouteResult AddComment(int BlogId, string Name, string Website, string Comment) { AlexAndNikkiDBEntities db = new AlexAndNikkiDBEntities(); BlogPost post = db.BlogPosts.Where(x => x.Id == BlogId).First(); post.BlogPostComments.Add(new BlogPostComment { BlogPostId = BlogId, Name = Name, Website = Website, Comment = Comment, Date = DateTime.Now }); db.SaveChanges(); return(RedirectToAction("Post", new { Id = post.FriendlyUrl })); }