< Summary

Class:SVETA.Api.Controllers.ValidateModelAttribute
Assembly:SVETA.Api
File(s):/opt/dev/sveta_api_build/SVETA.Api/Validation/ValidateModelAttribute.cs
Covered lines:0
Uncovered lines:8
Coverable lines:8
Total lines:27
Line coverage:0% (0 of 8)
Covered branches:0
Total branches:2
Branch coverage:0% (0 of 2)

Metrics

MethodLine coverage Branch coverage
OnActionExecuted(...)0%100%
OnActionExecuting(...)0%0%

File(s)

/opt/dev/sveta_api_build/SVETA.Api/Validation/ValidateModelAttribute.cs

#LineLine coverage
 1using Microsoft.AspNetCore.Mvc;
 2using Microsoft.AspNetCore.Mvc.Filters;
 3using System;
 4using System.Collections.Generic;
 5using System.Linq;
 6using System.Threading.Tasks;
 7
 8namespace SVETA.Api.Controllers
 9{
 10    /// <summary>
 11    /// Отдает ошибку валидации моделей контроллера в стандартном едином виде
 12    /// </summary>
 13    public class ValidateModelAttribute : IActionFilter
 14    {
 15        public void OnActionExecuted(ActionExecutedContext context)
 016        {
 017        }
 18
 19        public void OnActionExecuting(ActionExecutingContext context)
 020        {
 021            if (!context.ModelState.IsValid)
 022            {
 023                context.Result = new ValidationFailedResult(context.ModelState);
 024            }
 025        }
 26    }
 27}