public ActionResult UpdateCatalog(long id)
        {
            var obj = _catalogsBusiness.GetById(id);

            List <LoadDropdown.DropdowCate> listDropdowCates = new List <LoadDropdown.DropdowCate>();

            ViewBag.parent          = _loadCombo.SearchCategoryByName(ref listDropdowCates, obj.ParentId);
            ViewBag.statusProduct   = _loadCombo.InitSelectListItemStatusCreateCategory();
            ViewBag.PromotionListID = _loadCombo.InitSelectListItemStatusNewsGroup(obj.PromotionID);

            Common.Catalog objentity = new Common.Catalog();
            objentity.Id               = obj.Id;
            objentity.ParentId         = obj.ParentId;
            objentity.Code             = obj.Code;
            objentity.CatalogName      = obj.CatalogName;
            objentity.FriendlyUrl      = obj.FriendlyUrl;
            objentity.Icon             = obj.Icon;
            objentity.ImageSource      = obj.ImageSource;
            objentity.Banner           = obj.Banner;
            objentity.Description      = obj.Description;
            objentity.Order            = obj.Order;
            objentity.Status           = obj.Status;
            objentity.CreateDate       = obj.CreateDate;
            objentity.ModifyDate       = obj.ModifyDate;
            objentity.IsLast           = obj.IsLast;
            objentity.SeoTitle         = obj.SeoTitle;
            objentity.SeoKeyword       = obj.SeoKeyword;
            objentity.SeoDescription   = obj.SeoDescription;
            objentity.ShareTitle       = obj.ShareTitle;
            objentity.ShareKeyword     = obj.ShareKeyword;
            objentity.ShareDescription = obj.ShareDescription;
            objentity.PromotionID      = obj.PromotionID;
            return(View(objentity));
        }
        public ActionResult UpdateCatalog(Common.Catalog viewCatalog, long parent, long?PromotionListID, string FriendlyHD, HttpPostedFileBase Icon, HttpPostedFileBase Banner, string ImageSource)
        {
            try
            {
                string           friendly         = "";
                CatalogsBusiness catalogsBusiness = new CatalogsBusiness();
                var dbCatalog = catalogsBusiness.GetById(viewCatalog.Id);
                dbCatalog.ParentId    = parent;
                dbCatalog.Code        = viewCatalog.Code;
                dbCatalog.CatalogName = viewCatalog.CatalogName;

                string friendlyCata = "";
                if (dbCatalog.ParentId != -1)
                {
                    var dbCatalogSub = catalogsBusiness.GetById(dbCatalog.ParentId);
                    friendlyCata = dbCatalogSub.FriendlyUrl.Replace(".html", "") + "/";
                }
                friendly = friendlyCata + Function.ConvertFileName(viewCatalog.CatalogName) + duoilink;

                dbCatalog.FriendlyUrl = friendly;
                if (Icon != null && Icon.ContentLength > 0)
                {
                    // TourInfo entity=new TourInfo();
                    //Random rdImage = new Random();
                    string randomImage = Guid.NewGuid().ToString();
                    //string fileNameImage = Common.util.Function.ConvertFileName(icon.FileName);
                    string pathImage   = HttpContext.Server.MapPath("~/FileUpload");
                    var    strurlimage = Common.util.Function.ResizeImageNew(Icon, 300, 300, pathImage, randomImage);
                    Common.util.Function.ResizeImageNew(Icon, 500, 500, pathImage, randomImage);
                    Common.util.Function.ResizeImageNew(Icon, 1000, 1000, pathImage, randomImage);
                    //  Common.util.Function.ReSizeImage(pathImage, fileNameImage, randomImage, 1000, 1000, icon);
                    dbCatalog.Icon = strurlimage;
                }
                if (Banner != null && Banner.ContentLength > 0)
                {
                    // TourInfo entity=new TourInfo();
                    //Random rdImage = new Random();
                    string randomImage = Guid.NewGuid().ToString();
                    //string fileNameImage = Common.util.Function.ConvertFileName(icon.FileName);
                    string pathImage   = HttpContext.Server.MapPath("~/FileUpload");
                    var    strurlimage = Common.util.Function.ResizeImageNew(Banner, 1500, 1500, pathImage, randomImage);
                    //Common.util.Function.ResizeImageNew(Banner, 500, 500, pathImage, randomImage);
                    //Common.util.Function.ResizeImageNew(Banner, 1000, 1000, pathImage, randomImage);
                    //  Common.util.Function.ReSizeImage(pathImage, fileNameImage, randomImage, 1000, 1000, icon);
                    dbCatalog.Banner = strurlimage;
                }
                if (ImageSource != "")
                {
                    dbCatalog.ImageSource = ImageSource;
                }
                dbCatalog.Description = viewCatalog.Description;
                dbCatalog.Order       = viewCatalog.Order;
                dbCatalog.Status      = viewCatalog.Status;
                //dbCatalog.PromotionID = PromotionListID;
                dbCatalog.IsLast           = viewCatalog.IsLast;
                dbCatalog.SeoTitle         = viewCatalog.SeoTitle;
                dbCatalog.SeoKeyword       = viewCatalog.SeoKeyword;
                dbCatalog.SeoDescription   = viewCatalog.SeoDescription;
                dbCatalog.ShareTitle       = viewCatalog.ShareTitle;
                dbCatalog.ShareKeyword     = viewCatalog.ShareKeyword;
                dbCatalog.ShareDescription = viewCatalog.ShareDescription;

                catalogsBusiness.Edit(dbCatalog);

                try
                {
                    Common.FriendlyUrl friendlyUrl = new Common.FriendlyUrl();
                    Random             rnd         = new Random();
                    int    ngaunhien = rnd.Next(1, 100);
                    string linkcu    = "";

                    if (FriendlyHD != friendly)
                    {
                        linkcu = FriendlyHD;
                    }
                    else
                    {
                        linkcu = "";
                    }
                    friendlyUrl.ItemId         = viewCatalog.Id;
                    friendlyUrl.Link           = friendly;
                    friendlyUrl.ControllerName = "Home";
                    friendlyUrl.ActionName     = "Category";
                    friendlyUrl.NameLink       = friendly + ngaunhien;
                    friendlyUrl.NameSpaces     = "BuyGroup365.Controllers";
                    friendlyUrl.Order          = 0;

                    _friendlyUrlBusines.UpdateLink(linkcu, friendlyUrl);
                    RefreshFriendly.BindataSiteUrl();
                }
                catch { }
                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                throw;
            }
        }