protected void Tag_Click(object sender, EventArgs e)
        {
            var oldSettings = settingsBLL.getSettingsByUserId(hdnUserID.Value);

            if (oldSettings != null)
            {
                oldSettings.UserId = null;
                var oldResult = settingsBLL.update(oldSettings);

                if (oldResult == null)
                {
                    lblModal.Text = "Failed to update";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "myModal", "$('#divPopUp').modal('show');", true);
                    return;
                }
            }
            var setting = settingsBLL.getSettingsByAppId(ddlAppId.SelectedValue);

            setting.UserId = hdnUserID.Value;

            var newSetting = settingsBLL.update(setting);

            if (newSetting != null)
            {
                Response.Redirect(Request.RawUrl);
            }
            else
            {
                lblModal.Text = "Failed to update";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "myModal", "$('#divPopUp').modal('show');", true);
            }
        }
예제 #2
0
        protected void Save_Click(object sender, EventArgs e)
        {
            string appId = repo.Session_Get("uAppId");

            Settings setting = settingsBLL.getSettingsByAppId(appId);

            if (string.IsNullOrEmpty(sendTime.Text))
            {
                lblModal.Text = "Time to send is required";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "myModal", "$('#divPopUp').modal('show');", true);
                return;
            }
            if (string.IsNullOrEmpty(areaMsgTemplate.Text))
            {
                lblModal.Text = "Message is required";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "myModal", "$('#divPopUp').modal('show');", true);
                return;
            }

            TimeSpan minusTimeZone = TimeSpan.FromHours(repo.SubtractLocalTimeZone);
            TimeSpan cycleTimeZone = TimeSpan.FromHours(repo.CycleLocalTimeZone);

            setting.Scheduletime    = TimeSpan.Parse(sendTime.Text).Hours < (repo.SubtractLocalTimeZone * -1) ? TimeSpan.Parse(sendTime.Text).Add(cycleTimeZone) : TimeSpan.Parse(sendTime.Text).Add(minusTimeZone);
            setting.MessageTemplate = areaMsgTemplate.Text;

            Settings newSettings = settingsBLL.update(setting);

            if (newSettings != null)
            {
                lblModal.Text = "Update success";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "myModal", "$('#divPopUp').modal('show');", true);
            }
            else
            {
                lblModal.Text = "Failed to update";
                ScriptManager.RegisterStartupScript(this, this.GetType(), "myModal", "$('#divPopUp').modal('show');", true);
            }
        }