Example #1
0
 public ActionResult CreateNewPostType([FromBody] PostType postType)
 {
     try
     {
         if (ModelState.IsValid)
         {
             postType.CreatedDate = DateTime.Now;
             _context.Add(postType);
             _context.SaveChangesAsync();
         }
     }
     catch (DbUpdateException)
     {
         //Log the error (uncomment ex variable name and write a log.
         ModelState.AddModelError("", "Unable to save changes. " +
                                  "Try again, and if the problem persists " +
                                  "see your system administrator.");
     }
     return(Ok());
 }