public IActionResult Add(View view) { _Context.views.Add(view); _Context.SaveChanges(); List <View> views = _Context.views.ToList(); return(View("Show", views)); }
private void Save() { try { Db.SaveChanges(); } catch (DbUpdateException e) { var sb = new StringBuilder(); sb.AppendLine($"DbUpdateException error details - {e?.InnerException?.InnerException?.Message}"); foreach (var eve in e.Entries) { sb.AppendLine($"Entity of type {eve.Entity.GetType().Name} in state {eve.State} could not be updated"); } } }
private void Save() { try { Db.SaveChanges(); } catch (DbUpdateException e) { var sb = new StringBuilder(); sb.AppendLine($"Error: technic detail::: {e?.InnerException?.InnerException?.Message}"); foreach (var eve in e.Entries) { sb.AppendLine($"Object [{eve.Entity.GetType().Name}] in state [{eve.State}] can't be updated."); } } }
public ViewResult ThirdMethod(FirstClass obj) { //ViewBag.FirstObject = obj; try { FirstContext db = new FirstContext(); db.FirstClasses.Add(obj); db.SaveChanges(); ViewBag.Message = "Successfully Added"; } catch (Exception e) { ViewBag.Message = $"Something Went Wrong Details {e.Message}"; return(View()); } return(View()); }