Beispiel #1
0
        //public static SalesContext db = new SalesContext();

        //public static Customer CloneCustomer(Customer SelectedItem)
        //{
        //    using (var db = new SalesContext())
        //    {
        //        var item = db.Customers.Find(SelectedItem.Id);
        //        item.CustomerRank = CustomerRanks.Where(p => p.Id == item.CustomerRankID).Single();
        //        return item;
        //    }
        //}

        #endregion

        #region Asset
        public async static Task GetAllAssets()
        {
            Assets.Clear();
            AssetCategories.Clear();
            using (var db = new SalesContext())
            {
                var result  = await(from c in db.Assets select c).ToListAsync();
                var result1 = await(from c in db.AssetCategories.Include("Assets") select c).ToListAsync();
                var result2 = await(from c in db.Departments.Include("Assets") select c).ToListAsync();
                var result3 = await(from c in db.InstallationLocations.Include("Assets") select c).ToListAsync();
                foreach (Asset item in result)
                {
                    Assets.Add(item);
                }
                foreach (AssetCategory item in result1)
                {
                    AssetCategories.Add(item);
                }
                foreach (Department item in result2)
                {
                    Departments.Add(item);
                }
                foreach (InstallationLocation item in result3)
                {
                    InstallationLocations.Add(item);
                }
            }
        }
Beispiel #2
0
        public async static Task AddInstallationLocation(InstallationLocation itemPara)
        {
            using (var db = new SalesContext())
            {
                db.InstallationLocations.Add(itemPara);
                await UpdateDatabase(db);

                InstallationLocations.Add(itemPara);
            }
        }