private async Task LoadClientAsync(Guid id)
        {
            try
            {
                IsBusy = true;

                Client = await AsyncFake.CallAsync(ClientBL, x => x.GetClient(id));

                // Initialize IsPurchaseDeletable
                if (Client.Purchases != null)
                {
                    DateTime?lastVoucherIssueDate = Client.LastVoucherIssueDate;
                    if (lastVoucherIssueDate.HasValue)
                    {
                        foreach (Purchase purchase in Client.Purchases)
                        {
                            purchase.IsPurchaseDeletable = purchase.Date > lastVoucherIssueDate.Value;
                        }
                    }
                    else
                    {
                        foreach (Purchase purchase in Client.Purchases)
                        {
                            purchase.IsPurchaseDeletable = true;
                        }
                    }
                }

                // Initialize input fields
                _automaticCitySearch = false; // desactivate while filling client fields
                LastName             = Client.LastName;
                FirstName            = Client.FirstName;
                BirthDate            = Client.BirthDate;
                Email        = Client.Email;
                Mobile       = Client.Mobile;
                StreetName   = Client.StreetName;
                StreetNumber = Client.StreetNumber;
                ZipCode      = Client.ZipCode;
                City         = Client.City;
                Comment      = Client.Comment;
                Sex          = Client.Sex;
                foreach (ClientCategoryModel categoryModel in Categories)
                {
                    categoryModel.IsSelected = Client.Categories?.Contains(categoryModel.Category) == true;
                }
                _automaticCitySearch = true;
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);
                PopupService.DisplayQuestion("Ouverture client", "Le client n'a pu être chargé.");
                Mediator.Default.Send(new SwitchToSearchClientMessage()); // Switch back to Search Client
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #2
0
        private async Task SearchWeekBestClientAsync()
        {
            DateTime weekStart = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek);
            DateTime weekEnd   = weekStart.AddDays(7).AddSeconds(-1);

            BestClient bestClient = await AsyncFake.CallAsync(StatisticsBL, x => x.GetBestClientInPeriod(weekStart, weekEnd));

            WeekBestClient      = bestClient?.Client;
            WeekBestClientTotal = bestClient?.Amount;
        }
Exemple #3
0
        private async Task CountAverageAmountByAgeAsync()
        {
            var averageAmountByAgeCategories = (await AsyncFake.CallAsync(StatisticsBL, x => x.GetClientAverageAmountByAgeCategory()))
                                               .OrderBy(x => x.Key);
            SeriesCollection collection = new SeriesCollection
            {
                new ColumnSeries
                {
                    Title  = "Montant moyen",
                    Values = new ChartValues <decimal>(averageAmountByAgeCategories.Select(x => x.Value))
                }
            };

            AverageAmountByAgeLabels = averageAmountByAgeCategories.Select(x => x.Key.DisplayName()).ToList();
            AverageAmountByAgeSeries = collection;
        }
        private async Task SearchAsync()
        {
            try
            {
                IsBusy = true;

                List <ClientSummary> clients = await AsyncFake.CallAsync(ClientBL, x => x.SearchClientSummaries(Filter));

                Clients = new ObservableCollection <ClientSummary>(clients);
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #5
0
        private async Task CountClientByAgeRangeAsync()
        {
            var clientCountByAgeCategories = await AsyncFake.CallAsync(StatisticsBL, x => x.GetClientCountByAgeCategory());

            SeriesCollection collection = new SeriesCollection();

            foreach (var data in clientCountByAgeCategories.OrderBy(x => x.Key))
            {
                collection.Add(new PieSeries
                {
                    Title  = data.Key.DisplayName(),
                    Values = new ChartValues <int> {
                        data.Value
                    },
                    DataLabels = true,
                    LabelPoint = GenericChartLabelPercentagePointFunction
                });
            }
            ClientByAgeRangeSeries = collection;
        }
Exemple #6
0
        private async Task RefreshAsync()
        {
            try
            {
                IsBusy = true;

                FooterInformations infos = await AsyncFake.CallAsync(StatisticsBL, x => x.GetFooterInformations());

                TotalClientCount    = infos.TotalClientCount;
                TotalNewClientCount = infos.TotalNewClientCount;
                DaySales            = infos.DaySales;
                WeekSales           = infos.WeekSales;
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }