Пример #1
0
        public async Task <User> GetUser(string externalUserId, UserDomainEnum currentUserDomain)
        {
            if (await EnsureLogin())
            {
                try
                {
                    var domainsTable = MobileService.GetTable <UserDomain>();
                    var domains      = await domainsTable.ToCollectionAsync();

                    var currentDomain = domains.Single(d => d.DomainKey == (int)currentUserDomain);
                    var extUsers      = await MobileService.GetTable <ExternalUser>().ToListAsync();

                    var currentExtUser =
                        extUsers.Single(u => u.ExternalUserId == externalUserId && u.UserDomainId == currentDomain.Id);
                    var users = await MobileService.GetTable <User>().ToListAsync();

                    var user = users.Single(u => u.Id == currentExtUser.UserId);
                    return(user);
                }
                catch (Exception ex)
                {
                }
                return(null);
            }
            return(null);
        }
Пример #2
0
        public async Task <string> GetUserId(string externalUserId, UserDomainEnum currentUserDomain)
        {
            if (await EnsureLogin())
            {
                try
                {
                    var domains = await MobileService.GetTable <UserDomain>().ToListAsync();

                    var currentDomain = domains.Single(d => d.DomainKey == (int)currentUserDomain);
                    var externalUsr   = await MobileService.GetTable <ExternalUser>().ToListAsync();

                    var currentExtUsr =
                        externalUsr.Single(u => u.ExternalUserId == externalUserId && u.UserDomainId == currentDomain.Id);

                    return(currentExtUsr.UserId);
                }
                catch (Exception ex)
                {
                }
            }
            return("");
        }