private void DeleteBlogItem(BlogItem blogItem) { using (ApplicationDbContextcs db = new ApplicationDbContextcs()) { try { Trace.WriteLine("Trying to delete blogItem"); if (blogItem != null) { db.blogItem.Remove(blogItem); db.SaveChanges(); } } catch (Exception e) { Trace.WriteLine("Problem While deleting blog item"); } } }
public IActionResult Register(UserAcccount account) { try { addViewBags(); } catch (Exception e) { Console.WriteLine(e.StackTrace); } if (ModelState.IsValid) { using (ApplicationDbContextcs db = new ApplicationDbContextcs()) { db.userAccount.Add(account); db.SaveChanges(); } ModelState.Clear(); ViewBag.Message = account.FirstName + " " + account.LastName + " Successfully registered."; } return(View()); }