public bool CreateIdea(IdeaCreate model) { var entity = new Idea() { OwnerId = _userId, IdeaId = model.IdeaId, IdeaTitle = model.IdeaTitle, IdeaDescription = model.IdeaDescription, DateIdeaCreated = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Ideas.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(IdeaCreate model) { if (ModelState.IsValid) { return(View(model)); } var service = CreateIdeaService(); if (service.CreateIdea(model)) { TempData["SaveResult"] = "Your Idea was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Idea could not be created."); return(View(model)); }