protected void Delete_Click(object sender, EventArgs e)
        {
            //Get the button that raised the event
            Button btn = (Button)sender;

            //Get the row that contains this button
            GridViewRow gvr = (GridViewRow)btn.NamingContainer;

            string id = gvr.Cells[0].Text;

            var userStore   = new UserStore <IdentityUser>();
            var userManager = new UserManager <IdentityUser>(userStore);
            var user        = userManager.FindById(id);

            if (user != null)
            {
                var oldSettings = settingsBLL.getSettingsByUserId(id);

                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;
                    }
                }

                userStore.DeleteAsync(user);

                UsersGV.DataSource = usersBLL.getAllUsers();
                UsersGV.DataBind();
                Response.Redirect(Request.RawUrl);
            }
            else
            {
                lblModal.Text = "Failed to delete account";
                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);
            }
        }