public JsonResult GetNewsGroupById(long id) { try { var dbNewsGroup = _newsGroupBusiness.GetById(id); if (dbNewsGroup != null) { Common.NewsGroups viewNewsGroup = new Common.NewsGroups(); viewNewsGroup.Id = dbNewsGroup.Id; viewNewsGroup.ParentId = dbNewsGroup.ParentId; viewNewsGroup.NewsGroupName = dbNewsGroup.NewsGroupName; viewNewsGroup.isPublic = viewNewsGroup.isPublic; viewNewsGroup.Status = dbNewsGroup.Status; viewNewsGroup.CreateDate = dbNewsGroup.CreateDate; viewNewsGroup.ModifyDate = dbNewsGroup.ModifyDate; viewNewsGroup.AdminIDApproval = dbNewsGroup.AdminIDApproval; return(Json(viewNewsGroup, JsonRequestBehavior.AllowGet)); } else { return(Json(0)); } } catch (Exception) { //Write log throw; } }
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; } }
public JsonResult UpdateNewsGroup(Common.NewsGroups viewNewsGroup) { try { NewsGroupBusiness newsGroupBusiness = new NewsGroupBusiness(); var dbNewsGroup = newsGroupBusiness.GetById(viewNewsGroup.Id); dbNewsGroup.ParentId = viewNewsGroup.ParentId; dbNewsGroup.NewsGroupName = viewNewsGroup.NewsGroupName; dbNewsGroup.isPublic = viewNewsGroup.isPublic; dbNewsGroup.Status = viewNewsGroup.Status; dbNewsGroup.ModifyDate = DateTime.Now; dbNewsGroup.AdminIDApproval = viewNewsGroup.AdminIDApproval; dbNewsGroup.IsView1 = viewNewsGroup.IsView1; dbNewsGroup.IsView2 = viewNewsGroup.IsView2; newsGroupBusiness.Edit(dbNewsGroup); return(Json(1));//Cập nhật thành công } catch (Exception) { throw; } }