private void ParseAndAddItemsToList(List <XElement> items, Store store)
        {
            PriceCompareDataAccess dataAccess = new PriceCompareDataAccess();

            foreach (XElement xmlItem in items)
            {
                try
                {
                    Item item = new Item(xmlItem.Element("ItemName").Value.ToString());
                    item.Price         = xmlItem.Element("ItemPrice").Value.ToString();
                    item.Code          = xmlItem.Element("ItemCode").Value.ToString();
                    item.Type          = xmlItem.Element("ItemType").Value.ToString();
                    item.Quantity      = xmlItem.Element("Quantity").Value.ToString();
                    item.UnitOfMeasure = xmlItem.Element("UnitOfMeasure").Value.ToString();
                    item.StoreId       = store.Id;
                    item.StoreId       = dataAccess.GetStoreId(store);
                    itemsDB.Add(item);
                }
                catch (FormatException)
                {
                }
                catch (OverflowException)
                {
                }
            }
        }
 public void Parse()
 {
     itemsDB = new List<Item>();
     foreach (string currentDirectory in Directory.GetDirectories(path))
     {
         StoresDocument storesDocument = GetDataStoresFile(currentDirectory);
         foreach (string currentFile in Directory.GetFiles(currentDirectory))
         {
             if (!currentFile.Contains(@"\Stores"))
             {
                 XDocument xmlDoc = XDocument.Load(currentFile);
                 Store store = AddStoreToDB(xmlDoc, storesDocument);
                 if (store != null)
                 {
                     var items = xmlDoc.Descendants("item").ToList();
                     if (items.Count == 0)
                     {
                         items = xmlDoc.Descendants("Item").ToList();
                     }
                     if (items != null)
                     {
                         ParseAndAddItemsToList(items, store);
                     }
                 }
             }
         }
     }
     PriceCompareDataAccess dataAccess = new PriceCompareDataAccess();
     dataAccess.AddItems(itemsDB);
 }
        public void Parse()
        {
            itemsDB = new List <Item>();
            foreach (string currentDirectory in Directory.GetDirectories(path))
            {
                StoresDocument storesDocument = GetDataStoresFile(currentDirectory);
                foreach (string currentFile in Directory.GetFiles(currentDirectory))
                {
                    if (!currentFile.Contains(@"\Stores"))
                    {
                        XDocument xmlDoc = XDocument.Load(currentFile);
                        Store     store  = AddStoreToDB(xmlDoc, storesDocument);
                        if (store != null)
                        {
                            var items = xmlDoc.Descendants("item").ToList();
                            if (items.Count == 0)
                            {
                                items = xmlDoc.Descendants("Item").ToList();
                            }
                            if (items != null)
                            {
                                ParseAndAddItemsToList(items, store);
                            }
                        }
                    }
                }
            }
            PriceCompareDataAccess dataAccess = new PriceCompareDataAccess();

            dataAccess.AddItems(itemsDB);
        }
Esempio n. 4
0
 public User Login(string name, string password)
 {
     if (((!String.IsNullOrEmpty(name)) && (!String.IsNullOrEmpty(password))))
     {
         PriceCompareDataAccess dataAccess = new PriceCompareDataAccess();
         List <User>            users      = dataAccess.GetAllUsers().Where(user => user.Name.Equals(name) && user.Password.Equals(password)).ToList();
         if (users.Count == 1)
         {
             return(users.First());
         }
     }
     return(null);
 }
