public ProductObservableCollection <Product> Build()
        {
            ProductObservableCollection <Product> products = new ProductObservableCollection <Product>();

            var filePath = String.Format("{0}{1}\\ProductModel.xml", AppDomain.CurrentDomain.BaseDirectory,
                                         DBUtility.FilePath);

            List <ProductModel> list = null;

            if (this.checkFileFirst)
            {
                if (!File.Exists(filePath))
                {
                    list = DBUtility.CreateFile <ProductModel>(DBUtility.MockProductModel());
                }
                else
                {
                    list = DBUtility.DeserializeParamsListOf <ProductModel>(filePath);
                }
            }

            if (list != null)
            {
                foreach (ProductModel sp in list)
                {
                    products.Add(sp.ProductModel2Product());
                }
            }


            return(products);
        }
Exemple #2
0
        public UserObservableCollection <UserVM> Build()
        {
            UserObservableCollection <UserVM> users = new UserObservableCollection <UserVM>();

            var filePath = String.Format("{0}{1}\\UserModel.xml", AppDomain.CurrentDomain.BaseDirectory,
                                         DBUtility.FilePath);

            List <UserModel> list = null;

            if (this.checkFileFirst)
            {
                if (!File.Exists(filePath))
                {
                    DBUtility.CreateFile <DeptoModel>(DBUtility.MockDepartment());
                    DBUtility.CreateFile <RoleModel>(DBUtility.MockRoles());
                    list = DBUtility.CreateFile <UserModel>(DBUtility.MockUserModel());
                }
                else
                {
                    list = DBUtility.DeserializeParamsListOf <UserModel>(filePath);
                }
            }

            //list = DBUtility.DeserializeXMLFileOf <List<UserModel>>(filePath);

            if (list != null)
            {
                foreach (UserModel sp in list)
                {
                    users.Add(sp.UserModel2User());
                }
            }


            return(users);
        }