public async Task <DictionaryCrudResponse> FaultCrud(DictionaryCrudRequest input)
        {
            var data = input.Fault;

            if (data == null && input.IdToDelete == null)
            {
                throw new ValidationException("Не распарсилось");
            }

            var sqlR = new FaultsRepository(_logger);

            if (input?.IdToDelete != null)
            {
                await sqlR.Delete((int)input.IdToDelete);

                return(new DictionaryCrudResponse {
                    IsDeleted = true, Fault = data
                });
            }

            var all = await sqlR.GetAll();

            if (all.Any(x => x.Name.Equals(input.Fault.Name)))
            {
                throw new ValidationException(Error.AlreadyAddWithThisName);
            }

            if (data?.Id == 0)
            {
                var item = await sqlR.Add(data);

                return(new DictionaryCrudResponse {
                    IsAdd = true, Fault = item
                });
            }
            else
            {
                //Неиспользуемая хуета этот тип фаулта
                data.FaultType = 0;
                var item = await sqlR.Update(data);

                return(new DictionaryCrudResponse {
                    IsUpdated = true, Fault = item
                });
            }
        }
        public async Task <JsonResult> Add([FromBody] Fault input)
        {
            await CheckPermission();

            var   sqlR = new FaultsRepository(_logger);
            Fault result;

            if (input.Id != 0)
            {
                result = await sqlR.Update(input);
            }
            else
            {
                result = await sqlR.Add(input);
            }

            return(Json(result));
        }