Пример #1
0
        public override bool Execute()
        {
            if (!Verifier.CheckAmmountElements(AmountElements))
            {
                Information = StringSource.AmmountElementsStructureError();
                return(false);
            }
            Clear();

            return(true);
        }
Пример #2
0
        public override bool Execute()
        {
            if (!Verifier.CheckName(LastName))
            {
                Information = StringSource.NameStructureError();
                return(false);
            }
            if (!Verifier.CheckAmmountElements(AmmountElements))
            {
                Information = StringSource.AmmountElementsStructureError();
                return(false);
            }
            Clear();
            int id = 0;

            using (var localrepos = new DAL.Repositories()) {
                if (IsNext)
                {
                    if (LastElement == null)
                    {
                        id = 0;
                    }
                    else
                    {
                        id = LastElement.CustomerID;
                    }
                    Client      = localrepos.Customers.GetAll(el => el.LastName == LastName && el.CustomerID > id);
                    CurrentList = Client.Take(AmmountElements).ToList();
                }
                else
                {
                    if (FirstElement == null)
                    {
                        id = int.MaxValue;
                    }
                    else
                    {
                        id = FirstElement.CustomerID;
                    }
                    Client = localrepos.Customers.GetAll().OrderByDescending(el => el.CustomerID).
                             Where(el => el.LastName == LastName && el.CustomerID < id);
                    CurrentList = Client.Take(AmmountElements).OrderBy(el => el.CustomerID).ToList();
                }
            }

            if (CurrentList != null && CurrentList.Count > 0)
            {
                FirstElement = CurrentList.First();
                LastElement  = CurrentList.Last();
            }
            else
            {
                FirstElement = null;
                LastElement  = null;
                Information  = StringSource.EndList();
                return(false);
            }

            foreach (var el in CurrentList)
            {
                ClientsInformation.Add(StringSource.ClientInformation(el));
                IdsClients.Add(el.CustomerID);
            }

            Information = StringSource.Successfully();
            return(true);
        }