Example #1
0
 protected void egvBrands_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         ProductBrand brand     = e.Row.DataItem as ProductBrand;
         Image        brandLogo = e.Row.FindControl("BrandLogo") as Image;
         if (brandLogo != null)
         {
             if (brand.File != null)
             {
                 brandLogo.ImageUrl = SiteUrlManager.GetResizedImageUrl(brand.File, (int)brandLogo.Width.Value, (int)brandLogo.Height.Value);
             }
             else
             {
                 brandLogo.ImageUrl = SiteUrlManager.GetNoPictureUrl((int)brandLogo.Width.Value, (int)brandLogo.Height.Value);
             }
         }
         HyperLink hyName = e.Row.FindControl("hlBrandName") as HyperLink;
         if (hyName != null)
         {
             hyName.Text        = brand.BrandName;
             hyName.NavigateUrl = GlobalSettings.RelativeWebRoot + "controlpanel/controlpanel.aspx?product-product&bi=" + brand.BrandID;
         }
     }
 }
        public static async Task SeedAsync(ApplicationDbContext dbContext, ILoggerFactory loggerFactory)
        {
            try
            {
                if (!dbContext.ProductTypes.Any())
                {
                    var typesData = File.ReadAllText("../Infrastructure/Data/SeedData/types.json");

                    var types = JsonSerializer.Deserialize <List <ProductType> >(typesData);

                    foreach (var item in types)
                    {
                        var tmp = new ProductType()
                        {
                            Name = item.Name
                        };
                        dbContext.ProductTypes.Add(tmp);
                    }

                    await dbContext.SaveChangesAsync();
                }

                if (!dbContext.ProductBrands.Any())
                {
                    var brandsData = File.ReadAllText("../Infrastructure/Data/SeedData/brands.json");

                    var brands = JsonSerializer.Deserialize <List <ProductBrand> >(brandsData);

                    foreach (var item in brands)
                    {
                        var tmp = new ProductBrand()
                        {
                            Name = item.Name
                        };
                        dbContext.ProductBrands.Add(tmp);
                    }

                    await dbContext.SaveChangesAsync();
                }

                if (!dbContext.Products.Any())
                {
                    var productsData = File.ReadAllText("../Infrastructure/Data/SeedData/products.json");

                    var products = JsonSerializer.Deserialize <List <Product> >(productsData);

                    foreach (var item in products)
                    {
                        dbContext.Products.Add(item);
                    }

                    await dbContext.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                var logger = loggerFactory.CreateLogger <ApplicationDbContextSeed>();
                logger.LogError(ex.Message);
            }
        }
Example #3
0
        public void TestProductBrandGetHashcode()
        {
            ProductBrand brandA = new ProductBrand()
            {
                value = "google"
            };

            ProductBrand brandATitleCase = new ProductBrand()
            {
                value = "Google"
            };

            ProductBrand brandB = new ProductBrand()
            {
                value = "google"
            };

            ProductBrand brandC = new ProductBrand()
            {
                value = "motorola"
            };

            Assert.AreEqual(comparer.GetHashCode(brandA), comparer.GetHashCode(brandB));
            Assert.AreNotEqual(comparer.GetHashCode(brandA), comparer.GetHashCode(brandC));

            // Case of value is ignored.
            Assert.AreEqual(comparer.GetHashCode(brandA), comparer.GetHashCode(brandATitleCase));
        }
        public IEnumerable <ProductBrand> GetBrand(int?BrandID)
        {
            List <ProductBrand> productBrands = new List <ProductBrand>();

            if (BrandID == null)
            {
                command = new SqlCommand("SELECT * FROM [ViewBrands]", connection);
            }
            else
            {
                command = new SqlCommand("SELECT * FROM [ViewBrands] WHERE BrandID = '" + BrandID + "'", connection);
            }

            connection.Open();

            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    ProductBrand productBrand = new ProductBrand((int)Convert.ToInt64(reader["BrandID"]),
                                                                 (String)reader["BrandName"]);
                    productBrands.Add(productBrand);
                }
            }

            connection.Close();

            return(productBrands);
        }
