public ActionResult Create(SpecialNeedsStory story) { ViewBag.exMsg = ""; try { if (!ModelState.IsValid) return View(); // we need to gen the primary key story.SpecialNeedsStoryId = Guid.NewGuid(); if (Request.Files != null & Request.Files.Count > 0) { HttpPostedFileBase storyImageFile = Request.Files["image"]; if (storyImageFile != null) story.Image = ImageUtils.GetBytes(storyImageFile.InputStream); } // Add and Save var _db = new DataEntities(); _db.SpecialNeedsStories.AddObject(story); _db.SaveChanges(); return RedirectToAction("Index"); } catch (Exception ex) { ViewBag.exMsg = ex.Message; return View(); } }
/// <summary> /// Deprecated Method for adding a new object to the SpecialNeedsStories EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSpecialNeedsStories(SpecialNeedsStory specialNeedsStory) { base.AddObject("SpecialNeedsStories", specialNeedsStory); }
/// <summary> /// Create a new SpecialNeedsStory object. /// </summary> /// <param name="specialNeedsStoryId">Initial value of the SpecialNeedsStoryId property.</param> /// <param name="isFeatured">Initial value of the IsFeatured property.</param> public static SpecialNeedsStory CreateSpecialNeedsStory(global::System.Guid specialNeedsStoryId, global::System.Boolean isFeatured) { SpecialNeedsStory specialNeedsStory = new SpecialNeedsStory(); specialNeedsStory.SpecialNeedsStoryId = specialNeedsStoryId; specialNeedsStory.IsFeatured = isFeatured; return specialNeedsStory; }