Esempio n. 5
0
 public User AddUser(string name, string password)
 {
     if (((!String.IsNullOrEmpty(name)) && (!String.IsNullOrEmpty(password))))
     {
         PriceCompareDataAccess dataAccess = new PriceCompareDataAccess();
         List <User>            users      = dataAccess.GetAllUsers().Where(user => user.Name.Equals(name)).ToList();
         if (users.Count == 0)
         {
             User newUser = new User(name, password);
             dataAccess.AddUser(newUser);
             return(newUser);
         }
     }
     return(null);
 }
 public User AddUser(string name, string password)
 {
     if (((!String.IsNullOrEmpty(name)) && (!String.IsNullOrEmpty(password))))
     {
         PriceCompareDataAccess dataAccess = new PriceCompareDataAccess();
         List<User> users = dataAccess.GetAllUsers().Where(user => user.Name.Equals(name)).ToList();
         if (users.Count == 0)
         {
             User newUser = new User(name, password);
             dataAccess.AddUser(newUser);
             return newUser;
         }
     }
     return null;
 }
 private Store AddStoreToDB(XDocument xmlDoc, StoresDocument storesDocument)
 {
     Store store = null;
     if(storesDocument != null)
     {
         string storeId = xmlDoc.Element("Root").Element("StoreId").Value.ToString();
         string name = storesDocument.Stores[storeId];
         if (name != null)
         {
             store = new Store(name);
             store.ChainStoreName = storesDocument.ChainStoresName;
             PriceCompareDataAccess dataAccess = new PriceCompareDataAccess();
             dataAccess.AddStore(store);
         }
     }
     return store;
 }
        private Store AddStoreToDB(XDocument xmlDoc, StoresDocument storesDocument)
        {
            Store store = null;

            if (storesDocument != null)
            {
                string storeId = xmlDoc.Element("Root").Element("StoreId").Value.ToString();
                string name    = storesDocument.Stores[storeId];
                if (name != null)
                {
                    store = new Store(name);
                    store.ChainStoreName = storesDocument.ChainStoresName;
                    PriceCompareDataAccess dataAccess = new PriceCompareDataAccess();
                    dataAccess.AddStore(store);
                }
            }
            return(store);
        }
        private void ParseAndAddItemsToList(List<XElement> items, Store store)
        {
            PriceCompareDataAccess dataAccess = new PriceCompareDataAccess();
            foreach (XElement xmlItem in items)
            {
                try
                {
                    Item item = new Item(xmlItem.Element("ItemName").Value.ToString());
                    item.Price = xmlItem.Element("ItemPrice").Value.ToString();
                    item.Code = xmlItem.Element("ItemCode").Value.ToString();
                    item.Type = xmlItem.Element("ItemType").Value.ToString();
                    item.Quantity = xmlItem.Element("Quantity").Value.ToString();
                    item.UnitOfMeasure = xmlItem.Element("UnitOfMeasure").Value.ToString();
                    item.StoreId = store.Id;
                    item.StoreId = dataAccess.GetStoreId(store);
                    itemsDB.Add(item);
                }
                catch(FormatException)
                {

                }
                catch(OverflowException)
                {

                }
            }
        }
Esempio n. 10
0
        public List <Item> GetItemsByStoreId(long storeId)
        {
            PriceCompareDataAccess dataAccess = new PriceCompareDataAccess();

            return(dataAccess.GetItemsByStoreId(storeId));
        }
Esempio n. 11
0
        public List <Store> GetAllStores()
        {
            PriceCompareDataAccess dataAccess = new PriceCompareDataAccess();

            return(dataAccess.GetAllStores());
        }
 public User Login(string name, string password)
 {
     if(((!String.IsNullOrEmpty(name)) && (!String.IsNullOrEmpty(password))))
     {
         PriceCompareDataAccess dataAccess = new PriceCompareDataAccess();
         List<User> users = dataAccess.GetAllUsers().Where(user => user.Name.Equals(name) && user.Password.Equals(password)).ToList();
         if (users.Count == 1)
         {
             return users.First();
         }
     }
     return null;
 }
 public List<Item> GetItemsByStoreId(long storeId)
 {
     PriceCompareDataAccess dataAccess = new PriceCompareDataAccess();
     return dataAccess.GetItemsByStoreId(storeId);
 }
 public List<Store> GetAllStores()
 {
     PriceCompareDataAccess dataAccess = new PriceCompareDataAccess();
     return dataAccess.GetAllStores();
 }