示例#1
0
        public JsonResult UpdateNews(Common.News viewNews)
        {
            try
            {
                NewsBusiness newsBusiness = new NewsBusiness();
                var          dbNews       = newsBusiness.GetById(viewNews.Id);
                dbNews.NewsGroupId     = viewNews.NewsGroupId;
                dbNews.Title           = viewNews.Title;
                dbNews.ImageSource     = viewNews.ImageSource;
                dbNews.Summary         = viewNews.Summary;
                dbNews.Descriptions    = viewNews.Descriptions;
                dbNews.Status          = viewNews.Status;
                dbNews.isPublic        = viewNews.isPublic;
                dbNews.ModifyDate      = DateTime.Now;
                dbNews.AdminIDApproval = viewNews.AdminIDApproval;

                newsBusiness.Edit(dbNews);
                return(Json(1));//Cập nhật thành công
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#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;
            }
        }
示例#3
0
 public void EditNews(News element, string username, string password)
 {
     IManager<News> business = new NewsBusiness();
     business.Edit(element, username, password);
 }