public ActionResult Create(DocumentType model)
        {
            if (!ModelState.IsValid)
                return View(model);

            DocumentType.CreateDocumentType(model);
            return RedirectToAction("Index");
        }
Пример #2
0
 //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");
         //}
     }
 }
Пример #3
0
 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");
             //}
         }
     }
 }