コード例 #1
0
        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");
        }
コード例 #2
0
ファイル: BandController.cs プロジェクト: uneecorn/trinity
 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()));
     }
 }
コード例 #3
0
 public void Validate(BandInsertingModel model)
 {
     CreateInsertingValidationRules();
     Validate((Band)model).HandleResult();
 }