public ActionResult Create(string DanhMucGuid, int?DanhMucId, string CategoryName, string CategoryGuid, bool?Status, string Description, int?SortOrder, string FileName)
        {
            shCategory category = new shCategory();

            using (var context = new ShopOnlineDb())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        // Insert- update Category
                        shCategoryService _category = new shCategoryService();
                        category = _category.ThemMoi_HieuChinhCategory(
                            DanhMucGuid,
                            null,
                            CategoryName,
                            CategoryGuid,
                            null,
                            Status,
                            DateTime.Now,
                            null,
                            Description,
                            SortOrder,
                            FileName);

                        // Insesrt Image
                        if (!string.IsNullOrEmpty(FileName) || !string.IsNullOrWhiteSpace(FileName))
                        {
                            shCategoryImageService _categoryImage = new shCategoryImageService();
                            shCategoryImage        categoryImage  = _categoryImage.Insert_UpdateCategoryImage(
                                null,
                                null,
                                category.CategoryGuid,
                                FileName,
                                null,
                                User.Identity.GetUserLogin().Userid,
                                true,
                                DateTime.Now,
                                null
                                );
                        }

                        dbContextTransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }

            int?page = CommonHelper.FindPageCategory(category.CategoryGuid, category.CategoryId);

            return(RedirectToAction("Index", new { page = page }));
        }
Example #2
0
        public static string CategoryImageIconActive(this HtmlHelper helper, string CategoryGuid)
        {
            shCategoryImageService _categoryImage = new shCategoryImageService();
            shCategoryImage        categoryimage  = _categoryImage.FindList()
                                                    .Where(x => x.CategoryGuid == CategoryGuid && x.Image == Config.Category_Image_Icon_Active)
                                                    .LastOrDefault();

            if (categoryimage == null)
            {
                categoryimage = new shCategoryImage();
            }
            return(categoryimage.FileName);
        }
Example #3
0
        public static string CategoryImage(this HtmlHelper helper, string CategoryGuid)
        {
            shCategoryImageService _categoryImage = new shCategoryImageService();
            shCategoryImage        categoryimage  = _categoryImage.FindList()
                                                    .Where(x => x.CategoryGuid == CategoryGuid &&
                                                           (string.IsNullOrWhiteSpace(x.Image) || string.IsNullOrEmpty(x.Image)))
                                                    .LastOrDefault();

            if (categoryimage == null)
            {
                categoryimage = new shCategoryImage();
            }
            return(categoryimage.FileName);
        }
Example #4
0
        public ActionResult Create(string DanhMucGuid, int?DanhMucId, string CategoryName, string CategoryGuid, bool?Status, string Description, int?SortOrder, string FileName)
        {
            // Insert Category
            shCategoryService _category = new shCategoryService();
            shCategory        category  = _category.ThemMoi_HieuChinhCategory(
                DanhMucGuid,
                null,
                CategoryName,
                CategoryGuid,
                HttpContext.User.Identity.GetUserLogin().Userid,
                Status,
                DateTime.Now,
                null,
                Description,
                SortOrder,
                FileName);

            // Insesrt Image
            if (!string.IsNullOrEmpty(FileName) || !string.IsNullOrWhiteSpace(FileName))
            {
                shCategoryImageService _categoryImage = new shCategoryImageService();
                shCategoryImage        categoryImage  = _categoryImage.Insert_UpdateCategoryImage(
                    null,
                    null,
                    category.CategoryGuid,
                    FileName,
                    null,
                    User.Identity.GetUserLogin().Userid,
                    true,
                    DateTime.Now,
                    null
                    );
            }

            int?page = CommonHelper.FindPageCategory(category.CategoryGuid, category.CategoryId);

            return(RedirectToAction("Index", new { page = page }));
        }
Example #5
0
        public ActionResult DialogHighLight(string CategoryGuid, string ImageIcon, string ImageIconActive)
        {
            // 1. Upload file sản phẩm nổi bật
            shCategoryImageService _categoryImage = new shCategoryImageService();
            shCategoryImage        categoryImage  = new shCategoryImage();

            _categoryImage.Insert_UpdateCategoryImage(
                null,
                null,
                CategoryGuid,
                ImageIcon,
                null,
                User.Identity.GetUserLogin().Userid,
                true,
                DateTime.Now,
                Config.Category_Image_Icon
                );

            _categoryImage.Insert_UpdateCategoryImage(
                null,
                null,
                CategoryGuid,
                ImageIconActive,
                null,
                User.Identity.GetUserLogin().Userid,
                true,
                DateTime.Now,
                Config.Category_Image_Icon_Active
                );

            if (Request.IsAjaxRequest())
            {
                return(Json("OK", JsonRequestBehavior.AllowGet));
            }
            return(RedirectToAction("Index"));
        }
Example #6
0
        public ActionResult DialogHighLight(string CategoryGuid)
        {
            shCategoryImageService _category = new shCategoryImageService();

            IEnumerable <shCategoryImage> dsCategory = _category.FindList().Where(x => x.CategoryGuid == CategoryGuid);
            string          Icon          = "/Content/Images/background.jpg";
            shCategoryImage categoryImage = dsCategory.Where(x => x.Image == Config.Category_Image_Icon).LastOrDefault();

            if (categoryImage != null)
            {
                Icon = categoryImage.FileName;
            }
            ViewBag.Icon = "<img src='" + Icon + "' id='previewIcon' name='previewIcon' style='width:auto; height: auto; max-height: 100px; max-width: 100px;' />";

            Icon          = "/Content/Images/background.jpg";
            categoryImage = dsCategory.Where(x => x.Image == Config.Category_Image_Icon_Active).LastOrDefault();
            if (categoryImage != null)
            {
                Icon = categoryImage.FileName;
            }
            ViewBag.IconActive = "<img src='" + Icon + "' id='previewIconActive' name='previewIconActive' style='width:auto; height: auto; max-height: 100px; max-width: 100px;' />";

            return(PartialView("DialogHighLight"));
        }