public List <CATEGORY> GetCategoryListByCampaign(int campaignId) { return(_categoryDAO.GetCategoryListByCampaign(campaignId)); }
public void ImportProducts(int CampaignId, string Path) { var productList = ProductExcelImporter.ReadProductExcel(Path); string encryptedCampId = FashionZone.BL.Util.Encryption.Encrypt(CampaignId.ToString()); PRODUCT product; // preparing categories List <CATEGORY> categoriesList = _categoryDAO.GetCategoryListByCampaign(CampaignId); int?categoryParentF = null, categoryParentM = null; CATEGORY cat, categoryParent = null; categoryParent = categoriesList.Where(o => o.NameEng.Contains("Woman")).FirstOrDefault(); if (categoryParent != null) { cat = new CATEGORY() { ID = categoryParent.ID }; categoryParentF = categoryParent.ID; } categoryParent = categoriesList.Where(o => o.NameEng.Contains("Man")).FirstOrDefault(); if (categoryParent != null) { cat = new CATEGORY() { ID = categoryParent.ID }; categoryParentM = categoryParent.ID; } var query = (from c in categoriesList select new { c.ID, c.Name, c.NameEng, c.ParentID }).ToList(); foreach (FZExcelProduct exProd in productList) { product = new PRODUCT(); product.Name = exProd.Title; product.Code = exProd.Code; decimal our, original, suppl = 0; if (Decimal.TryParse(exProd.Sell, out our)) { product.OurPrice = our; } if (Decimal.TryParse(exProd.Retail, out original)) { product.OriginalPrice = original; } if (Decimal.TryParse(exProd.Buy, out suppl)) { product.SupplierPrice = suppl; } product.Description = "Produkti <br /><br />" + exProd.Title + "<br /><br />" + exProd.Desc.Replace("\n", "<br />"); setCategories(CampaignId, query, product, exProd.Category, exProd.Sex, categoryParentF, categoryParentM); // inserting the product entity, we are on a "transaction" so everything will // be rolled back in case the other statements aren't successful Insert(product); setAttributes(categoriesList, product, exProd); setImages(product, exProd, encryptedCampId); } }