Exemple #1
0
        public ActionResult AddNewsGroup(string newsGroupName, string FriendlyUrl, int?IsPublic, int parent, int?IsView1, int?IsView2, string SeoTitle, string SeoKeyword, string SeoDescription, string Descriptions, string ShareKeyword, string ShareTitle, string ShareDescription, string ImageSource)
        {
            try
            {
                string            friendly  = "";
                Common.NewsGroups newsGroup = new Common.NewsGroups();
                newsGroup.ParentId      = parent;
                newsGroup.NewsGroupName = newsGroupName;

                newsGroup.isPublic    = (IsPublic == 1);
                friendly              = Common.util.Function.ConvertUrlString(newsGroupName) + duoilink;
                newsGroup.FriendlyUrl = friendly;
                // }
                newsGroup.Status           = 1;
                newsGroup.CreateDate       = DateTime.Now;
                newsGroup.ModifyDate       = DateTime.Now;
                newsGroup.AdminIDApproval  = 1;
                newsGroup.IsView1          = (IsView1 == 1);
                newsGroup.IsView2          = (IsView2 == 1);
                newsGroup.SeoTitle         = SeoTitle;
                newsGroup.SeoKeyword       = SeoKeyword;
                newsGroup.SeoDescription   = SeoDescription;
                newsGroup.ShareTitle       = ShareTitle;
                newsGroup.ShareKeyword     = ShareKeyword;
                newsGroup.ShareDescription = ShareDescription;
                newsGroup.Descriptions     = Descriptions;

                if (ImageSource != "")
                {
                    newsGroup.ImageSource = ImageSource;
                }
                long Catalogid;
                _newsGroupBusiness.AddNew(newsGroup);
                Catalogid = newsGroup.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 = "News";
                    friendlyUrl.ActionName     = "Index";
                    friendlyUrl.NameLink       = friendly + ngaunhien.ToString();
                    friendlyUrl.NameSpaces     = "BuyGroup365.Controllers";
                    friendlyUrl.Order          = 0;

                    _friendlyUrlBusines.InsertLink(friendlyUrl);
                    RefreshFriendly.BindataSiteUrl();
                }
                catch { }
                return(RedirectToAction("NewsGroup"));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #2
0
        public ActionResult EditNews(Common.News obj, string IsPublic, string ImageSource, string[] tags, string[] Author, string FriendlyUrlhd, string IsActive, string ModifyDate)
        {
            try
            {
                var record = _newsBusines.GetById(obj.Id);

                string friendly = "tin-tuc";
                record.Status = obj.Status;
                try
                {
                    if (ModifyDate != null)
                    {
                        record.ModifyDate = DateTime.ParseExact(ModifyDate.Replace('-', '/'), "dd/MM/yyyy", CultureInfo.CurrentCulture);
                    }
                    else
                    {
                        record.ModifyDate = DateTime.Now;
                    }
                }
                catch
                {
                    record.ModifyDate = DateTime.Now;
                }

                if (!string.IsNullOrEmpty(IsPublic) && IsPublic == "1")
                {
                    record.isPublic = true;
                }
                else
                {
                    record.isPublic = false;
                }

                if (!string.IsNullOrEmpty(IsActive) && IsActive == "1")
                {
                    record.IsActive = true;
                }
                else
                {
                    record.IsActive = false;
                }

                //if (string.IsNullOrEmpty(obj.FriendlyUrl))
                //{
                friendly = Function.ConvertFileName(_newsGroupBusiness.GetById(obj.NewsGroupId).NewsGroupName) + "/" + Function.ConvertFileName(obj.Title) + duoilink;
                //}
                //else
                //{
                //    friendly = _newsGroupBusiness.GetById(obj.NewsGroupId).FriendlyUrl + "/" + obj.FriendlyUrl;

                //}

                record.FriendlyUrl = friendly;
                if (ImageSource != "")
                {
                    record.ImageSource = ImageSource;
                }
                else
                {
                    //  record.ImageSource = obj.ImageSource;
                }

                record.Title            = obj.Title;
                record.Descriptions     = obj.Descriptions;
                record.SeoDescription   = obj.SeoDescription;
                record.SeoKeyword       = obj.SeoKeyword;
                record.SeoTitle         = obj.SeoTitle;
                record.ShareDescription = obj.ShareDescription;
                record.ShareKeyword     = obj.ShareKeyword;
                record.ShareTitle       = obj.ShareTitle;
                record.Summary          = obj.Summary;

                if (tags != null && tags.Count() > 0)
                {
                    record.Tags = "";
                    foreach (string tag in tags)
                    {
                        record.Tags = record.Tags + tag + ";";
                    }

                    record.Tags = record.Tags.Substring(0, record.Tags.Count() - 1);
                }
                else
                {
                    record.Tags = "";
                }
                if (Author != null && Author.Count() > 0)
                {
                    record.Author = "";
                    foreach (string auth in Author)
                    {
                        record.Author = record.Author + auth + ";";
                    }

                    record.Author = record.Author.Substring(0, record.Author.Count() - 1);
                }
                else
                {
                    record.Author = "";
                }
                record.NewsGroupId = obj.NewsGroupId;
                _newsBusines.Edit(record);

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

                    friendlyUrl.ItemId         = record.Id;
                    friendlyUrl.Link           = friendly;
                    friendlyUrl.ControllerName = "News";
                    friendlyUrl.ActionName     = "Detail";
                    friendlyUrl.NameLink       = record.FriendlyUrl + ngaunhien.ToString();
                    friendlyUrl.NameSpaces     = "BuyGroup365.Controllers";
                    friendlyUrl.Order          = 0;
                    if (FriendlyUrlhd != friendly)
                    {
                        linkcu = FriendlyUrlhd;

                        //  RouteTable.Routes.MapRoute(name: record.FriendlyUrl + ngaunhien.ToString(), url: record.FriendlyUrl, defaults: new { controller = "News", action = "Detail", id = record.Id, }, namespaces: new string[] { "BuyGroup365.Controllers" });
                    }
                    else
                    {
                        linkcu = "";
                    }
                    _friendlyUrlBusines.UpdateLink(linkcu, friendlyUrl);
                    RefreshFriendly.BindataSiteUrl();
                }
                catch { }
                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #3
0
        public ActionResult AddNews(Common.News obj, string IsPublic, string ImageSource, string[] tags, string[] Author, string IsActive, string ModifyDate)
        {
            try
            {
                Common.FriendlyUrl friendlyUrl = new Common.FriendlyUrl();

                string friendly = "tin-tuc";
                obj.Status     = 1;
                obj.CreateDate = DateTime.Now;
                try
                {
                    if (ModifyDate != null)
                    {
                        obj.ModifyDate = DateTime.ParseExact(ModifyDate.Replace('-', '/'), "dd/MM/yyyy", CultureInfo.CurrentCulture);
                    }
                    else
                    {
                        obj.ModifyDate = DateTime.Now;
                    }
                }
                catch { obj.ModifyDate = DateTime.Now; }

                if (!string.IsNullOrEmpty(IsPublic) && IsPublic == "1")
                {
                    obj.isPublic = true;
                }
                else
                {
                    obj.isPublic = false;
                }

                if (!string.IsNullOrEmpty(IsActive) && IsActive == "1")
                {
                    obj.IsActive = true;
                }
                else
                {
                    obj.IsActive = false;
                }

                //if (string.IsNullOrEmpty(obj.FriendlyUrl))
                //{
                friendly = Function.ConvertFileName(_newsGroupBusiness.GetById(obj.NewsGroupId).NewsGroupName) + "/" + Function.ConvertFileName(obj.Title) + duoilink;
                //}
                obj.FriendlyUrl = friendly;

                if (ImageSource != "")
                {
                    obj.ImageSource = ImageSource;
                }

                if (tags != null && tags.Count() > 0)
                {
                    obj.Tags = "";
                    foreach (string tag in tags)
                    {
                        obj.Tags = obj.Tags + tag + ";";
                    }

                    obj.Tags = obj.Tags.Substring(0, obj.Tags.Count() - 1);
                }
                if (Author != null && Author.Count() > 0)
                {
                    obj.Author = "";
                    foreach (string auth in Author)
                    {
                        obj.Author = obj.Author + auth + ";";
                    }

                    obj.Author = obj.Author.Substring(0, obj.Author.Count() - 1);
                }
                long newsid;
                _newsBusines.AddNew(obj);
                newsid = obj.Id;
                try
                {
                    Random rnd       = new Random();
                    int    ngaunhien = rnd.Next(1, 100);
                    friendlyUrl.ItemId         = newsid;
                    friendlyUrl.Link           = friendly;
                    friendlyUrl.ControllerName = "News";
                    friendlyUrl.ActionName     = "Detail";
                    friendlyUrl.NameLink       = obj.FriendlyUrl + ngaunhien.ToString();
                    friendlyUrl.NameSpaces     = "BuyGroup365.Controllers";
                    friendlyUrl.Order          = 0;

                    _friendlyUrlBusines.InsertLink(friendlyUrl);
                    RefreshFriendly.BindataSiteUrl();
                }
                catch { }
                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #4
0
        public ActionResult Update(long id, string btnSubmit, string TagName, string TagUrl, int Type, string Description, string SeoTitle, string SeoKeyword, string SeoDescription, string TagNamecu, string ShareTitle, string ShareKeyword, string ShareDescription, string ImageSource)
        {
            try
            {
                Common.FriendlyUrl friendlyUrl = new Common.FriendlyUrl();
                string             friendly    = "";
                if (btnSubmit == "Thêm")
                {
                    Tag tag = new Tag();
                    tag.TagName = TagName;

                    tag.TagUrl = friendly;

                    tag.Description      = Description;
                    tag.SeoTitle         = SeoTitle;
                    tag.SeoKeyword       = SeoKeyword;
                    tag.SeoDescription   = SeoDescription;
                    tag.ShareTitle       = ShareTitle;
                    tag.ShareKeyword     = ShareKeyword;
                    tag.ShareDescription = ShareDescription;
                    tag.Type             = Type;
                    tag.DateCreate       = DateTime.Now;
                    tag.ModifyDate       = DateTime.Now;

                    if (ImageSource != "")
                    {
                        tag.ImageSource = ImageSource;
                    }

                    try
                    {
                        Random rnd       = new Random();
                        int    ngaunhien = rnd.Next(1, 100);

                        if (tag.Type == 1)
                        {
                            friendlyUrl.ControllerName = "Home";
                            friendlyUrl.ActionName     = "Tags";
                            friendly = "san-pham/" + Function.ConvertFileName(TagName) + duoilink;
                        }
                        if (tag.Type == 2)
                        {
                            friendlyUrl.ControllerName = "News";
                            friendlyUrl.ActionName     = "Tags";
                            friendly = "tin-tuc/" + Function.ConvertFileName(TagName) + duoilink;
                        }
                        if (tag.Type == 3)
                        {
                            friendlyUrl.ControllerName = "News";
                            friendlyUrl.ActionName     = "author";
                            friendly = "author/" + Function.ConvertFileName(TagName) + duoilink;
                        }
                        tag.TagUrl = friendly;
                        tagsBusiness.AddNew(tag);

                        friendlyUrl.ItemId     = tag.Id;
                        friendlyUrl.Link       = friendly;
                        friendlyUrl.NameLink   = friendly + ngaunhien.ToString();
                        friendlyUrl.NameSpaces = "BuyGroup365.Controllers";
                        friendlyUrl.Order      = 0;

                        _friendlyUrlBusines.InsertLink(friendlyUrl);
                        RefreshFriendly.BindataSiteUrl();
                    }
                    catch { }
                }
                else
                {
                    var tag = tagsBusiness.GetById(id);
                    tag.TagName = TagName;

                    friendly             = Function.ConvertFileName(TagName) + duoilink;
                    tag.TagUrl           = friendly;
                    tag.Description      = Description;
                    tag.SeoTitle         = SeoTitle;
                    tag.SeoKeyword       = SeoKeyword;
                    tag.SeoDescription   = SeoDescription;
                    tag.ShareTitle       = ShareTitle;
                    tag.ShareKeyword     = ShareKeyword;
                    tag.ShareDescription = ShareDescription;
                    tag.Type             = Type;
                    if (ImageSource != "")
                    {
                        tag.ImageSource = ImageSource;
                    }
                    tag.ModifyDate = DateTime.Now;

                    try
                    {
                        string linkcu = "";

                        if (TagNamecu != friendly)
                        {
                            linkcu = Function.ConvertUrlString(TagNamecu);
                        }
                        else
                        {
                            linkcu = "";
                        }
                        Random rnd       = new Random();
                        int    ngaunhien = rnd.Next(1, 100);
                        friendlyUrl.ItemId = tag.Id;

                        if (tag.Type == 1)
                        {
                            friendlyUrl.ControllerName = "Home";
                            friendlyUrl.ActionName     = "Tags";
                            friendly = "san-pham/" + Function.ConvertFileName(TagName) + duoilink;
                        }
                        if (tag.Type == 2)
                        {
                            friendlyUrl.ControllerName = "News";
                            friendlyUrl.ActionName     = "Tags";
                            friendly = "tin-tuc/" + Function.ConvertFileName(TagName) + duoilink;
                        }
                        if (tag.Type == 3)
                        {
                            friendlyUrl.ControllerName = "News";
                            friendlyUrl.ActionName     = "Author";
                            friendly = "author/" + Function.ConvertFileName(TagName) + duoilink;
                        }
                        friendlyUrl.Link       = friendly;
                        tag.TagUrl             = friendly;
                        friendlyUrl.NameLink   = friendly + ngaunhien.ToString();
                        friendlyUrl.NameSpaces = "BuyGroup365.Controllers";
                        friendlyUrl.Order      = 0;

                        _friendlyUrlBusines.UpdateLink(linkcu, friendlyUrl);
                        RefreshFriendly.BindataSiteUrl();
                    }
                    catch { }
                    tagsBusiness.Edit(tag);
                }
                Response.Redirect("/Manage/Tags/Index");
            }
            catch (Exception ex)
            {
                Response.Redirect("/Manage/Tags/Index");
            }
            return(View());
        }
        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;
            }
        }