Esempio n. 1
0
 public override void AfterConstruction()
 {
     base.AfterConstruction();
     StartOn = DateTime.Now;
     EndOn   = StartOn.AddHours(1);
     AppUsers.Add(Session.GetObjectByKey <AppUser>(SecuritySystem.CurrentUserId));
 }
Esempio n. 2
0
 public void AddUserToAddress(AppUser appUser)
 {
     if (appUser != null && !AppUsers.Contains(appUser))
     {
         AppUsers.Add(appUser);
         appUser.UpdateAddress(this);
     }
 }
Esempio n. 3
0
 public void CreateUser(AppUserEntity appUserEntity)
 {
     AppUsers.Add(appUserEntity);
 }
Esempio n. 4
0
        private async Task GetAppUsers()
        {
            AppUsers.Clear();
            var AppUsersOrdered = new List <User>();

            try
            {
                var users       = (await _userAppService.GetAppUsers()).Users;
                var allAppUsers = await _userAppService.GetAllAppUsers();

                switch (ListType)
                {
                case CarouselBannerType.AveragePiecesForSale:
                    users = users.Count < 6 ? users.OrderByDescending(u => u.AverageItensPerSalePoints).ToList().GetRange(0, users.Count) : users.OrderByDescending(u => u.AverageItensPerSalePoints).ToList().GetRange(0, 5);

                    foreach (var user in users)
                    {
                        user.ListRankingPoints = Formatter.FormatAveragePiecesForSale(user.AverageItensPerSalePoints);
                    }
                    AppUsersOrdered = allAppUsers.Users.OrderByDescending(user => user.AverageItensPerSalePoints).ToList();
                    break;

                case CarouselBannerType.AverageTicket:

                    users = users.Count < 6 ? users.OrderByDescending(u => u.AverageTicketPoints).ToList().GetRange(0, users.Count) : users.OrderByDescending(u => u.AverageTicketPoints).ToList().GetRange(0, 5);

                    foreach (var user in users)
                    {
                        user.ListRankingPoints = Formatter.FormatMoney(user.AverageTicketPoints);
                    }
                    AppUsersOrdered = allAppUsers.Users.OrderByDescending(user => user.AverageTicketPoints).ToList();
                    break;

                case CarouselBannerType.RegisterAlliedFlowers:

                    users = users.Count < 6 ? users.OrderByDescending(u => u.InviteAllyFlowersPoints).ToList().GetRange(0, users.Count) : users.OrderByDescending(u => u.InviteAllyFlowersPoints).ToList().GetRange(0, 5);

                    foreach (var user in users)
                    {
                        user.ListRankingPoints = user.InviteAllyFlowersPoints.ToString();
                    }
                    AppUsersOrdered = allAppUsers.Users.OrderByDescending(user => user.InviteAllyFlowersPoints).ToList();
                    break;

                case CarouselBannerType.RegisterClients:

                    users = users.Count < 6 ? users.OrderByDescending(u => u.RegisterClientsPoints).ToList().GetRange(0, users.Count) : users.OrderByDescending(u => u.RegisterClientsPoints).ToList().GetRange(0, 5);

                    foreach (var user in users)
                    {
                        user.ListRankingPoints = user.RegisterClientsPoints.ToString();
                    }
                    AppUsersOrdered = allAppUsers.Users.OrderByDescending(user => user.RegisterClientsPoints).ToList();
                    break;

                case CarouselBannerType.RegisteredSales:

                    users = users.Count < 6 ? users.OrderByDescending(u => u.SalesNumberPoints).ToList().GetRange(0, users.Count) : users.OrderByDescending(u => u.SalesNumberPoints).ToList().GetRange(0, 5);

                    foreach (var user in users)
                    {
                        user.ListRankingPoints = user.SalesNumberPoints.ToString();
                    }
                    AppUsersOrdered = allAppUsers.Users.OrderByDescending(user => user.SalesNumberPoints).ToList();
                    break;

                case CarouselBannerType.Total:
                    foreach (var user in users)
                    {
                        user.ListRankingPoints = (user.RegisterClientsPoints +
                                                  user.InviteAllyFlowersPoints +
                                                  user.SalesNumberPoints).ToString();
                        user.TotalPoints = (user.RegisterClientsPoints +
                                            user.InviteAllyFlowersPoints +
                                            user.SalesNumberPoints);
                    }

                    users = users.Count < 6 ? users.OrderByDescending(u => u.TotalPoints).ToList().GetRange(0, users.Count) : users.OrderByDescending(u => u.TotalPoints).ToList().GetRange(0, 5);

                    AppUsersOrdered = allAppUsers.Users.OrderByDescending(user => user.TotalPoints).ToList();
                    break;
                }

                foreach (var user in users)
                {
                    AppUsers.Add(user);
                }
            }
            catch
            {
                _userDialogs.Toast("Não foi possível obter os usuários");
                await _navigationService.NavigateAsync(NavigationSettings.MenuPrincipal);
            }


            ThisUser = new User();

            ThisUser = await CacheAccess.GetSecure <User>(CacheKeys.USER_KEY);

            GetThisUserRankingPosition(AppUsersOrdered, ListType);

            AppUsers = FillUserRankingPosition(AppUsers);

            InsertPageTitleAndPoints();
        }