Example #5
0
        public async Task <IActionResult> PutProductBrand([FromRoute] int id, [FromBody] ProductBrand productBrand)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != productBrand.ProductBrandId)
            {
                return(BadRequest());
            }

            _context.Entry(productBrand).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductBrandExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
    void BindData()
    {
        if (brandID != 0)
        {
            btnPost.Text = "更新";
        }
        ProductBrand brand = ProductBrands.GetProductBrand(brandID);

        if (brand == null)
        {
            brand = new ProductBrand();
        }

        this.txtBrandAbstract.Text = brand.BrandAbstract;
        this.txtBrandContent.Text  = brand.BrandContent;
        if (!string.IsNullOrEmpty(brand.BrandGroup))
        {
            ddlBrandGroup.SelectedItem.Selected = false;
            ddlBrandGroup.Items.FindByText(brand.BrandGroup).Selected = true;
        }
        this.txtBrandName.Text    = brand.BrandName;
        this.txtBrandTitle.Text   = brand.BrandTitle;
        this.txtDisplayOrder.Text = brand.DisplayOrder.ToString();
        csBrand.SelectedValue     = brand.BrandStatus;
        if (brand.File != null)
        {
            this.imgLogo.ImageUrl = SiteUrlManager.GetResizedImageUrl(brand.File, (int)imgLogo.Width.Value, (int)imgLogo.Height.Value);
        }
        else
        {
            this.imgLogo.ImageUrl = SiteUrlManager.GetNoPictureUrl((int)imgLogo.Width.Value, (int)imgLogo.Height.Value);
        }
    }
