| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 | using System;
using System.Collections.Generic;
using System.Linq;
using Luticate2.Auth.Dbo.Tokens;
using Luticate2.Auth.Dbo.Users;
using Luticate2.Utils.Dbo.Basic;
using Luticate2.Utils.Dbo.Result;
using Luticate2.Utils.Utils;
namespace Luticate2.Auth.Business
{
    public static class LuBusinessExtensions
    {
        public static IEnumerable<LuUsersDbo> ToLite(this IEnumerable<LuUsersFullDbo> userRes)
        {
            return userRes.Select(fullDbo => fullDbo.ToLite());
        }
        public static LuResult<LuUsersDbo> ToLite(this LuResult<LuUsersFullDbo> userRes)
        {
            return userRes.To(dbo => dbo.ToLite());
        }
        public static LuResult<LuPaginatedDbo<LuUsersDbo>> ToLite(this LuResult<LuPaginatedDbo<LuUsersFullDbo>> userRes)
        {
            return userRes.To(dbo => dbo.To(dbos => dbos.ToLite().ToList()));
        }
        public static LuUsersDbo ToLite(this LuUsersFullDbo dbo)
        {
            if (dbo == null)
            {
                return null;
            }
            return new LuUsersDbo
            {
                Id = dbo.Id,
                Username = dbo.Username
            };//TODO
        }
        public static LuUsersToken ToUserToken(this LuTokensDbo dbo)
        {
            if (dbo == null)
            {
                return null;
            }
            return new LuUsersToken
            {
                Data = dbo.Data,
                NotAfter = dbo.NotAfter,
                NotBefore = dbo.NotBefore,
                UserId = dbo.UserId
            };
        }
    }
}
 |