Exemplo n.º 1
0
        public wsSQLResult addUserTips(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)
                {
                    NoteWriterTip newCustomer = new NoteWriterTip()
                    {
                        usr    = item.usr,
                        cat    = item.cat,
                        subcat = item.subcat,
                        item   = item.item,
                        dialog = item.dialog
                    };

                    dc.NoteWriterTips.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 UpdateNoteWriterTip(NoteWriterTip instance);
 partial void DeleteNoteWriterTip(NoteWriterTip instance);
 partial void InsertNoteWriterTip(NoteWriterTip instance);