Example #1
0
        public MusicDisplayingModel Create(MusicInsertingModel model)
        {
            Validator.Validate(model);
            Music entity = model;

            Repository.Create(entity);
            Repository.SaveDbChanges();
            if (Exists(entity))
            {
                return(entity);
            }
            throw new InternalServerException("An error ocurred while saving the model");
        }
Example #2
0
 public IActionResult Post([FromBody] MusicInsertingModel 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()));
     }
 }
Example #3
0
 public void Validate(MusicInsertingModel model)
 {
     CreateInsertingValidationRules();
     Validate((Music)model).HandleResult();
 }