Ejemplo n.º 1
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            try
            {
                Page.Validate("vgRegister");
                if (Page.IsValid)
                {
                    if (!IsUserNameExist(txtUserName.Text))
                    {
                        BupaUser objUser = new Data.BupaUser();
                        objUser.Firstname = txtFirstName.Text;
                        objUser.LastName  = txtLastName.Text;
                        objUser.UserName  = txtUserName.Text;
                        objUser.Password  = txtPassword.Text;

                        _context.Insert(objUser);
                        _context.SaveChanges();
                        ClearInput();
                        ShowMessage("Registration successful !!!", string.Empty);
                    }
                    else
                    {
                        ShowMessage("Useranme already exist", "warning");
                    }
                }
            }
            catch (Exception ex)
            {
                ShowMessage("Something went wrong. Please try again after sometime", "warning");
            }
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                Page.Validate("vgLogin");
                if (Page.IsValid)
                {
                    BupaUser objUser = new Data.BupaUser();
                    objUser.UserName = txtUserName.Text;
                    objUser.Password = txtPassword.Text;

                    if (_context.IsValidCredentials(objUser))
                    {
                        AddUserCookie(objUser.UserName);
                        Response.Redirect("~/Programs");
                    }
                    else
                    {
                        ShowMessage("Invalid credentials", "warning");
                    }
                }
            }
            catch (Exception ex)
            {
                ShowMessage("Something went wrong. Please try again after sometime", "warning");
            }
        }
Ejemplo n.º 3
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                Page.Validate("vgMyProfile");
                if (Page.IsValid)
                {
                    BupaUser objUser = new Data.BupaUser();
                    objUser.UserId    = Convert.ToInt32(txtUserId.Text);
                    objUser.Firstname = txtFirstName.Text;
                    objUser.LastName  = txtLastName.Text;
                    objUser.UserName  = txtUserName.Text;
                    objUser.Password  = txtPassword.Text;

                    _context.Update(objUser);
                    _context.SaveChanges();
                    ShowMessage("Profile updated successfully!", string.Empty);
                }
            }
            catch (Exception ex)
            {
                ShowMessage("Something went wrong. Please try again after sometime", "warning");
            }
        }