Exemple #1
0
        public async Task <string> CreateAsync(ScopeViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var param = ToParam(model);

            return(await _service.CreateAsync(param));
        }
Exemple #2
0
        public async Task <IActionResult> UpdateAsync([FromBody] ScopeViewModel model)
        {
            if (model == null)
            {
                return(BadRequest());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _service.UpdateAsync(model);

            return(NoContent());
        }
Exemple #3
0
        public async Task <IActionResult> CreateAsync([FromBody] ScopeViewModel model)
        {
            if (model == null)
            {
                return(BadRequest());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _service.CreateAsync(model);

            return(Created($"scopes/{result}", result));
        }
Exemple #4
0
        public async Task UpdateAsync(ScopeViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            if (string.IsNullOrWhiteSpace(model.Id))
            {
                throw new InvalidOperationException(nameof(model.Id));
            }

            var param = ToParam(model);

            await _service.UpdateAsync(param);
        }
Exemple #5
0
 private static ScopeParam ToParam(ScopeViewModel model)
 {
     return(SimpleMapper.From <ScopeViewModel, ScopeParam>(model));
 }