Example #7
0
        public async Task <ResponseViewModel> Create(int id, [FromBody] API.Models.Brand.BrandCriteriaModel model)
        {
            //var oldBrand = await _brandService.GetByIdWithoutInclude(model.GetByIdWithoutInclude);
            var oldBrand = await _brandService.GetById(id);

            if (oldBrand != null)
            {
                var response = new ResponseViewModel
                {
                    Result = false,
                };

                response.Messages.Add("Tên nhãn hiệu đã tồn tại");

                return(response);
            }
            else
            {
                var productBrand = new ProductBrand
                {
                    ProductBrandName = model.BrandName,
                };

                ApplyUserCreateEntity(productBrand);

                return(await SaveOrUpdate(productBrand));
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Admin_Id,Name,DateCreate,DateModify")] ProductBrand productBrand)
        {
            if (id != productBrand.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(productBrand);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductBrandExists(productBrand.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("ProductBrandsOverview", "Admin"));
            }
            ViewData["Admin_Id"] = new SelectList(_context.Admins, "Id", "Email", productBrand.Admin_Id);
            return(View(productBrand));
        }
Example #9
0
 public ProductBrandListViewModel(IShoppingSystemSettingsService shoppingSystemSettingsService, SainaDbContext uow)
 {
     _shoppingSystemSettingsService = shoppingSystemSettingsService;
     AddBrandCommand = new RelayCommand(OnAddProduct);
     ProductBrand    = new ProductBrand();
     _uow            = uow;
 }
Example #10
0
        /// <summary>
        /// 品牌信息页面
        /// </summary>
        /// <param name="user"></param>
        /// <param name="entity"></param>
        /// <param name="imgmsg"></param>
        /// <returns></returns>
        public IActionResult BrandForm(SysUser user, ProductBrand entity, string imgmsg)
        {
            if (NHttpContext.Current.Request.IsAjaxRequest())
            {
                //获取状态
                StateCode state = ServiceIoc.Get <ProductBrandService>().Save(user.id, entity, imgmsg);
                return(Json(GetResult(state)));
            }
            else
            {
                ViewBag.Ticket = StringHelper.GetEncryption(ImgType.Product_Brand + "#" + bid);
                ViewBag.defurl = ResXmlConfig.Instance.DefaultImgSrc(AppGlobal.Res, ImgType.Product_Brand);
                ViewBag.imgurl = ViewBag.imgurl;

                entity = ServiceIoc.Get <ProductBrandService>().GetById(bid);
                if (entity != null)
                {
                    Img img = ServiceIoc.Get <ImgService>().GetImg(ImgType.Product_Brand, entity.id);
                    if (img != null)
                    {
                        ViewBag.imgurl = string.IsNullOrEmpty(img.getImgUrl()) ? ViewBag.defimgurl : img.getImgUrl();
                    }
                    ViewBag.entity = JsonConvert.SerializeObject(entity);
                }
            }

            return(View());
        }
        public ActionResult SearchProduct(string q)
        {
            ViewBag.SearchProduct = q;

            var brands      = ProductBrand.All(b => b.Name.Contains(q));
            var products    = Product.All();
            var inventories = Inventory.All();

            //joins brands to products
            var QueryProducts = from brand in brands
                                join pp in products
                                on brand.Id equals pp.BrandId
                                select pp;

            //joins inventory to products
            var QueryInventory = from prod in QueryProducts
                                 join inven in inventories
                                 on prod.Id equals inven.ProductId
                                 select inven;

            //pagination
            Pagination <Inventory> pagination = new Pagination <Inventory>(QueryInventory, 1);

            ViewBag.TotalPages = pagination.TotalPages;
            //pagination end

            //sets model
            IEnumerable <InventoryDisplayViewModel> model = pagination.GetPaginatedResult().Select(p => new InventoryDisplayViewModel(p));

            return(View("display", model));
        }
 public CustomResult ChangeLockProductBrand(int id)
 {
     try
     {
         ProductBrand productBrand = db.ProductBrands.Find(id);
         if (productBrand == null)
         {
             return(new CustomResult(CustomResultType.NotExisted, "This Product Brand doesn't exist"));
         }
         if (ModelState.IsValid(productBrand))
         {
             productBrand.IsActive = !productBrand.IsActive;
             db.Set <ProductBrand>().AddOrUpdate(productBrand);
             db.SaveChanges();
             return(new CustomResult(CustomResultType.Succeed));
         }
         else
         {
             return(new CustomResult(CustomResultType.InvalidModelState));
         }
     }
     catch (Exception ex)
     {
         return(new CustomResult(CustomResultType.UnexpectedError, ex.Message));
     }
 }
Example #13
0
        public ActionResult AddBrandTitle(string title)
        {
            var re  = new OpResult();
            var obj = new ProductBrand();

            obj.CompanyId = CommonService.CompanyId;
            var source = ProductBrandService.Find(o => o.CompanyId == obj.CompanyId && o.Title == title);

            if (source != null)
            {
                re = OpResult.Success(source.BrandSN.ToString());
            }
            else
            {
                obj.Title   = title;
                obj.BrandSN = ProductBrandService.MaxSN;
                obj.State   = 1;
                re          = ProductBrandService.Add(obj);
                if (re.Successed)
                {
                    re.Message = obj.BrandSN.ToString();
                }
                #region 操作日志
                try
                {
                    var logMsg = LogEngine.CompareModelToLog <ProductBrand>(LogModule.品牌管理, obj);
                    logEngine.WriteInsert(logMsg, LogModule.品牌管理);
                }
                catch
                {
                }
                #endregion
            }
            return(Content(re.ToJson()));
        }
    public override void OnPageLoaded()
    {
        string brandName = string.Empty, brandGroup = string.Empty, brandAbstract = string.Empty;
        string id = Request.QueryString["ID"];

        if (!string.IsNullOrEmpty(id))
        {
            int          brandId = int.Parse(GlobalSettings.Decrypt(id));
            ProductBrand pb      = ProductBrands.GetProductBrand(brandId);
            if (null != pb)
            {
                brandName     = pb.BrandName;
                brandGroup    = pb.BrandGroup;
                brandAbstract = pb.BrandAbstract;
            }
        }

        if (string.IsNullOrEmpty(brandName))
        {
            brandName = "所有品牌";
            this.AddKeywords(brandName);
            this.AddDescription("分组显示所有品牌列表,选择品牌导航到对应品牌的产品列表。");
            this.ShortTitle = brandName;
        }
        else
        {
            this.AddKeywords(string.Format("{0},{1}", brandName, brandGroup));
            this.AddDescription(string.Format("显示{0}品牌的产品列表。{1}{2}", brandName, brandAbstract, string.Format(" 关键字: {0},{1}", brandName, brandGroup)));
            this.ShortTitle = brandName + " - " + brandGroup;
        }
        this.SetTitle();


        this.AddJavaScriptInclude("scripts/pages/sortby.aspx.js", false, false);
    }
Example #15
0
        public ActionResult Add(ProductBrandAddEditViewModel formData)
        {
            ProductBrand brand = new ProductBrand()
            {
                Name = formData.Name,
            };

            if (!brand.Exists())
            {
                brand.Add();
                return(RedirectToAction("Add"));
            }
            else
            {
                string        message   = "An Error occured when trying to add new brand.";
                List <string> solutions = new List <string>();
                solutions.Add("Brand Already exists");
                ErrorHelp error = new ErrorHelp()
                {
                    Message   = message,
                    Solutions = solutions
                };

                return(View("_ErrorView", error));
            }
        }
Example #16
0
 public IActionResult ProductBrandEdit(int id)
 {
     if (IsLogedIn() == true)
     {
         ProductBrand edit = _context.ProductBrands.Where(p => p.Id == id).FirstOrDefault();
         if (edit != null)
         {
             AdminProductBrandEditViewModel vm = new AdminProductBrandEditViewModel()
             {
                 ProductBrand  = edit,
                 ProductBrands = _context.ProductBrands.OrderBy(p => p.Name).ToList(),
                 Products      = _context.Products.ToList()
             };
             return(View(vm));
         }
         else
         {
             return(RedirectToAction("ProductBrandsOverview"));
         }
     }
     else
     {
         return(RedirectToAction("Login"));
     }
 }
Example #17
0
        public async Task <IActionResult> Create(ProductBrand productBrand, IFormFile limg)
        {
            if (ModelState.IsValid)
            {
                var bname = await _context.ProductBrand.FirstOrDefaultAsync(a => a.Name == productBrand.Name);

                if (bname == null)
                {
                    if (limg != null == limg.Length > 0)
                    {
                        string brandimgPath   = _env.WebRootPath + "/brands/";
                        string FileUniqueName = Guid.NewGuid().ToString() + Path.GetExtension(limg.FileName);
                        await limg.CopyToAsync(new FileStream(brandimgPath + FileUniqueName, FileMode.CreateNew));

                        productBrand.Logo = FileUniqueName;
                    }
                    productBrand.Status      = "Active";
                    productBrand.CreatedDate = DateTime.Now;
                    _context.Add(productBrand);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            return(View(productBrand));
        }
        private static void AddProductBrand(IProductCommand command, Product product)
        {
            if (command.ProductBrand.Name == null)
            {
                return;
            }

            var brand = new ProductBrand
            {
                Name         = command.ProductBrand.Name,
                CreationDate = DateTime.Now,
                Creator      = command.UserIdentity.Email
            };

            if (command.ProductBrand.IsNew)
            {
                product.ProductBrand = brand;
                //product.ProductCategory = new ProductCategory();
                //product.ProductCategory.AddBrand(brand);
            }
            else
            {
                product.Brand = command.ProductBrand.Name;
            }
        }
Example #19
0
        public void TestChildNodeBasicFunctionality()
        {
            rootNode = rootNode.AsSubdivision();
            Assert.False(rootNode.IsUnit, "Parent should not be a unit.");
            Assert.True(rootNode.IsSubdivision, "Parent should be a subdivision.");
            ProductBrand         childDimension = ProductDimensions.CreateBrand("google");
            ProductPartitionNode childNode      = rootNode.AddChild(childDimension);

            Assert.AreSame(childDimension, childNode.Dimension,
                           "Child node merely wraps the " + "underlying dimension node.");
            Assert.AreSame(rootNode, childNode.Parent, "child.GetParent should return parentNode.");
            Assert.That(childNode.ProductPartitionId == 0, "Partition ID is incorrect.");

            Assert.That(childNode.Children.Count() == 0, "ChildNode should not have any children.");
            Assert.True(childNode.IsUnit, "New node should be a unit node by default.");
            Assert.True(childNode.IsBiddableUnit,
                        "New node should be a biddable unit node by default.");

            Assert.That(rootNode.HasChild(childDimension),
                        "rootNode.HasChild should return true when " +
                        "passed the dimension of the added child");
            Assert.False(rootNode.HasChild(ProductDimensions.CreateBrand("xyz")),
                         "rootNode.HasChild " +
                         "should return false when passed a dimension for a nonexistent child");
            Assert.False(rootNode.HasChild(null),
                         "rootNode.HasChild should return false when passed " +
                         "a dimension for a nonexistent child");
        }
Example #20
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Logo,Website,Description,Status,CreatedDate,CreatedBy,ModifiedDate,ModifiedBy")] ProductBrand productBrand)
        {
            if (id != productBrand.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(productBrand);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductBrandExists(productBrand.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(productBrand));
        }
Example #21
0
        public IActionResult ProductBrandDelete(int id)
        {
            if (IsLogedIn() == true)
            {
                ProductBrand delete = _context.ProductBrands.Where(p => p.Id == id).FirstOrDefault();
                if (delete != null)
                {
                    // Xóa tất cả sản phẩm
                    // Lý do không đổi ProductBrand_Id = 0 vì đó là khóa ngoại
                    // mà Microsoft thì không cho phép gán khóa ngoại cho giá trị không tồn tại

                    List <Product> products = _context.Products.Where(p => p.ProductBrand_Id == id).ToList();
                    foreach (Product product in products)
                    {
                        RemoveProduct(product);
                    }

                    // Xóa nhãn hàng sau khi đã xóa tất cả sản phẩm liên quan
                    _context.ProductBrands.Remove(delete);
                    _context.SaveChanges();
                }
                return(RedirectToAction("ProductBrandsOverview"));
            }
            else
            {
                return(RedirectToAction("Login"));
            }
        }
Example #22
0
        public JsonResult ProductBrands(int categoryId)
        {
            IEnumerable <int>          brandIds = Product.All(p => p.CategoryId == categoryId).Select(item => item.BrandId).Distinct();
            IEnumerable <ProductBrand> brands   = brandIds.Select(brandId => ProductBrand.GetById(brandId));

            return(Json(brands.Select(c => new { text = c.Name, value = c.Id }), JsonRequestBehavior.AllowGet));
        }
Example #23
0
 public IActionResult ProductBrandEdit(AdminProductBrandEditViewModel vm)
 {
     if (IsLogedIn() == true)
     {
         if (ModelState.IsValid)
         {
             ProductBrand data = vm.ProductBrand;
             ProductBrand up   = _context.ProductBrands.Where(p => p.Id == data.Id).FirstOrDefault();
             up.Name       = data.Name;
             up.DateModify = DateTime.Now;
             _context.SaveChanges();
         }
         return(View(
                    new AdminProductBrandEditViewModel()
         {
             ProductBrand = vm.ProductBrand,
             ProductBrands = _context.ProductBrands.OrderBy(p => p.Name).ToList(),
             Products = _context.Products.ToList()
         }
                    ));
     }
     else
     {
         return(RedirectToAction("Login"));
     }
 }
 public CustomResult EditProductBrand(ProductBrand brand)
 {
     try
     {
         if (db.ProductBrands.Find(brand.Id) == null)
         {
             return(new CustomResult(CustomResultType.NotExisted, "Can't find this ID to edit"));
         }
         if (db.ProductBrands.FirstOrDefault(c => c.Name == brand.Name &&
                                             c.Id != brand.Id) != null)
         {
             return(new CustomResult(CustomResultType.Existed, "This Product Brand exists"));
         }
         if (ModelState.IsValid(brand))
         {
             db.Set <ProductBrand>().AddOrUpdate(brand);
             db.SaveChanges();
             return(new CustomResult(CustomResultType.Succeed));
         }
         else
         {
             return(new CustomResult(CustomResultType.InvalidModelState));
         }
     }
     catch (Exception ex)
     {
         return(new CustomResult(CustomResultType.UnexpectedError, ex.Message));
     }
 }
Example #25
0
        public void TestProductBrandEquals()
        {
            ProductBrand brandA = new ProductBrand()
            {
                value = "google"
            };

            ProductBrand brandATitleCase = new ProductBrand()
            {
                value = "Google"
            };

            ProductBrand brandB = new ProductBrand()
            {
                value = "google"
            };

            ProductBrand brandC = new ProductBrand()
            {
                value = "motorola"
            };

            ProductBrand brandD = new ProductBrand();
            ProductBrand brandE = new ProductBrand();

            Assert.True(comparer.Equals(brandA, brandB));
            Assert.False(comparer.Equals(brandA, brandC));

            // Case of value is ignored.
            Assert.True(comparer.Equals(brandA, brandATitleCase));

            //Null value is handled gracefully.
            Assert.False(comparer.Equals(brandA, brandD));
            Assert.True(comparer.Equals(brandD, brandE));
        }
 public ProductBrandDto MapperToProductBrandDto(ProductBrand productBrand)
 {
     return(new ProductBrandDto
     {
         Id = productBrand.Id,
         Name = productBrand.Name
     });
 }
        public ActionResult DeleteConfirmed(int id)
        {
            ProductBrand productbrand = db.productBrand.Find(id);

            db.productBrand.Remove(productbrand);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #28
0
    protected void Button33_Click(object sender, EventArgs e)
    {
        ProductBrand brand = ProductBrands.GetProductBrand(10);

        Image1.ImageUrl        = SiteUrlManager.GetResizedImageUrl(brand.File, 80, 80);
        HyperLink2.NavigateUrl = brand.Url;
        HyperLink2.Text        = brand.BrandLogo;
    }
        public async Task <ProductBrand> CreateProductBrandAsync(ProductBrand productBrand)
        {
            var result = await _storeContext.ProductBrands.AddAsync(productBrand);

            await _storeContext.SaveChangesAsync();

            return(result.Entity);
        }
Example #30
0
        public async Task <ActionResult <ProductBrand> > CreateBrand(ProductBrand brand)
        {
            var brands = await _uom.productBrandRepository.CreateAsync(brand);

            await _uom.completedTask();

            return(brands);
        }
Example #31
0
        internal static void Products()
        {
            int productbrandcount = 0;
            int productsubbrandcount = 0;
            int productcount = 1;

            bool boolSessionBegun = false;
            QBSessionManager sessionManager = new QBSessionManager();
            try
            {
                IMsgSetRequest requestMsgSet;
                IMsgSetResponse responseMsgSet;
                sessionManager.OpenConnection("", _appName);
                sessionManager.BeginSession(qdbpath, ENOpenMode.omDontCare);
                boolSessionBegun = true;
                requestMsgSet = GetLatestMsgSetRequest(sessionManager);
                requestMsgSet.Attributes.OnError = ENRqOnError.roeStop;
               // ISalesTaxCodeRetList
                IItemInventoryQuery itemInventoryQ = requestMsgSet.AppendItemInventoryQueryRq();
               
                responseMsgSet = sessionManager.DoRequests(requestMsgSet);
                
               
                IResponse response = responseMsgSet.ResponseList.GetAt(0);
                IItemInventoryRetList itemInventoryRetList = response.Detail as IItemInventoryRetList;
                List<ProductImport> items= new List<ProductImport>();
                List<ProductPricing> pricings=new List<ProductPricing>();
                 List<Packaging> packagings=new List<Packaging>();
                List<ProductBrand> brands=new List<ProductBrand>();
                if (itemInventoryRetList != null && itemInventoryRetList.Count > 0)
                {
                   
                    for (var i = 0; i < itemInventoryRetList.Count; i++)
                    {
                        IItemInventoryRet inventoryRet = itemInventoryRetList.GetAt(i);
                        if(!inventoryRet.Sublevel.IsSet())
                        {
                            productbrandcount++;
                        }
                        if (inventoryRet.Sublevel.IsSet())
                        {
                            productsubbrandcount++;
                        }
                        if (inventoryRet.UnitOfMeasureSetRef!=null)
                        {
                            productcount++;
                        }

                        if (inventoryRet != null && inventoryRet.IsActive.GetValue())
                        {
                            var p = new ProductImport
                                        {
                                            pCode = inventoryRet.FullName != null ? inventoryRet.Name.GetValue() : "",
                                            pDesc =
                                                inventoryRet.SalesDesc != null ? inventoryRet.SalesDesc.GetValue() : "",
                                            exfactory = inventoryRet.PurchaseCost != null
                                                            ? Convert.ToDecimal(inventoryRet.PurchaseCost.GetAsString())
                                                            : 0m,
                                            vatclassName = inventoryRet.SalesTaxCodeRef != null
                                                               ? inventoryRet.SalesTaxCodeRef.FullName.GetValue()
                                                               : "",
                                            packagingTypeName = inventoryRet.UnitOfMeasureSetRef !=null?inventoryRet.UnitOfMeasureSetRef.FullName.GetValue():"",
                                            productBrandName = 
                                           inventoryRet.ParentRef != null ? inventoryRet.ParentRef.FullName.GetValue() : ""
                                        };
                            items.Add(p);
                            if (inventoryRet.ParentRef != null && inventoryRet.ParentRef.FullName != null )
                            {
                                IItemInventoryRet b = GetInventoryByNameFilter(inventoryRet.ParentRef.FullName.GetValue());
                                if (b != null )
                                {
                                    var brand = new ProductBrand
                                    {
                                        Code = b.FullName != null ? b.FullName.GetValue() : "",
                                        Name = b.SalesDesc != null ? b.SalesDesc.GetValue() : "",
                                        Description = b.SalesDesc != null ? b.SalesDesc.GetValue() : "",
                                        supplierName = "NESTLE KENYA LIMITED"   //b.PrefVendorRef.FullName.GetValue()
                                    };
                                    if (!string.IsNullOrEmpty(brand.Code) && brands.All(n => n.Code != brand.Code))
                                        brands.Add(brand);

                                    brands.Select(n => new {});
                                }
                                
                            }
                            if(inventoryRet!=null && inventoryRet.UnitOfMeasureSetRef!=null)//p !=null && items.Any(n=>n.pCode==p.pCode))
                            {
                                //Michael Added Code
                              //  if(p.exfactory==0) continue;
                                //End of Michael Added Code
                                var pricing = new ProductPricing
                                {
                                    ProductCode = inventoryRet.FullName != null ? inventoryRet.Name.GetValue() : "",
                                    Exfactory = inventoryRet.PurchaseCost != null
                                                            ? Convert.ToDecimal(inventoryRet.PurchaseCost.GetAsString())
                                                            : 0m,
                                    SellingPrice = inventoryRet.SalesPrice !=null?Convert.ToDecimal(inventoryRet.SalesPrice.GetValue()):0m,
                                    StartDate = DateTime.Today.ToShortDateString(),
                                    TierNameCode = "Default"
                                };
                                pricings.Add(pricing); 
                            }
                            

                        }

                    }

                    
                }

                sessionManager.EndSession();
                boolSessionBegun = false;
                sessionManager.CloseConnection();
                if (items.Any())
                {
                    DumpExportFilesAsync(items.Where(p=>!string.IsNullOrEmpty(p.productBrandName) && p.exfactory >0m).ToCsv(), MasterDataCollective.SaleProduct.ToString());
                }
                if (pricings.Any())
                {
                    DumpExportFilesAsync(pricings.ToCsv(), MasterDataCollective.Pricing.ToString());
                }
                if (packagings.Any())
                {
                    DumpExportFilesAsync(packagings.ToCsv(), MasterDataCollective.ProductPackaging.ToString());
                }

                if (brands.Any())
                {
                    DumpExportFilesAsync(brands.ToCsv(), MasterDataCollective.ProductBrand.ToString());
                }
            }
            catch (Exception ex)
            {
                if (boolSessionBegun)
                {
                    sessionManager.EndSession();
                    sessionManager.CloseConnection();
                }
                string error = (ex.Message.ToString() + "\nStack Trace: \n" + ex.StackTrace + "\nExiting the application");
                Log(error);
                MessageBox.Show(error);

            }
          
        }
 public ProductNavigationViewModel(ProductBrand productBrand)
 {
     Text = productBrand.BrandName;
     CategorySlug = Text.CreateUrlSlug();
     ProductCount = productBrand.Products.Count().ToString();
 }