Esempio n. 1
0
        private async Task CheckPowerFields(PowerDto powerDto)
        {
            await _elementService.FindById(powerDto.ElementId);

            if (string.IsNullOrEmpty(powerDto.Name) || string.IsNullOrEmpty(powerDto.Strength.ToString()) || string.IsNullOrEmpty(powerDto.MainTrait) || string.IsNullOrEmpty(powerDto.ElementId.ToString()) || string.IsNullOrEmpty(powerDto.Details))
            {
                throw new NullParameterException($"There are null parameters");
            }

            if (powerDto.Strength < 1 || powerDto.Strength > 100)
            {
                throw new OutOfRangeException(nameof(PowerDto.Strength));
            }
        }
Esempio n. 2
0
        public Response <ElementDto> GetById(Guid id)

        {
            Response <ElementDto> response = new Response <ElementDto>();

            try
            {
                response.Object = _elementService.FindById(id);
            }
            catch (Exception ex)
            {
                response.Errored      = true;
                response.ErrorMessage = ex.Message;
                _logger.LogError($"{typeof(ElementController).FullName}.{nameof(GetById)}", null);
            }
            return(response);
        }