コード例 #1
0
        public static void Update(DetailProductModel product)
        {
            var target = One(p => p.ProductID == product.ProductID);

            if (target != null)
            {
                target.ProductID    = product.ProductID;
                target.ProductName  = product.ProductName;
                target.UnitPrice    = (decimal)product.UnitPrice;
                target.UnitsInStock = product.UnitsInStock;
                target.Discontinued = product.Discontinued;
                target.Category     = new CategoryModel()
                {
                    CategoryID = product.Category.CategoryID, CategoryName = product.Category.CategoryName
                };
                target.Country = new CountryModel()
                {
                    CountryID = product.Country.CountryID, CountryNameShort = product.Country.CountryNameShort, CountryNameLong = product.Country.CountryNameLong
                };
                target.CategoryID      = product.CategoryID;
                target.CountryID       = product.CountryID;
                target.CustomerRating  = product.CustomerRating;
                target.LastSupply      = product.LastSupply;
                target.QuantityPerUnit = product.QuantityPerUnit;
                target.TargetSales     = product.TargetSales;
                target.UnitsOnOrder    = product.UnitsOnOrder;
            }
        }
コード例 #2
0
        public static void Delete(DetailProductModel product)
        {
            var target = One(p => p.ProductID == product.ProductID);

            if (target != null)
            {
                All().Remove(target);
            }
        }
コード例 #3
0
        public static void Insert(DetailProductModel product)
        {
            var first = All().OrderByDescending(p => p.ProductID).FirstOrDefault();

            if (first != null)
            {
                product.ProductID = first.ProductID + 1;
            }
            else
            {
                product.ProductID = 0;
            }

            All().Insert(0, product);
        }