Example #1
0
        public async Task <IBaseResult> AddWeatherForeCast(Weather weather)
        {
            BaseResult <Domain.Weather> result = new BaseResult <Weather>();

            result.SetSuccess(await this.weatherCommandService.Add(weather));

            return(result);
        }
Example #2
0
        public async Task <IBaseResult> GetWeatherForecast()
        {
            BaseResult <IEnumerable <Weather> > result = new BaseResult <IEnumerable <Weather> >();

            var data = await this.weatherQueryService.GetAll();

            result.SetSuccess(data);

            return(await Task.FromResult(result));
        }
Example #3
0
        /// <summary>
        /// Method for try to convert a string to boolean
        /// </summary>
        /// <param name="expected"></param>
        /// <returns></returns>
        public static IBaseResult <bool> GetValidBoolean(string expected)
        {
            BaseResult <bool> result = new BaseResult <bool>();

            if (bool.TryParse(expected, out bool value))
            {
                result.SetResult(value);
                result.SetSuccess();
            }

            return(result);
        }
Example #4
0
        /// <summary>
        /// Method for try to convert a string to decimal
        /// </summary>
        /// <param name="expected"></param>
        /// <returns></returns>
        public static IBaseResult <decimal> GetValidDecimal(string expected)
        {
            BaseResult <decimal> result = new BaseResult <decimal>();

            if (decimal.TryParse(expected, out decimal value))
            {
                result.SetResult(value);
                result.SetSuccess();
            }

            return(result);
        }
Example #5
0
        /// <summary>
        /// Method for try to convert a string to double
        /// </summary>
        /// <param name="expected"></param>
        /// <returns></returns>
        public static IBaseResult <double> GetValidDouble(string expected)
        {
            BaseResult <double> result = new BaseResult <double>();

            if (double.TryParse(expected, out double value))
            {
                result.SetResult(value);
                result.SetSuccess();
            }

            return(result);
        }
Example #6
0
        /// <summary>
        /// Method for try to convert a string to DateTime
        /// </summary>
        /// <param name="expected"></param>
        /// <returns></returns>
        public static IBaseResult <DateTime> GetValidDateTime(string expected)
        {
            BaseResult <DateTime> result = new BaseResult <DateTime>();

            if (DateTime.TryParse(expected, out DateTime value))
            {
                result.SetResult(value);
                result.SetSuccess();
            }

            return(result);
        }
Example #7
0
        /// <summary>
        /// Method for try to convert a string to int
        /// </summary>
        /// <param name="expected"></param>
        /// <returns></returns>
        public static IBaseResult <int> GetValidInt(string expected)
        {
            BaseResult <int> result = new BaseResult <int>();

            if (int.TryParse(expected, out int value))
            {
                result.SetResult(value);
                result.SetSuccess();
            }

            return(result);
        }
Example #8
0
        /// <summary>
        /// Method for try to convert a string to long
        /// </summary>
        /// <param name="expected"></param>
        /// <returns></returns>
        public static IBaseResult <long> GetValidLong(string expected)
        {
            BaseResult <long> result = new BaseResult <long>();

            if (long.TryParse(expected, out long value))
            {
                result.SetResult(value);
                result.SetSuccess();
            }

            return(result);
        }