private void LoadList()
 {
     Application.Current.Dispatcher.BeginInvoke(
         new Action(
             delegate
                 {
                     using (var c = NestedContainer)
                     {
                         _pagenatedCommSuppList = Using<ICommoditySupplierRepository>(c).GetAll(CurrentPage,
                                                                                                ItemsPerPage,
                                                                                                SearchText,
                                                                                                ShowInactive);
                         CommoditySupplierList.Clear();
                         _pagenatedCommSuppList.Select((n, i) => Map(n as CommoditySupplier, i)).ToList().ForEach
                             (CommoditySupplierList.Add);
                         UpdatePagenationControl();
                     }
                 }));
 }
示例#2
0
        void LoadUsers()
        {
            using (StructureMap.IContainer c = NestedContainer)
            {
                Users.Clear();
                var myCostCentreId = Using<IConfigService>(c).Load().CostCentreId;
                var ccs = Using<ICostCentreRepository>(c).GetAll().Where(n => n.ParentCostCentre != null);
                ccs=ccs.Where(n => n.ParentCostCentre.Id == myCostCentreId).ToList();
                List<Guid> ccIds = ccs.Select(n => n.Id).ToList();
                ccIds.Add(myCostCentreId);

                var userRepository = Using<IUserRepository>(c);
             
                var users = ccIds.ToList().SelectMany(n => userRepository.GetByCostCentre(n, ShowInactive)).OrderByDescending(p => p.Username);

              PagedList=new PagenatedList<User>(users.AsQueryable(),CurrentPage,ItemsPerPage,users.Count());
                PagedList.Select(MapUser).ToList().ForEach(n => Users.Add(n));
                UpdatePagenationControl();

            }
        }
        private void LoadAgiUsers()
        {
            Application.Current.Dispatcher.BeginInvoke(
                new Action(
                    delegate
                        {
                            using (StructureMap.IContainer c = NestedContainer)
                            {
                                UsersList.Clear();
                                var userList = Using<IUserRepository>(c).GetAll(ShowInactive);
                                if (SelectedUserType == UserType.None)
                                    userList = userList.Where(n =>
                                                              (n.UserType == UserType.AgriHQAdmin ||
                                                               n.UserType == UserType.HubManager ||
                                                               n.UserType == UserType.Clerk ||
                                                               n.UserType == UserType.PurchasingClerk ||
                                                               n.UserType == UserType.Driver)
                                                              && n.Username.ToLower().Contains(SearchText.ToLower())
                                        );
                                else
                                    userList = userList.Where(n => n.UserType == SelectedUserType);
                                userList = userList.OrderBy(n => n.CostCentre)
                                    .ThenBy(n => n.Username);

                                _pagenatedUserList = new PagenatedList<User>(userList.AsQueryable(), CurrentPage,
                                                                             (int) ItemsPerPage,
                                                                             userList.Count());
                                var mappedUserItems = _pagenatedUserList.Select(MapUser);

                                foreach (var user in mappedUserItems)
                                {
                                    if (user.EntityStatus == (int) EntityStatus.Active)
                                        user.HlkDeactivateContent = GetLocalText("sl.users.grid.col.deactivate");
                                            //Deactivate
                                    else if (user.EntityStatus == (int) EntityStatus.Inactive)
                                        user.HlkDeactivateContent = GetLocalText("sl.users.grid.col.activate");
                                    UsersList.Add(user);
                                }
                                UpdatePagenationControl();
                            }
                        }), null);
        }
       protected async virtual void ListOrders()
       {

          await Task.Factory.StartNew(() =>
                                     {
                                         Application.Current.Dispatcher.BeginInvoke(
                                             new Action(delegate
                                                            {
                                                                if (SelectedOrderStatus != DocumentStatus.Confirmed)
                                                                    ShowApproveSelectedButton = Visibility.Collapsed;
                                                                using (var container = NestedContainer)
                                                                {
                                                                    OrdersSummaryList.Clear();
                                                                    if (isUnconfirmedTab)
                                                                    {
                                                                        var orderSaveAndContinueService =
                                                                            Using<IOrderSaveAndContinueService>(
                                                                                container);
                                                                        var item =orderSaveAndContinueService.Query(
                                                                                StartDate, EndDate, SelectedOrderType);
                                                                        IPagenatedList<OrderSaveAndContinueLater> ItemList =
                                                                               new PagenatedList<OrderSaveAndContinueLater>(
                                                                                   item.AsQueryable(), CurrentPage,
                                                                                   ItemsPerPage, item.Count());
                                                                        ItemList.Select(Map).ToList().
                                                                            ForEach(
                                                                                OrdersSummaryList.Add);
                                                                    }
                                                                    else
                                                                    {


                                                                        //var orders = Using<IMainOrderRepository>(
                                                                        //    container)
                                                                        //    .GetMainOrderSummariyList(StartDate, EndDate,
                                                                        //                              SelectedOrderType,
                                                                        //                              SelectedOrderStatus,
                                                                        //                              SearchText);
                                                                        var orders =
                                                                            Using<IMainOrderRepository>(container).
                                                                                PagedDocumentList(CurrentPage,
                                                                                                  ItemsPerPage,
                                                                                                  StartDate, EndDate,
                                                                                                  SelectedOrderType,
                                                                                                  SelectedOrderStatus,
                                                                                                  SearchText);

                                                                     
                                                                        if (orders != null && orders.Any())
                                                                        {
                                                                            PagedDocumentList =
                                                                                new PagenatedList<MainOrderSummary>(
                                                                                    orders.AsQueryable(), CurrentPage,
                                                                                    ItemsPerPage, orders.TotalItemCount,true);
                                                                            PagedDocumentList.Select(Map).ToList().
                                                                                ForEach(
                                                                                    OrdersSummaryList.Add);

                                                                            UpdatePagenationControl();

                                                                        }
                                                                    }
                                                                   

                                                                }
                                                            }));
                                     });


       }
        void LoadContactsFromLocalDb()
        {
           

            using (StructureMap.IContainer c = NestedContainer)
            {
                var contactRepository = Using<IContactRepository>(c);

                var contacts = contactRepository.Query(new QueryStandard()).Data.ToList();
                if (SelectedContactOwner != null)
                {
                    contacts =
                   Using<IContactRepository>(c).GetByContactsOwnerId(SelectedContactOwner.Id, ShowInactive).ToList();
                

                    foreach (var item in contacts)
                    {

                        Contacts.Add(Map(item));

                   } }
                PagedList = new PagenatedList<Contact>(contacts, CurrentPage, ItemsPerPage, contacts.Count());
                Contacts.Clear();
                PagedList.Select(Map).ToList().ForEach(n => Contacts.Add(n));
                UpdatePagenationControl();
            }

        }
