コード例 #1
0
        public JsonResult UpdateCatalog(Common.Catalog viewCatalog)
        {
            try
            {
                CatalogsBusiness catalogsBusiness = new CatalogsBusiness();
                var dbCatalog = catalogsBusiness.GetById(viewCatalog.Id);
                dbCatalog.ParentId    = viewCatalog.ParentId;
                dbCatalog.Code        = viewCatalog.Code;
                dbCatalog.CatalogName = viewCatalog.CatalogName;
                dbCatalog.FriendlyUrl = viewCatalog.FriendlyUrl;
                dbCatalog.Icon        = viewCatalog.Icon;
                dbCatalog.Description = viewCatalog.Description;
                dbCatalog.Order       = viewCatalog.Order;
                dbCatalog.Status      = viewCatalog.Status;

                dbCatalog.IsLast         = viewCatalog.IsLast;
                dbCatalog.SeoTitle       = viewCatalog.SeoTitle;
                dbCatalog.SeoKeyword     = viewCatalog.SeoKeyword;
                dbCatalog.SeoDescription = viewCatalog.SeoDescription;

                catalogsBusiness.Edit(dbCatalog);
                return(Json(1));//Cập nhật thành công
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        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;
            }
        }