protected void submitSurvey_btn_Click(object sender, EventArgs e)
        {
            Sample m = new Sample();
            m.AddToFields("website_id", Indicia_WebsiteID);
            m.AddToFields("survey_id", Indicia_SurveyID);
            m.AddToFields("date", DateTime.Now.ToString("yyyy-MM-dd"));

            SubModel smOcc = new SubModel(SubModelType.occurrence);
            smOcc.AddToFields("website_id", Indicia_WebsiteID.ToString());
            SubModel smLoc = new SubModel(SubModelType.location);

            foreach (Control ctrl in survey_pnl.Controls) //these are the 'IndiciaQuestionWrap' divs
            {
                foreach (Control subCtrl in ctrl.Controls)
                {
                    IIndiciaAttributes t = subCtrl as IIndiciaAttributes;
                    if (t == null)
                    { continue; }

                    if (t.IndiciaAttributeJSONID.Contains("smpAttr"))
                    {
                        m.AddToFields(t.IndiciaAttributeJSONID, t.GetValue());
                    }

                    if (t.IndiciaAttributeJSONID.Contains("locAttr"))
                    {
                        smLoc.AddToFields(t.IndiciaAttributeJSONID, t.GetValue());
                    }

                    if (t.IndiciaAttributeJSONID.Contains("occAttr"))
                    {
                        smOcc.AddToFields(t.IndiciaAttributeJSONID, t.GetValue());
                    }
                }
            }

            if (smOcc.HasFields())
            {
                smOcc.AddToFields("taxa_taxon_list_id", "72"); //TODO: this should be implemeted via the species picker
                m.AddSubModel(smOcc);
            }
            if (smLoc.HasFields())
            {
                m.AddSubModel(smLoc);
            }

            // TODO: need to implement method of getting sample location from user. This is outside the scope of this project
            // One way would to implement a web map (OpenLayers, Google, Bing) and get the user to click on location.
            m.AddToFields("entered_sref", "TQ 27647 78433");
            m.AddToFields("entered_sref_system", "OSGB");

            DataService ds = new DataService();
            JavaScriptSerializer jss = new JavaScriptSerializer();
            ds.RequestData.Add("submission", jss.Serialize(m));

            try
            {
                ds.SaveData();
                submitSurveyResponse_ltl.Text = "Thank you, survey submitted";
            }
            catch (ArgumentException ex)
            {
                submitSurveyResponse_ltl.Text = ex.Message;
            }
        }
Beispiel #2
0
 public void AddSubModel(SubModel subModel)
 {
     this._subModels.Add(subModel);
 }