// GET: LatestNews public ActionResult Index(string MsgSerialNo) { LatestNews model = new LatestNews(); try { //if (Session["INSTNO"] == null || string.IsNullOrEmpty(Session["INSTNO"].ToString())) //{ // //Log.Error(ex + ex.StackTrace); // TempData["SessionExipred"] = "true"; // //TempData["error"] = ex + ex.StackTrace; // //tran.Rollback(); // return RedirectToAction("Index", "Login", null); //} MysqlDBA <MessageRec> mysqlDBA = new MysqlDBA <MessageRec>(FunctionController.CONNSTR); MessageRec messageRec = new MessageRec(); messageRec.MsgSerialNo = int.Parse(MsgSerialNo); messageRec = Utility.Utility.getUniqueMessageRec(Utility.Utility.getMessageDataSet(mysqlDBA, messageRec));// (List<MessageRec>)mysqlDBA.getDataSet(string.Format("SELECT * FROM ")); model.MsgData = messageRec.MsgData; model.MsgSerialNo = messageRec.MsgSerialNo.ToString(); model.MsgSub = messageRec.MsgSub; model.Attachs = messageRec.Attachs; model.CreateDate = messageRec.CreateDate; } catch (Exception ex) { Log.Error(ex + ex.StackTrace); TempData["action"] = "latest"; TempData["error"] = ex + ex.StackTrace; return(RedirectToAction("Index", "Home", null)); } return(View(model)); }
public IActionResult AddLatestNews(LatestNews latestNews) { if (latestNews == null) { return(Json(new { code = 1, msg = "FALSE", count = 0, data = string.Empty })); } var news = _latestNewsManager.LoadEntities(x => x.Id == latestNews.Id).FirstOrDefault(); if (news != null) { news.IsOpen = latestNews.IsOpen; news.NewsName = latestNews.NewsName; news.NewsUrl = latestNews.NewsUrl; if (_latestNewsManager.EditEntity(news)) { return(Json(new { code = 0, msg = "SUCCESS", count = 1, data = string.Empty })); } } news = new LatestNews() { IsOpen = latestNews.IsOpen, NewsName = latestNews.NewsName, NewsUrl = latestNews.NewsUrl, }; var result = _latestNewsManager.AddEntity(news); if (result != null) { return(Json(new { code = 0, msg = "SUCCESS", count = 1, data = string.Empty })); } return(Json(new { code = 1, msg = "FALSE", count = 0, data = string.Empty })); }
public async Task <ActionResult> Create_News(LatestNews c, HttpPostedFileBase img) { var santizer = new HtmlSanitizer(); if (ModelState.IsValid) { LatestNews l = new LatestNews(); l.Title = c.Title; l.Content = santizer.Sanitize(Server.HtmlEncode(c.Content)); l.EntryDate = DateTime.UtcNow; l.Url = c.Url; l.ImageUrl = c.ImageUrl; if (img != null) { byte[] im = new byte[img.InputStream.Length]; img.InputStream.Read(im, 0, (int)img.InputStream.Length); l.Image = im; } db.News.Add(l); await db.SaveChangesAsync(); TempData["success"] = "Latest News Registration is Successfull"; return(Redirect(Request.UrlReferrer.ToString())); } ModelState.AddModelError("", "Correct your errors!"); return(View()); }
public LatestNews getNewsDetail(int id) { LatestNews objLatestNews = null; using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand command = new SqlCommand("", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@id", id); objReader = objCommand.ExecuteReader(); if (objReader.HasRows) { while (objReader.Read()) { objLatestNews = new LatestNews(); objLatestNews.newsId = (int)objReader["newsId"]; objLatestNews.Image = objReader["Image"].ToString(); objLatestNews.Header = objReader["Header"].ToString(); objLatestNews.NewsDescription = objReader["NewsDescription"].ToString(); objLatestNews.SchoolId = (int)objReader["SchoolId"]; } } } return(objLatestNews); }
public ActionResult Index() { //if (Session["INSTNO"] == null || string.IsNullOrEmpty(Session["INSTNO"].ToString())) //{ // TempData["SessionExipred"] = "true"; // return RedirectToAction("Index", "Login", null); //} List <LatestNews> ViewModel = new List <LatestNews>(); List <MessageRec> dataSet = null; //List<AccountBase> retObj = null; try { MysqlDBA <MessageRec> mysqlDBA = new MysqlDBA <MessageRec>(FunctionController.CONNSTR); MessageRec messageRec = new MessageRec(); dataSet = (List <MessageRec>)mysqlDBA.getAllDataList(messageRec); dataSet.ForEach(obj => { LatestNews obj1 = new LatestNews(); obj1.MsgSerialNo = obj.MsgSerialNo.ToString(); obj1.MsgSub = obj.MsgSub; obj1.Attachs = obj.Attachs; obj1.CreateDate = obj.CreateDate; ViewModel.Add(obj1); }); TempData["action"] = "latest"; } catch (Exception ex) { Log.Error(ex + ex.StackTrace); TempData["action"] = "latest"; TempData["error"] = ex + ex.StackTrace; return(RedirectToAction("Index", "Home", null)); } return(View(ViewModel)); }
private async void LoadNewsList() { try { IsBusy = true; if (_connectivity.NetworkAccess != NetworkAccess.Internet) { Device.BeginInvokeOnMainThread(() => { _dialogService.DisplayAlert(AppResources.ConnectionPleaseCheckInternet); }); return; } LatestNews latestNews = await _newsService.GetLatestNews(); NewsItems = new ObservableCollection <Source>(latestNews.sources); } catch (Exception ex) { _dialogService.DisplayError(ex); } finally { IsBusy = false; } }
public IActionResult AddLatestNews(int latestNewsId) { LatestNews news = new LatestNews(); if (latestNewsId == 0) { return(View(news)); } news = _latestNewsManager.LoadEntities(x => x.Id == latestNewsId).FirstOrDefault(); if (news == null) { news = new LatestNews(); } return(View(news)); }
private async Task UpdateLatestNewsAsync(bool isForce = false) { IsProblem = false; try { DispatcherHelper.UIDispatcher.BeginInvoke( delegate { IsRefreshingLatestNews = true; if (LatestNews == null) { LatestNews = new ObservableCollection <Article>(); } LatestNews.Clear(); }); var tempArticles = await _dataService.GetArticlesAsync(DataService.LATESTNEWS, isForce); if (tempArticles != null && tempArticles.Count > 0) { DispatcherHelper.UIDispatcher.BeginInvoke( delegate { if (Categories == null) { Categories = new ObservableCollection <Category>(); _dataService.ListOfCategories.ForEach(o => Categories.Add(o)); } Category categoryDetails = Categories.FirstOrDefault(o => o.CategoryName.ToLower() == DataService.LATESTNEWS.ToLower()); foreach (var article in tempArticles.ToList()) { LatestNews.Add(article); } IsRefreshingLatestNews = false; }); } else { IsProblem = true; IsRefreshingLatestNews = false; } } catch (Exception ex) { } }
public Message createNews(LatestNews news) { Message msg = null; using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand command = new SqlCommand("", connection); msg = new Message(); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@newsId", news.newsId); command.Parameters.AddWithValue("@Image", news.Image); command.Parameters.AddWithValue("@Header", news.Header); command.Parameters.AddWithValue("@NewsDescription", news.NewsDescription); command.Parameters.AddWithValue("@SchoolId", news.SchoolId); command.Parameters.AddWithValue("@CreateBy", news.CreateBy); command.Parameters.AddWithValue("@UpdatedBy", news.UpdatedBy); msg.status = objCommand.ExecuteNonQuery(); } return(msg); }
public Message editNews(LatestNews news) { throw new NotImplementedException(); }
public CustomList <LatestNews> GetAllLatestNewsForDisplay() { return(LatestNews.GetAllLatestNewsForDisplay()); }
public CustomList <LatestNews> GetAllLatestNews() { return(LatestNews.GetAllLatestNews()); }