Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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;
            }
        }