public ActionResult Create(SaveCreate model) { var service = CreateSaveService(); if (service.CreateSave(model)) { TempData["SaveResult"] = "Your epic meme was saved!"; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "the meme could not be saved."); return(View(model)); }
public bool CreateSave(SaveCreate model) { var entity = new Save() { OwnerId = _userId, Title = model.Title, URL = model.URL }; using (var ctx = new ApplicationDbContext()) { ctx.Saves.Add(entity); return(ctx.SaveChanges() == 1); } }