public wsSQLResult deleteTestDbItem(string TestDbItemID) { wsSQLResult result = new wsSQLResult(); try { narfdaddy2DataContext dc = new narfdaddy2DataContext(); NoteWriterItem item = dc.NoteWriterItems.Where(s => s.numRow == Int32.Parse(TestDbItemID)).FirstOrDefault(); if (item == null) { // We couldn't find a [Customer] record with this ID. result.WasSuccessful = -3; result.Exception = "Could not find a [ListBuilder1] record with ID: " + TestDbItemID.ToString(); return(result); } dc.NoteWriterItems.DeleteOnSubmit(item); dc.SubmitChanges(); result.WasSuccessful = 1; result.Exception = ""; return(result); // Success ! } catch (Exception ex) { result.WasSuccessful = -1; result.Exception = "An exception occurred: " + ex.Message; return(result); // Failed. } }
public wsSQLResult addUserItems(Stream JSONdataStream) { wsSQLResult result = new wsSQLResult(); try { // Read in our Stream into a string... StreamReader reader = new StreamReader(JSONdataStream); string JSONdata = reader.ReadToEnd(); // ..then convert the string into a single "wsCustomer" record. JavaScriptSerializer jss = new JavaScriptSerializer(); var root = jss.Deserialize <List <wsNoteWriterItem> >(JSONdata); if (root == null) { // Error: Couldn't deserialize our JSON string into a "wsCustomer" object. result.WasSuccessful = 0; result.Exception = "Unable to deserialize the JSON data."; return(result); } narfdaddy2DataContext dc = new narfdaddy2DataContext(); foreach (var item in root) { NoteWriterItem newCustomer = new NoteWriterItem() { usr = item.usr, cat = item.cat, subcat = item.subcat, item = item.item, dialog = item.dialog }; dc.NoteWriterItems.InsertOnSubmit(newCustomer); dc.SubmitChanges(); } result.WasSuccessful = 1; result.Exception = ""; return(result); } catch (Exception ex) { result.WasSuccessful = 0; result.Exception = ex.Message; return(result); } }
partial void UpdateNoteWriterItem(NoteWriterItem instance);
partial void DeleteNoteWriterItem(NoteWriterItem instance);
partial void InsertNoteWriterItem(NoteWriterItem instance);