public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary <string, object>(); if (requestParameters.ContainsKey("Submit")) { string title = requestParameters["NewsTitle"].ToString(); string text = requestParameters["NewsText"].ToString(); IGenericsConnector connector = Framework.Utilities.DataManager.RequestPlugin <IGenericsConnector>(); GridNewsItem item = new GridNewsItem { Text = text, Time = DateTime.Now, Title = title }; item.ID = connector.GetGenericCount(UUID.Zero, "WebGridNews") + 1; connector.AddGeneric(UUID.Zero, "WebGridNews", item.ID.ToString(), item.ToOSD()); response = "<h3>News item added successfully, redirecting to main page</h3>" + "<script language=\"javascript\">" + "setTimeout(function() {window.location.href = \"index.html?page=news_manager\";}, 0);" + "</script>"; return(null); } vars.Add("NewsItemTitle", translator.GetTranslatedString("NewsItemTitle")); vars.Add("NewsItemText", translator.GetTranslatedString("NewsItemText")); vars.Add("AddNewsText", translator.GetTranslatedString("AddNewsText")); vars.Add("Submit", translator.GetTranslatedString("Submit")); return(vars); }
public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest, OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator, out string response) { response = null; var vars = new Dictionary <string, object>(); IGenericsConnector connector = Framework.Utilities.DataManager.RequestPlugin <IGenericsConnector>(); GridNewsItem news; if (requestParameters.ContainsKey("Submit")) { string title = requestParameters["NewsTitle"].ToString(); string text = requestParameters["NewsText"].ToString(); string id = requestParameters["NewsID"].ToString(); news = connector.GetGeneric <GridNewsItem>(UUID.Zero, "WebGridNews", id); if (news != null) { connector.RemoveGeneric(UUID.Zero, "WebGridNews", id); GridNewsItem item = new GridNewsItem { Text = text, Time = news.Time, Title = title, ID = int.Parse(id) }; connector.AddGeneric(UUID.Zero, "WebGridNews", id, item.ToOSD()); response = "<h3>News item editted successfully, redirecting to main page</h3>" + "<script language=\"javascript\">" + "setTimeout(function() {window.location.href = \"index.html?page=news_manager\";}, 0);" + "</script>"; } return(null); } news = connector.GetGeneric <GridNewsItem>(UUID.Zero, "WebGridNews", httpRequest.Query["newsid"].ToString()); if (news != null) { vars.Add("NewsTitle", news.Title); vars.Add("NewsText", news.Text); vars.Add("NewsID", news.ID.ToString()); vars.Add("NewsItemTitle", translator.GetTranslatedString("NewsItemTitle")); vars.Add("NewsItemText", translator.GetTranslatedString("NewsItemText")); vars.Add("EditNewsText", translator.GetTranslatedString("EditNewsText")); vars.Add("Submit", translator.GetTranslatedString("Submit")); } return(vars); }