Beispiel #1
0
        private void DeleteAtCheck(int id)
        {
            int index = GetIndexByIdInCheck(id);

            FinishSum -= InCheck[index].Price;
            InCheck.RemoveAt(index);
            RewriteCount(GetIndexByIdProducts(id), 1);
        }
Beispiel #2
0
        private void AddToBuy(int id)
        {
            int index = GetIndexByIdProducts(id);

            InCheck.Add(Products[index]);
            FinishSum += Products[index].Price;
            RewriteCount(index, -1);
        }
Beispiel #3
0
        private int GetIndexByIdInCheck(int id)
        {
            int index = 0;
            IEnumerator <Product> iterator = InCheck.GetEnumerator();

            while (iterator.MoveNext())
            {
                if (iterator.Current.Id == id)
                {
                    return(index);
                }

                index++;
            }
            return(-1);
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            InCheck item = new InCheck {
                Filed = "B"
            };

            InCheck checkitem = ExecuteAllCheck(item);

            if (!checkitem.isValid)
            {
                Console.WriteLine($"Execute {checkitem.ErrorRule} Fail");
            }

            Console.WriteLine("Execute Complete");
            Console.ReadLine();
        }
Beispiel #5
0
        public static InCheck ExecuteAllCheck(InCheck item)
        {
            Dictionary <string, Predicate <InCheck> > All_Rule = new StringRule().GetRuleList();

            List <string> ExecuteList = new List <string>();

            ExecuteList.Add("is_null");
            ExecuteList.Add("is_equal_to_A");


            foreach (string Execute_Rule in ExecuteList)
            {
                item.isValid = All_Rule[Execute_Rule](item);

                if (!item.isValid)
                {
                    item.ErrorRule = Execute_Rule;
                }
            }

            return(item);
        }