Пример #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;
            }
        }
        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));
        }
Пример #3
0
        public static PromotionList InitPromotionList(Product item)
        {
            CatalogsBusiness cataBussiness = new CatalogsBusiness();
            Catalog          cata          = new Catalog();
            string           html          = "";
            int  i = 1;
            long cataid;

            try
            {
                if (item.PromotionID != null)
                {
                    return(item.PromotionList);
                }
                else
                {
                    cataid = item.CatalogProducts.First().CatalogId;
                    cata   = cataBussiness.GetById(cataid);
                    return(cata.PromotionList);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        public JsonResult GetProperty(long cateId)
        {
            try
            {
                var htm      = "";
                var property = _catalogPropertiesBusiness.GetDynamicQuery().Where(x => x.CatalogId == cateId);
                CatalogsBusiness catabusinness = new CatalogsBusiness();
                string           friendlyUrl   = catabusinness.GetById(cateId).FriendlyUrl;
                foreach (var item in property)
                {
                    htm += "<div class=\"panel panel-default tht_panel  panlel_" + item.Id + "\">" +
                           "<div class=\"panel-heading\">" +
                           "<h3 class=\"panel-title\">" +
                           "  <input id=\"cataproname" + item.Id + "\" type=\"text\" value=\"" + item.Name + "\" />" +
                           " <input id=\"cataprokey" + item.Id + "\" type=\"text\" value=\"" + item.Key + "\" />";
                    if (item.TypeDesign == 1)
                    {
                        if (item.Type == 1)
                        {
                            htm += "<label style=\"display:none;\"><input type=\"checkbox\"  id =\"typeproperty" + item.Id + "\" checked value=\"" + item.Type + "\">Cho phép chọn nhiều? </label><input type=\"checkbox\" id =\"typedesignproperty" + item.Id + "\" checked value=\"" + item.TypeDesign + "\">Hiển thị 1 dòng </label><a class=\"del_1\" onclick=\"UpdateProperties(" + item.Id + ")\">Sửa</a><a class=\"del_1\" onclick=\"DeleteProperties(" + item.Id + ")\">Xóa</a></div>" +
                                   "<div class=\"panel-body\">";
                        }
                        else
                        {
                            htm += "<label style=\"display:none;\"><input type=\"checkbox\"  id =\"typeproperty" + item.Id + "\" value=\"" + item.Type + "\">Cho phép chọn nhiều? </label><input type=\"checkbox\" id =\"typedesignproperty" + item.Id + "\" checked value=\"" + item.TypeDesign + "\">Hiển thị 1 dòng </label><a class=\"del_1\" onclick=\"UpdateProperties(" + item.Id + ")\">Sửa</a><a class=\"del_1\" onclick=\"DeleteProperties(" + item.Id + ")\">Xóa</a></div>" +
                                   "<div class=\"panel-body\">";
                        }
                    }
                    else
                    {
                        if (item.Type == 1)
                        {
                            htm += "<label style=\"display:none;\"><input type=\"checkbox\"   id =\"typeproperty" + item.Id + "\" checked  value=\"" + item.Type + "\">Cho phép chọn nhiều? </label><input type=\"checkbox\" id =\"typedesignproperty" + item.Id + "\"  value=\"" + item.TypeDesign + "\">Hiển thị 1 dòng </label><a class=\"del_1\" onclick=\"UpdateProperties(" + item.Id + ")\">Sửa</a><a class=\"del_1\" onclick=\"DeleteProperties(" + item.Id + ")\">Xóa</a></div>" +
                                   "<div class=\"panel-body\">";
                        }
                        else
                        {
                            htm += "<label style=\"display:none;\"><input type=\"checkbox\"   id =\"typeproperty" + item.Id + "\" value=\"" + item.Type + "\">Cho phép chọn nhiều? </label><input type=\"checkbox\" id =\"typedesignproperty" + item.Id + "\"  value=\"" + item.TypeDesign + "\">Hiển thị 1 dòng </label><a class=\"del_1\" onclick=\"UpdateProperties(" + item.Id + ")\">Sửa</a><a class=\"del_1\" onclick=\"DeleteProperties(" + item.Id + ")\">Xóa</a></div>" +
                                   "<div class=\"panel-body\">";
                        }
                    }
                    foreach (var item2 in item.CatalogPropertiesValues)
                    {
                        htm += "<p id=\"properties_value_" + item2.Id + "\">+  <input id=\"properties_value_edit_" + item2.Id + "\" type=\"text\" value=\"" + item2.Value + "\" /><a class=\"update_2\" onclick=\"UpdatePropertiesValue(" + item2.Id + ")\">Sửa</a><a class=\"del_2\" onclick=\"DeletePropertiesValue(" + item2.Id + ")\">Xóa</a></p>";
                    }
                    htm += " <div id=\"valueUpdate\"></div> <div style=\"float:right\"><a onclick=\"AddvalueFormUpdate(" + item.Id + ")\" class=\"btn btn-primary btn-sm\">Thêm giá trị</a></div></div></div>";
                }
                return(Json(htm));
            }
            catch (Exception)
            {
                //write log
                return(Json(0));

                throw;
            }
        }
Пример #5
0
        public static string HtmlBreadcrumb(long id, ref string html)
        {
            var catalogsBusiness = new CatalogsBusiness();
            var obj = catalogsBusiness.GetById(id);

            html = "<li><a href=\"#\">" + obj.CatalogName + "</a></li>" + html;
            if (obj.ParentId != -1)
            {
                HtmlBreadcrumb(obj.ParentId, ref html);
            }
            return(html);
        }
Пример #6
0
        public static List <long> GetIdPrentById(long id, ref List <long> listParent)
        {
            var catalogsBusiness = new CatalogsBusiness();
            var obj = catalogsBusiness.GetById(id);

            if (obj != null)
            {
                if (obj.ParentId != -1)
                {
                    listParent.Add(obj.ParentId);
                    GetIdPrentById(obj.ParentId, ref listParent);
                }
            }

            return(listParent);
        }
Пример #7
0
        public static String InitPromotion(Product item)
        {
            CatalogsBusiness cataBussiness = new CatalogsBusiness();
            Catalog          cata          = new Catalog();
            string           html          = "";
            int  i = 1;
            long cataid;

            try
            {
                if (item.PromotionID != null)
                {
                    html = "<strong>" + item.PromotionList.Title + " </strong>";

                    foreach (PromotionItem pr in item.PromotionList.PromotionItem)
                    {
                        html += " <span class=\"promo\" data-id=\"0\">";
                        html += "<i class=\"numeric\">" + i + "</i>" + pr.Title;
                        i++;
                        html += "</span>";
                    }
                    html += "<div style=\"margin: 8px;    border-top: 1px dashed;    padding-top: 5px;\">" + item.PromotionList.Description + "</div>";
                }
                else
                {
                    cataid = item.CatalogProducts.First().CatalogId;
                    cata   = cataBussiness.GetById(cataid);
                    html   = "<strong>" + cata.PromotionList.Title + " </strong>";

                    foreach (PromotionItem pr in cata.PromotionList.PromotionItem)
                    {
                        html += " <span class=\"promo\" data-id=\"0\">";
                        html += "<i class=\"numeric\">" + i + "</i>" + pr.Title;
                        i++;
                        html += "</span>";
                    }
                    html += "<div style=\"margin: 8px;    border-top: 1px dashed;    padding-top: 5px;\">" + cata.PromotionList.Description + "</div>";
                }
            }
            catch (Exception ex)
            { }
            return(html);
        }
Пример #8
0
        public JsonResult GetCatalogProuctById(long id)
        {
            try
            {
                var obj = _catalogsBusiness.GetById(id);
                if (obj != null)
                {
                    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.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;

                    return(Json(objentity, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(0));
                }
            }
            catch (Exception)
            {
                //Write log
                throw;
            }
        }
        public ActionResult CreateCate(string categoryname, HttpPostedFileBase icon, HttpPostedFileBase Banner, int statusCatg, int?PromotionListID, int parent, string seoTitle, string seoKeyword, string seoDescription, string description, string ShareTitle, string ShareKeyword, string ShareDescription, string ImageSource)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    CatalogsBusiness catalogsBusiness = new CatalogsBusiness();
                    string           friendly         = "";
                    Random           rd  = new Random();
                    Catalog          obj = new Catalog();
                    // obj.FriendlyUrl = Function.ConvertFileName(categoryname);
                    string friendlyCata = "";
                    if (parent != -1)
                    {
                        var dbCatalogSub = catalogsBusiness.GetById(parent);
                        friendlyCata = dbCatalogSub.FriendlyUrl.Replace(".html", "") + "/";
                    }
                    friendly        = friendlyCata + Function.ConvertFileName(categoryname) + duoilink;
                    obj.FriendlyUrl = friendly;
                    obj.ParentId    = parent;
                    obj.Status      = statusCatg;
                    obj.CatalogName = categoryname;
                    obj.Code        = rd.Next(100000, 999999).ToString();
                    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);
                        obj.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);
                        obj.Banner = strurlimage;
                    }
                    if (ImageSource != "")
                    {
                        obj.ImageSource = ImageSource;
                    }
                    obj.SeoKeyword       = seoKeyword;
                    obj.SeoTitle         = seoTitle;
                    obj.SeoDescription   = seoDescription;
                    obj.ShareTitle       = ShareTitle;
                    obj.ShareKeyword     = ShareKeyword;
                    obj.ShareDescription = ShareDescription;
                    obj.Description      = description;
                    //obj.PromotionID = PromotionListID;

                    long Catalogid;
                    _catalogsBusiness.AddNew(obj);
                    Catalogid = obj.Id;
                    try
                    {
                        Common.FriendlyUrl friendlyUrl = new Common.FriendlyUrl();
                        Random             rnd         = new Random();
                        int ngaunhien = rnd.Next(1, 100);
                        friendlyUrl.ItemId         = Catalogid;
                        friendlyUrl.Link           = friendly;
                        friendlyUrl.ControllerName = "Home";
                        friendlyUrl.ActionName     = "Category";
                        friendlyUrl.NameLink       = friendly + ngaunhien.ToString();
                        friendlyUrl.NameSpaces     = "BuyGroup365.Controllers";
                        friendlyUrl.Order          = 0;

                        _friendlyUrlBusines.InsertLink(friendlyUrl);
                        RefreshFriendly.BindataSiteUrl();
                    }
                    catch { }
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", "Tạo mới không thành công");
                    return(View());
                }
            }
            catch (Exception ex)
            {
                //witrelog
                throw;
            }
        }
        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;
            }
        }