public IActionResult PostSchool([FromBody] SchoolInsertModel school) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = unitOfWork.School.Insert(school); return(Ok(new { result })); } catch (Exception ex) { Log.Error(ex, "Exceptions occurred in post school api"); return(StatusCode(500, ex.Message)); } }
public bool Insert(SchoolInsertModel model) { try { var school = new School() { Name = model.Name }; Add(school); Log.Information("Created school {0}", model.Name); return(true); } catch (System.Exception ex) { Log.Error(ex, "Exceptions occurred in school insert"); return(false); } }