public BandDisplayingModel Create(BandInsertingModel model) { Validator.Validate(model); Band entity = model; Repository.Create(entity); Repository.SaveDbChanges(); if (Exists(entity)) { return(entity); } throw new InternalServerException("An error ocurred while saving the model"); }
public IActionResult Post([FromBody] BandInsertingModel model) { try { return(StatusCode(201, App.Create(model))); } catch (ValidationException ex) { return(StatusCode(400, ex.ToString())); } catch (InternalServerException ex) { return(StatusCode(500, ex.ToString())); } catch (Exception ex) { return(StatusCode(500, ex.ToString())); } }
public void Validate(BandInsertingModel model) { CreateInsertingValidationRules(); Validate((Band)model).HandleResult(); }