public ActionResult Create(BlogMaster Blog, int Categoryid) { if (ModelState.IsValid) { //Save Sub Category Blog.DateTime = System.DateTime.Now; Blog.UserId = 1; Blog.UserName = User.Identity.Name; Blog.CategoryId = Categoryid; shopDB.AddToBlogMasters(Blog); shopDB.SaveChanges(); return RedirectToAction("Browse", "Category", new { Category = Blog.CategoryMaster.Name }); } // Invalid – redisplay with errors var viewModel = new BlogManagerViewModel { Blog = new BlogMaster() }; return View(viewModel); }
/// <summary> /// Create a new BlogMaster object. /// </summary> /// <param name="blogId">Initial value of the BlogId property.</param> /// <param name="categoryId">Initial value of the CategoryId property.</param> /// <param name="userId">Initial value of the UserId property.</param> /// <param name="description">Initial value of the Description property.</param> /// <param name="dateTime">Initial value of the DateTime property.</param> /// <param name="userName">Initial value of the UserName property.</param> public static BlogMaster CreateBlogMaster(global::System.Int32 blogId, global::System.Int32 categoryId, global::System.Int32 userId, global::System.String description, global::System.DateTime dateTime, global::System.String userName) { BlogMaster blogMaster = new BlogMaster(); blogMaster.BlogId = blogId; blogMaster.CategoryId = categoryId; blogMaster.UserId = userId; blogMaster.Description = description; blogMaster.DateTime = dateTime; blogMaster.UserName = userName; return blogMaster; }
/// <summary> /// Deprecated Method for adding a new object to the BlogMasters EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToBlogMasters(BlogMaster blogMaster) { base.AddObject("BlogMasters", blogMaster); }