private void Bot_OnMessage(object sender, MessageEventArgs e)
        {
            var text = e?.Message?.Text;

            bot.SendTextMessageAsync(e.Message.Chat.Id, $"Site {text} has been saved");
            var controller = new SiteController();

            controller.AddSite(text, currentUser, sitePassword);
            bot.StopReceiving();
            bot.OnMessage -= Bot_OnMessage;
        }
Beispiel #2
0
    /// <summary>
    /// An on-click method that adds a site to the database, adds assigns a new survey word to the site, and adds a "Not Applicable" unit associated with the new site.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void AddSite_Click(object sender, EventArgs e)
    {
        SiteController       sysmgr    = new SiteController();
        SurveyWordController swControl = new SurveyWordController();
        UnitController       unControl = new UnitController();

        string siteName = AddSiteTextBox.Text.Trim();
        int    admin    = int.Parse(Session["adminID"].ToString());

        MessageUserControl.TryRun(() =>
        {
            sysmgr.AddSite(siteName, admin);            // adds the site to the database
            swControl.NewSite_NewWord(siteName);        // assigns a survey word to the site
            unControl.NewSite_NewUnit(siteName, admin); // adds the Not Applicable Unit option to the site

            ListView1.DataBind();
            AddSiteTextBox.Text = "";
        }, "Success", "Successfully added the new site: \"" + siteName + "\"");
    }
Beispiel #3
0
        // Sites

        private void btnSitesSave_Click(object sender, EventArgs e)
        {
            // Valiations:

            if (tbSiteName.Text.Length == 0)
            {
                errorProvider.SetError(tbSiteName, "Must provide a value.");
            }
            else
            {
                errorProvider.SetError(tbSiteName, "");
            }

            if (tbSiteLongtitude.Text.Length == 0)
            {
                errorProvider.SetError(tbSiteLongtitude, "Must provide a value.");
            }
            else
            {
                errorProvider.SetError(tbSiteLongtitude, "");
            }

            if (tbSiteLatitude.Text.Length == 0)
            {
                errorProvider.SetError(tbSiteLatitude, "Must provide a value.");
            }
            else
            {
                errorProvider.SetError(tbSiteLatitude, "");
            }

            if (cbSiteLongtitudeType.SelectedIndex == -1)
            {
                errorProvider.SetError(cbSiteLongtitudeType, "Must provide a value.");
            }
            else
            {
                errorProvider.SetError(cbSiteLongtitudeType, "");
            }

            if (cbSiteLatitudeType.SelectedIndex == -1)
            {
                errorProvider.SetError(cbSiteLatitudeType, "Must provide a value.");
            }
            else
            {
                errorProvider.SetError(cbSiteLatitudeType, "");
            }

            // Save new/changes:

            int    id         = 0;
            string name       = tbSiteName.Text;
            float  longtitude = float.Parse(tbSiteLongtitude.Text);
            float  latitude   = float.Parse(tbSiteLatitude.Text);

            Site.LongtitudeTypes longtitudeType = (Site.LongtitudeTypes)cbSiteLongtitudeType.SelectedIndex;
            Site.LatitudeTypes   latitudeType   = (Site.LatitudeTypes)cbSiteLatitudeType.SelectedIndex;

            if (emSites == EditingModes.Add)
            {
                id = 0;
            }
            else
            {
                id = currentSite.Id;
            }

            Site candidate = new Site(id, name, longtitude, longtitudeType, latitude, latitudeType);;

            if (emSites == EditingModes.Add)
            {
                id = SiteController.AddSite(candidate);
            }
            else
            {
                SiteController.EditSite(id, candidate);
            }

            // Reload data:

            lblStatus.Text = "Issuing sites saving command... ";
            currentSite    = SiteController.GetSites(new List <int>()
            {
                id
            })[0];
            LoadSiteData(currentSite);
            PrepareDataLists();
            lblStatus.Text += "Complete.";
        }