Exemplo n.º 1
0
        public async Task <bool> CreateExpressLogin()
        {
            if (ExpLogin != null && !string.IsNullOrEmpty(ExpLogin.Password))
            {
                var list = await GetExpressLogins();

                if (list == null)
                {
                    list = new List <ExpressLogin>();
                }

                var el = new ExpressLogin()
                {
                    Id     = this.User.Id,
                    UserId = this.AzureClient.CurrentUser.UserId,
                    MobileServiceAuthenticationToken = this.AzureClient.CurrentUser.MobileServiceAuthenticationToken,
                    Password = ExpLogin.Password
                };

                if (list.Any(x => x.Password == el.Password))
                {
                    return(false);
                }

                if (list.Any(x => x.Id == el.Id))
                {
                    var existingItem = list.First(x => x.Id == el.Id);
                    var index        = list.IndexOf(existingItem);
                    list[index] = el;
                }
                else
                {
                    list.Add(el);
                }
                var lss = new LocalStorageService();
                lss.SaveIsolatedStorage <List <ExpressLogin> >("SkadooshLogin", list);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public async Task<bool> CreateExpressLogin()
        {
            if (ExpLogin != null && !string.IsNullOrEmpty(ExpLogin.Password))
            {
                var list = await GetExpressLogins();

                if (list == null)
                    list = new List<ExpressLogin>();

                var el = new ExpressLogin()
                {
                    Id = this.User.Id,
                    UserId = this.AzureClient.CurrentUser.UserId,
                    MobileServiceAuthenticationToken = this.AzureClient.CurrentUser.MobileServiceAuthenticationToken,
                    Password = ExpLogin.Password

                };

                if (list.Any(x => x.Password == el.Password))
                    return false;

                if (list.Any(x => x.Id == el.Id))
                {
                    var existingItem = list.First(x => x.Id == el.Id);
                    var index = list.IndexOf(existingItem);
                    list[index] = el;
                }
                else
                {
                    list.Add(el);
                }
                var lss = new LocalStorageService();
                lss.SaveIsolatedStorage<List<ExpressLogin>>("SkadooshLogin", list);
                return true;
            }
            else
            {
                return false;
            }
        }