public ActionResult OnPostAlterSinger(string StringID, string StringScore, string StringSequence, int Round, int GroupId) { //验证 if ((StringID != null && int.TryParse(StringID, out int ID)) && (StringScore != null && float.TryParse(StringScore, out float Score)) && (StringSequence != null && int.TryParse(StringSequence, out int Sequence)) && Round != -1 && GroupId > 0 && GroupId <= 4) { string[] keys = { "sequence", string.Format("score{0}", Round.ToString()), "group_id" }; string specifier = string.Format("`ID`={0}", ID); MySqlIntegration sqlInteg = new MySqlIntegration(Configuration.GetConnectionString("sql")); try { sqlInteg.MySqlSelect("singers", new[] { "*" }, specifier); } catch (MySqlException ex) { return(JsonThrow(ex)); } if (sqlInteg.IntegratedResult.Count > 0) { try { sqlInteg.MySqlUpdate("singers", keys, specifier, Sequence, Score.ToString(), GroupId); } catch (MySqlException ex) { return(JsonThrow(ex)); } } return(new JsonResult(sqlInteg.IntegratedResult.Count)); } //返回错误 return(Redirect("https://baidu.com")); }
public ActionResult OnPostSave() { MemoryStream memoryStream = new MemoryStream(); Request.Body.CopyTo(memoryStream); memoryStream.Position = 0; using (StreamReader reader = new StreamReader(memoryStream)) { string result = reader.ReadToEnd(); if (result.Length > 0 || !result.Trim().Equals("")) { PageEntry = JsonConvert.DeserializeObject <Entry>(result); } else { return(new JsonResult(JsonConvert.SerializeObject(0))); } } //变量验证 if (BasicClasses.Find(basicClassObj => basicClassObj.ID == PageEntry.BasicClassID) == null) { PageEntry.BasicClassID = 0; } else { if (IsBasicEntry(PageEntry)) { PageEntry.BasicClassID = BasicClasses.Find(basicClassObj => basicClassObj.UniqueTitle == PageEntry.UniqueTitle).ID; } } PageEntry.PageContent = PageEntry.PageContent.Replace("\\", "\\\\"); PageEntry.PageContent = PageEntry.PageContent.Replace("\'", "\\\'"); string[] keySelect = { "title_unique" }; MySqlIntegration postInteg = new MySqlIntegration(Configuration.GetConnectionString("MySqlConnection")); postInteg.MySqlSelect("entries", keySelect, "title_unique=" + MySqlIntegration.QuoteStr(PageEntry.UniqueTitle)); string[] keysSave = { "title_unique", "basic_class_ID", "title_display", "content" }; int lineAffected; if (postInteg.IntegratedResult.Count > 0) { lineAffected = postInteg.MySqlUpdate("entries", keysSave, "title_unique=" + MySqlIntegration.QuoteStr(PageEntry.UniqueTitle), PageEntry.UniqueTitle, PageEntry.BasicClassID, PageEntry.DisplayTitle, PageEntry.PageContent); } else { lineAffected = postInteg.MySqlInsert("entries", keysSave, PageEntry.UniqueTitle, PageEntry.BasicClassID, PageEntry.DisplayTitle, PageEntry.PageContent); } return(new JsonResult(JsonConvert.SerializeObject(lineAffected))); }