public ActionResult Category(string categoryName, HttpPostedFileBase inpImage)
        {
            try
            {
                ShopM shop = new ShopM();

                shop.Category.Add(new DataModel.Category {
                    cat_name = categoryName, del_flag = false, modify_user_id = 0, lang = "EN"
                });
                shop.SaveChanges();
                List <Category> lst = shop.Category.ToList();

                return(View(lst));
            }
            catch (DbEntityValidationException dbEx)
            {
                //code for get validation error (column name ,and error)
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                    }
                }
                return(View());
            }
        }
        public ActionResult CompanyInfo(string txtcompanyName, string txtphone, string txtphone2, string txtAddress, string txtEmail, string txtAbout)
        {
            ShopM   shop  = new ShopM();
            Company exist = shop.Company.Where(c => c.lang == "EN").FirstOrDefault();

            if (exist != null)
            {
                exist.address           = txtAddress;
                exist.brief_discription = txtAbout;
                exist.company_name      = txtcompanyName;
                exist.mail   = txtEmail;
                exist.phone  = txtphone;
                exist.mobile = txtphone2;
            }
            else
            {
                Company newcomp = new Company();
                newcomp.address           = txtAddress;
                newcomp.brief_discription = txtAbout;
                newcomp.company_name      = txtcompanyName;
                newcomp.mail   = txtEmail;
                newcomp.phone  = txtphone;
                newcomp.mobile = txtphone2;
                newcomp.lang   = "EN";
                shop.Company.Add(newcomp);
            }
            shop.SaveChanges();
            exist = shop.Company.Where(c => c.lang == "EN").FirstOrDefault();
            return(View(exist));
        }
        public ActionResult editBrand(int brandId, string editBrandName)
        {
            ShopM shop = new ShopM();
            Brand bran = shop.Brand.Where(c => c.id == brandId).FirstOrDefault();

            bran.brand_name = editBrandName;
            shop.SaveChanges();
            List <Brand> lst = shop.Brand.ToList();

            return(View("Brands", lst));
        }
        public ActionResult editCategory(int catId, string editCategoryName, HttpPostedFileBase inpImageEdit)
        {
            ShopM    shop = new ShopM();
            Category cat  = shop.Category.Where(c => c.id == catId).FirstOrDefault();

            cat.cat_name = editCategoryName;
            shop.SaveChanges();
            List <Category> lst = shop.Category.ToList();

            return(View("Category", lst));
        }
        public ActionResult deleteSubcategory(int subId)
        {
            ShopM       shop = new ShopM();
            SubCategory sub  = shop.SubCategory.Where(c => c.id == subId).FirstOrDefault();

            sub.del_flag = true;
            shop.SaveChanges();
            List <Category> lst = shop.Category.Where(c => c.id > 3).ToList();

            ViewBag.catg = lst;
            return(View("SubCategory"));
        }
        public ActionResult deleteBrand(int Brand)
        {
            ShopM shop = new ShopM();
            Brand bran = shop.Brand.Where(c => c.id == Brand).FirstOrDefault();

            bran.del_flag = true;
            shop.SaveChanges();
            List <Brand> lst = shop.Brand.ToList();

            Category();
            return(View("Brands", lst));
        }
        public ActionResult Brands(string txtBrandName)
        {
            ShopM shop = new ShopM();

            shop.Brand.Add(new DataModel.Brand {
                brand_name = txtBrandName, del_flag = false
            });
            shop.SaveChanges();
            List <Brand> lst = shop.Brand.ToList();

            return(View(lst));
        }
        public ActionResult deleteCategory(int catId)
        {
            ShopM    shop = new ShopM();
            Category cat  = shop.Category.Where(c => c.id == catId).FirstOrDefault();

            cat.del_flag = true;
            shop.SaveChanges();
            List <Category> lst = shop.Category.ToList();

            Category();
            return(View("Category", lst));
        }
        public ActionResult editSubcategory(int subId, string editSubcategoryName, int ddlCategForEdit)
        {
            ShopM       shop = new ShopM();
            SubCategory catg = shop.SubCategory.Where(c => c.id == subId).FirstOrDefault();

            catg.sub_cat_name = editSubcategoryName;
            catg.cat_id       = ddlCategForEdit;
            shop.SaveChanges();
            List <Category> lst = shop.Category.ToList();

            ViewBag.catg = lst;
            return(View("SubCategory"));
        }
        public ActionResult SubCategory(string txtSubcategoryName, int ddlCategForAdd)
        {
            ShopM shop = new ShopM();

            shop.SubCategory.Add(new DataModel.SubCategory {
                sub_cat_name = txtSubcategoryName, del_flag = false, cat_id = ddlCategForAdd, modify_user_id = 0, lang = "EN"
            });
            shop.SaveChanges();
            List <Category> lst = shop.Category.ToList();

            ViewBag.catg = lst;
            return(View());
        }