示例#1
0
 private void OnAddExecute()
 {
     if (SelectedItem != null)
     {
         ListTwo.Add(SelectedItem);
     }
 }
示例#2
0
 private void OnAddExecute(string obj)
 {
     if (SelectedItem != null)
     {
         ListTwo.Add(obj);
     }
 }
示例#3
0
        public void TestMethod2List1()
        {
            //Arrange
            ListTwo <int> l = new ListTwo <int>();

            //Act
            //Assert
            Assert.IsTrue(l.Beg == null);
        }
示例#4
0
        public void TestMethod2List5()
        {
            //Arrange
            ListTwo <int> l = new ListTwo <int>();

            //Act
            l.MakeList(3);
            //Assert
            Assert.IsTrue(l.Length() == 3);
        }
示例#5
0
        public void TestMethod2List2()
        {
            //Arrange
            PointTwo <int> p = new PointTwo <int>(4);
            ListTwo <int>  l = new ListTwo <int>(p);

            //Act
            //Assert
            Assert.IsTrue(l.Length() == 1);
        }
示例#6
0
        public void TestMethod2ListAdd4()
        {
            //Arrange
            Random        rand = new Random();
            ListTwo <int> l    = new ListTwo <int>();

            //Act
            l.Add(1, 3);
            //Assert
            Assert.IsTrue(l.Length() == 3);
        }
示例#7
0
        public void TestMethod2ListDel4()
        {
            //Arrange
            Random        rand = new Random();
            ListTwo <int> l    = new ListTwo <int>();

            //Act
            // l.Add(1,2);
            l.Delete(1, 4);
            //Assert
            Assert.IsTrue(l.Length() == 0);
        }
示例#8
0
        public void TestMethod2ListDel3()
        {
            //Arrange
            Random        rand = new Random();
            ListTwo <int> l    = new ListTwo <int>();

            //Act
            l.Add(1, 3);
            l.Delete(2, 8);
            //Assert
            Assert.IsTrue(l.Length() == 1);
        }
示例#9
0
        public void TestMethod2ListAdd3()
        {
            //Arrange
            Random         rand = new Random();
            PointTwo <int> p    = new PointTwo <int>(4);
            ListTwo <int>  l    = new ListTwo <int>(p);

            //Act
            l.Add(2, rand);
            //Assert
            Assert.IsTrue(l.Length() == 2);
        }
    public override List <ProductPurchaseOutp> ComputeMatches()
    {
        var l2 = ListTwo
                 .GroupBy(l => l.ProductID)
                 .ToDictionary(p => p.Key);

        return(ListOne
               .Select(listOne =>
        {
            decimal wap = 0;
            ProductPurchase minp = null;

            if (l2.TryGetValue(listOne.ProductID, out var matches))
            {
                long qsum = 0;
                decimal psum = 0;
                decimal min = decimal.MaxValue;
                foreach (var m in matches)
                {
                    long quantity = (long)m.Quantity * m.GlobalQuantity;
                    var price = m.Price;
                    qsum += quantity;
                    psum += quantity * price;
                    if (price < min)
                    {
                        minp = m;
                        min = price;
                    }
                }

                if (qsum != 0)
                {
                    wap = psum / qsum;
                }
            }


            return new ProductPurchaseOutp
            {
                ProductID = listOne.ProductID,
                ROQ = listOne.Price,
                RUQ = listOne.Quantity,
                RPQ = listOne.GlobalQuantity,
                RV = listOne.Price * listOne.Quantity * listOne.GlobalQuantity,
                BMPProduct = minp,
                WAP = wap
            };
        })
               .Where(p => p != null)
               .ToList());
    }
示例#11
0
        public void TestList()
        {
            Console.WriteLine($"\n\nListOne: ");
            ListOne list = new ListOne();

            list.Add(1); list.Add(2); list.Add(4);
            list.Print(); Console.WriteLine();
            list.Insert(2, 3);
            list.Print(); Console.WriteLine();
            list.RemoveAt(3); list.RemoveAt(0);
            list.Print(); Console.WriteLine();
            list.Remove(2);
            list.Print();


            Console.WriteLine($"\n\nListOneC: ");
            ListOneC listC = new ListOneC();

            listC.Add(1); listC.Add(2); listC.Add(3); listC.Add(4);
            listC.Print(); Console.WriteLine();
            listC.RemoveAt(3); listC.RemoveAt(0);
            listC.Print(); Console.WriteLine();
            listC.Remove(2);
            listC.Print();

            Console.WriteLine($"\n\nListTwo: ");
            ListTwo listTwo = new ListTwo();

            listTwo.Add(1); listTwo.Add(2); listTwo.Add(4);
            listTwo.Print(); Console.WriteLine();
            listTwo.Insert(2, 3);
            listTwo.Print(); Console.WriteLine();
            listTwo.RemoveAt(3); listTwo.RemoveAt(0);
            listTwo.Print(); Console.WriteLine();
            listTwo.Remove(2);
            listTwo.Print();

            Console.WriteLine($"\n\nListTwoF: ");
            ListTwoF ListTwoF = new ListTwoF();

            ListTwoF.Add(1); ListTwoF.Add(2); ListTwoF.Add(3); ListTwoF.Add(4);
            ListTwoF.Print(); Console.WriteLine();
            ListTwoF.Remove(1);
            ListTwoF.Print(); Console.WriteLine();
            ListTwoF.Remove(2);
            ListTwoF.Print();
        }
