using System.Collections.Generic;
using System.Linq;
using Spk.Common.Helpers.Guard;

namespace Spk.Common.Helpers.Service
{
    public class ServiceResult
    {
        public IEnumerable<string> Errors => _internalErrors;
        private readonly List<string> _internalErrors = new List<string>();

        public IEnumerable<string> Warnings => _internalWarnings;
        private readonly List<string> _internalWarnings = new List<string>();

        public bool Success => !Errors.Any();
        public bool HasWarnings => Warnings.Any();

        public void AddError(string error)
        {
            error.GuardIsNotNull(nameof(error));
            _internalErrors.Add(error);
        }

        public string GetFirstError()
        {
            return Errors.FirstOrDefault();
        }

        public void AddWarning(string warning)
        {
            warning.GuardIsNotNull(nameof(warning));
            _internalWarnings.Add(warning);
        }

        public string GetFirstWarning()
        {
            return Warnings.FirstOrDefault();
        }
    }

    public class ServiceResult<T> : ServiceResult
    {
        public T Data { get; private set; }

        public ServiceResult(T data)
        {
            SetData(data.GuardIsNotNull(nameof(data)));
        }

        public ServiceResult()
        {
        }

        public void SetData(T data)
        {
            Data = data;
        }
    }
}

using System.Collections.Generic;
using System.Linq;
using Spk.Common.Helpers.Guard;

namespace Spk.Common.Helpers.Service
{
    public class ServiceResult
    {
        public IEnumerable<string> Errors => _internalErrors;
        private readonly List<string> _internalErrors = new List<string>();

        public IEnumerable<string> Warnings => _internalWarnings;
        private readonly List<string> _internalWarnings = new List<string>();

        public bool Success => !Errors.Any();
        public bool HasWarnings => Warnings.Any();

        public void AddError(string error)
        {
            error.GuardIsNotNullOrWhiteSpace(nameof(error));
            _internalErrors.Add(error);
        }

        public string GetFirstError()
        {
            return Errors.FirstOrDefault();
        }

        public void AddWarning(string warning)
        {
            warning.GuardIsNotNullOrWhiteSpace(nameof(warning));
            _internalWarnings.Add(warning);
        }

        public string GetFirstWarning()
        {
            return Warnings.FirstOrDefault();
        }
    }

    public class ServiceResult<T> : ServiceResult
    {
        public T Data { get; private set; }

        public ServiceResult(T data)
        {
            SetData(data.GuardIsNotNull(nameof(data)));
        }

        public ServiceResult()
        {
        }

        public void SetData(T data)
        {
            Data = data;
        }
    }
}

Leverage 'GuardIsNotNullOrWhiteSpace' method instead of 'GuardIsNotNull'
Leverage 'GuardIsNotNullOrWhiteSpace' method instead of 'GuardIsNotNull'