示例#6
0
        void LoadPagedRoutes()
        {
            using (StructureMap.IContainer c = NestedContainer)
            {
                _pagedroutes = Using<IRouteRepository>(c).GetAll(CurrentPage, (int) ItemsPerPage, SearchText, ShowInactive);
                var pagedRouteItems = _pagedroutes.Select(Map).ToList();

                Routes.Clear();
                foreach (var item in pagedRouteItems)
                {
                    if (item.EntityStatus == (int)EntityStatus.Active)
                        item.HlkDeactivateContent = GetLocalText("sl.users.grid.col.deactivate"); //Deactivate
                    else if (item.EntityStatus == (int)EntityStatus.Inactive)
                        item.HlkDeactivateContent = GetLocalText("sl.users.grid.col.activate"); //Activate
                    Routes.Add(item);
                    double percent = ((double)Routes.Count * 100) / (double)_pagedroutes.Count();
                    LoadingStatus = "Loading Routes ..." + (int)percent + "%\nPlease wait";
                }
                Loading = false;
            }
        }
        void DoLoadReturns()
        {
            using (var container = NestedContainer)
            {
                var _returnsNoteService = Using<IReturnsNoteRepository>(container);

                Logging.Log("Loading Returns", LOGLEVEL.INFO);
                List<ReturnsNote> returns =
                    _returnsNoteService.GetAll()
                        .OfType<ReturnsNote>()
                        .Where(n => n.ReturnsNoteType == ReturnsNoteType.SalesmanToDistributor)
                        .ToList();


                returns = returns.Where(n => n.Status == SelectedDocumentStatus).ToList();
                             

                PagenatedReturnsList = new PagenatedList<ReturnsNote>(returns.AsQueryable(), CurrentPage,
                                                                      ItemsPerPage,
                                                                      returns.Count());
                ReturnsList.Clear();
                if (PagenatedReturnsList != null && PagenatedReturnsList.Count > 0)
                {
                    var items = PagenatedReturnsList
                        .Select(n => new ListRNItemsViewModel
                                         {
                                             Id = n.Id,
                                             ReturnsDate =
                                                 n.DocumentDateIssued.ToString(
                                                     "dd-MMM-yyyy hh:mm:ss.sss tt"),
                                             SalesMan = n.DocumentIssuerUser.Username
                                         }).ToList();
                    items.ForEach(ReturnsList.Add);

                    UpdatePagenationControl();
                }
               
            }
        }