示例#12
0
    public override List <ProductPurchaseOutp> ComputeMatches()
    {
        var dicTwo  = ListTwo.ToLookup(z => z.ProductID);
        var matched = (from listOne in ListOne
                       let matches = dicTwo[listOne.ProductID]
                                     let sum = matches.Sum(m => m.Quantity * m.GlobalQuantity)
                                               select new ProductPurchaseOutp
        {
            ProductID = listOne.ProductID,
            ROQ = listOne.Price,
            RUQ = listOne.Quantity,
            RPQ = listOne.GlobalQuantity,
            RV = listOne.Price * listOne.Quantity * listOne.GlobalQuantity,
            BMPProduct = matches.OrderBy(m => m.Price).FirstOrDefault(),
            WAP = sum == 0 ? 0 : matches.Sum(m => m.Quantity * m.GlobalQuantity * m.Price) / sum
        });

        return(matched.ToList());
    }
示例#13
0
        public void MoveItemBetweenList(string listToList)
        {
            if (listToList == "1to2")
            {
                // Move selected item from list 1 to list 2

                AListItemViewModel selectedItem = ListOne.SelectedItem;
                ListOne.RemoveFromList(selectedItem);
                ListTwo.AddToList(selectedItem);
            }

            if (listToList == "2to1")
            {
                // Move selected item from list 2 to list 1

                AListItemViewModel selectedItem = ListTwo.SelectedItem;
                ListTwo.RemoveFromList(selectedItem);
                ListOne.AddToList(selectedItem);
            }
        }
示例#14
0
        public DragAndDropVm()
        {
            ListOne.Add(new DragableData {
                Name = "Steve"
            });
            ListOne.Add(new DragableData {
                Name = "Fred"
            });
            ListOne.Add(new DragableData {
                Name = "Sally"
            });
            ListOne.Add(new DragableData {
                Name = "Hank"
            });
            ListOne.Add(new DragableData {
                Name = "Jane"
            });

            ListTwo.Add(new DragableData {
                Name = "Zach"
            });
        }
示例#15
0
    private IEnumerable <ProductPurchaseOutp> matched()
    {
        var l1 = ListOne
                 .OrderBy(p => p.ProductID);
        var l2 = ListTwo
                 .OrderBy(p => p.ProductID);
        bool eo2 = false;

        using (var en1 = l1.GetEnumerator())
            using (var en2 = l2.GetEnumerator())
            {
                if (!en1.MoveNext())
                {
                    yield break;
                }
                var             cur1 = en1.Current;
                ProductPurchase cur2 = null;
                if (en2.MoveNext())
                {
                    cur2 = en2.Current;
                }
                else
                {
                    eo2 = true;
                }
                do
                {
                    int             ID   = cur1.ProductID;
                    long            qsum = 0;
                    decimal         psum = 0;
                    decimal         min  = decimal.MaxValue;
                    decimal         wap  = 0;
                    ProductPurchase minp = null;
                    while (!eo2 && cur2.ProductID <= ID)
                    {
                        if (cur2.ProductID == ID)
                        {
                            long quantity = (long)cur2.Quantity * cur2.GlobalQuantity;
                            var  price    = cur2.Price;
                            qsum += quantity;
                            psum += quantity * price;
                            if (price < min)
                            {
                                minp = cur2;
                                min  = price;
                            }
                        }
                        if (en2.MoveNext())
                        {
                            cur2 = en2.Current;
                        }
                        else
                        {
                            eo2 = true;
                        }
                    }
                    ;
                    if (qsum != 0)
                    {
                        wap = psum / qsum;
                    }
                    do
                    {
                        yield return(new ProductPurchaseOutp()
                        {
                            ProductID = cur1.ProductID,
                            ROQ = cur1.Price,
                            RUQ = cur1.Quantity,
                            RPQ = cur1.GlobalQuantity,
                            RV = cur1.Price * cur1.Quantity * cur1.GlobalQuantity,
                            BMPProduct = minp,
                            WAP = wap
                        });
                    } while (en1.MoveNext() && (cur1 = en1.Current).ProductID == ID);
                    if (cur1.ProductID == ID)
                    {
                        yield break;
                    }
                } while (true);
            }
    }
示例#16
0
 private void OnDeleteExecuted()
 {
     ListTwo.Clear();
 }