public ActionResult Create(DocumentType model) { if (!ModelState.IsValid) return View(model); DocumentType.CreateDocumentType(model); return RedirectToAction("Index"); }
//POST: Edit public static void EditDocumentType(DocumentType dt) { using (var db = new ApplicationDbContext()) { //try //{ db.Entry(dt).State = EntityState.Modified; db.SaveChanges(); //} //catch (Exception ex) when (ex is DbUpdateException || // ex is DbEntityValidationException || // ex is NotSupportedException || // ex is ObjectDisposedException || // ex is InvalidOperationException) //{ // ErrorHelpers.LogError(ex, ErrorLevel.Error, "Error on write in database"); //} } }
public static void CreateDocumentType(DocumentType docType) { if (docType != null) { using (var db = new ApplicationDbContext()) { //try //{ db.DocumentsTypes.Add(docType); db.SaveChanges(); //} //catch (Exception ex) when (ex is DbUpdateException || // ex is DbEntityValidationException || // ex is NotSupportedException || // ex is ObjectDisposedException || // ex is InvalidOperationException) //{ //ErrorHelpers.LogError(ex, ErrorLevel.Error, "Error on write in database"); //} } } }