public async Task <JsonResult> GetCategoryData(int?categoryId, int?page, int?pageSize) { NewsOprations np = new NewsOprations(); DataSet ds = await Task.Run(() => np.GetNews(page.Value, pageSize.Value, categoryId.Value)); return(Json(new { data = JsonConvert.SerializeObject(ds.Tables[0], Formatting.None), totalcount = JsonConvert.SerializeObject(ds.Tables[1], Formatting.None) }, JsonRequestBehavior.AllowGet)); }
public JsonResult GetCurrentUser() { var currentUser = (ClaimsPrincipal)Thread.CurrentPrincipal; var UserId = currentUser.Claims.Where(x => x.Type == ClaimTypes.PrimarySid).Select(c => c.Value).SingleOrDefault(); int UserID = int.Parse(UserId); var _user = new NewsOprations().getCurrentUserId(UserID); return(Json(new { user = JsonConvert.SerializeObject(_user) }, JsonRequestBehavior.AllowGet)); }
public async Task <JsonResult> GetTopic(string topic, int?pageIndex = 1) { try { NewsOprations newsList = new NewsOprations(); var item = await Task.Run(() => newsList.GetNewsBySearch(pageIndex.Value, topic)); return(Json(new { latestdata = JsonConvert.SerializeObject(item.Tables[0]), populardata = JsonConvert.SerializeObject(item.Tables[1]), data = JsonConvert.SerializeObject(item.Tables[2]), count = JsonConvert.SerializeObject(item.Tables[3]) }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Log.Error(ex.ToString()); } return(null); }
public async Task <JsonResult> GetResultSection(int?categoryId, int?pageIndex, string section) { try { NewsOprations np = new NewsOprations(); DataTable dataTable = await Task.Run(() => np.GetSectionData(section, pageIndex.Value, categoryId.Value)); var result = new { data = JsonConvert.SerializeObject(dataTable, Formatting.None) }; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Log.Error(ex.ToString()); } return(null); }
public async Task <JsonResult> GetFirstTimeCategoryData(int?categoryId) { try { NewsOprations np = new NewsOprations(); DataSet ds = await Task.Run(() => np.GetClientCategory(categoryId.Value)); var result = new { latest = JsonConvert.SerializeObject(ds.Tables[0], Formatting.None), popular = JsonConvert.SerializeObject(ds.Tables[1], Formatting.None), category = JsonConvert.SerializeObject(ds.Tables[2], Formatting.None), paging = JsonConvert.SerializeObject(ds.Tables[3], Formatting.None) }; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Log.Error(ex.ToString()); } return(null); }
public async Task <JsonResult> GetHomePage() { try { NewsOprations np = new NewsOprations(); DataSet ds = await Task.Run(() => np.GetHomePage()); if (ds == null) { return(null); } var result = new { latest = JsonConvert.SerializeObject(ds.Tables[0], Formatting.None), datacat = JsonConvert.SerializeObject(ds.Tables[1], Formatting.None), svmenu = JsonConvert.SerializeObject(ds.Tables[2], Formatting.None), plrnw = JsonConvert.SerializeObject(ds.Tables[3], Formatting.None), phtnw = JsonConvert.SerializeObject(ds.Tables[4], Formatting.None) }; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Log.Error(ex.ToString()); } return(null); }
public async Task <JsonResult> GetNewsData(decimal Id) { try { NewsOprations np = new NewsOprations(); DataSet ds = await Task.Run(() => np.GetNewPost(Id, 2)); if (ds == null) { return(null); } var result = new { latest = JsonConvert.SerializeObject(ds.Tables[0], Formatting.None), popular = JsonConvert.SerializeObject(ds.Tables[1], Formatting.None), related = JsonConvert.SerializeObject(ds.Tables[2], Formatting.None), Prev = JsonConvert.SerializeObject(ds.Tables[3], Formatting.None), Next = JsonConvert.SerializeObject(ds.Tables[4], Formatting.None) }; return(Json(result, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Log.Error(ex.ToString()); } return(null); }
public async Task <ActionResult> News(string Category, int?Year, int?Month, decimal?Id, string SlugUrl) { try { NewsOprations np = new NewsOprations(); DataSet ds = await Task.Run(() => np.GetNewPost(Id.Value, 1)); if (ds == null) { return(View()); } ViewBag.Url = HttpContext.Request; return(View(ds.Tables[0])); } catch (Exception ex) { Log.Error(ex.ToString()); } return(View()); }
public async System.Threading.Tasks.Task <JsonResult> GetAnalytics(string mode = "mine") { try { var currentUser = (ClaimsPrincipal)Thread.CurrentPrincipal; var UserId = currentUser.Claims.Where(x => x.Type == ClaimTypes.PrimarySid).Select(c => c.Value).SingleOrDefault(); if (mode != "mine") { UserId = "0"; } NewsOprations newsList = new NewsOprations(); var item = await Task.Run(() => newsList.GetAnalytics(Convert.ToInt32(UserId))); return(Json(new { TotPst = JsonConvert.SerializeObject(item.Tables[0]), TotView = JsonConvert.SerializeObject(item.Tables[1]), TdayYday = JsonConvert.SerializeObject(item.Tables[2]), Wkly = JsonConvert.SerializeObject(item.Tables[3]), Monthly = JsonConvert.SerializeObject(item.Tables[4]), DayView = JsonConvert.SerializeObject(item.Tables[5]), WkView = JsonConvert.SerializeObject(item.Tables[6]), MonthView = JsonConvert.SerializeObject(item.Tables[7]) }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Log.Error(ex.ToString()); } return(null); }
public JsonResult GetAllNews(int?page, DateTime?startdt, DateTime?enddt) { try { NewsOprations oprations = new NewsOprations(); var currentUser = (ClaimsPrincipal)Thread.CurrentPrincipal; var UserId = currentUser.Claims.Where(x => x.Type == ClaimTypes.PrimarySid).Select(c => c.Value).SingleOrDefault(); var Role = currentUser.Claims.Where(x => x.Type == ClaimTypes.Role).Select(c => c.Value).SingleOrDefault(); int currentuseid = int.Parse(UserId); if (Role == "SuperAdmin" || Role == "Admin") { currentuseid = 0; } var item = oprations.GetAllNews(0, currentuseid, 0, page.Value, startdt, enddt); return(Json(new { data = JsonConvert.SerializeObject(item.Tables[0]), total_pages = JsonConvert.SerializeObject(item.Tables[1]) }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { Log.Error(ex.ToString()); } return(Json(null)); }
public JsonResult NewsPost(ClsPost clsPost) { try { var currentUser = (ClaimsPrincipal)Thread.CurrentPrincipal; var UserId = currentUser.Claims.Where(x => x.Type == ClaimTypes.PrimarySid).Select(c => c.Value).SingleOrDefault(); var Role = currentUser.Claims.Where(x => x.Type == ClaimTypes.Role).Select(c => c.Value).SingleOrDefault(); clsPost.IsReviewed = false; clsPost.CreatedBy = int.Parse(UserId); if (clsPost.IsSchedule == false) { if (Role == "SuperAdmin" || Role == "Admin") { clsPost.ReviewedBy = int.Parse(UserId); clsPost.IsReviewed = true; } } clsPost.PostedOn = DateTime.Now; clsPost.PostedDate = DateTime.Now; clsPost.PostedYear = DateTime.Now.Year; clsPost.PostedMonth = DateTime.Now.Month; clsPost.SlugUrl = UrlGenerator.GetUrl(clsPost.EnglishTitle); NewsOprations oprations = new NewsOprations(); decimal i = oprations.NewsPost(clsPost); if (i > 0) { Task.Factory.StartNew(() => new NewsOprations().UpdateData()); if (clsPost.IsSchedule == true) { try { SchdulePostConfig schPostConfig = new SchdulePostConfig(); if (schPostConfig != null) { schPostConfig.PostId = i; schPostConfig.PostedOn = DateTime.Now; schPostConfig.ScheduleTime = DateTime.Now.AddHours(clsPost.Delay); schPostConfig.TimeDelay = clsPost.Delay; schulepostconfig.Insert(schPostConfig); schulepostconfig.Save(); } } catch (Exception ex) { Log.Error(ex.ToString()); } } if (clsPost.IsSchedule == false) { if (Role == "SuperAdmin" || Role == "Admin") { if (clsPost.IsFacebookPublish == true) { string category = newsType.GetByID(x => x.Id == clsPost.CategoryId).NewsType; var webadrs = ConfigurationManager.AppSettings["webid"]; Task.Factory.StartNew(() => new apiPlugin().pagePublish(clsPost.OdiaTitle, (webadrs + "/News/" + category + "/" + clsPost.PostedYear + "/" + clsPost.PostedMonth + "/" + i + "/" + clsPost.SlugUrl))); } } } return(Json(new { msg = "News Posted Successfully..." }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { msg = "News Posted UnSuccessful..." }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { Log.Error(ex.ToString()); } return(Json(new { msg = "News Posted UnSuccessful..." }, JsonRequestBehavior.AllowGet)); }