Пример #1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            MyDataModel context = new MyDataModel();

            string email    = tbxEmail.Text;
            string password = tbxPassword.Text;

            T_ACCOUNT existingAccount = T_ACCOUNTservice.GetAccountByEmail(context, email);

            if (existingAccount == null)
            {
                lblError.Text = string.Format("Email '{0}' isn't registered.", email);
            }
            else if (existingAccount.Active == false)
            {
                lblError.Text = string.Format("Email '{0}' is blocked.", email);
            }
            else if (existingAccount.Password != password)
            {
                lblError.Text = "Invalid password.";
            }
            else
            {
                FormsAuthentication.SetAuthCookie(email, false);
                FormsAuthentication.RedirectFromLoginPage(email, false);
            }
        }
Пример #2
0
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            MyDataModel context = new MyDataModel();

            tbxEmail.BorderColor = Color.Empty;

            string email    = tbxEmail.Text.Trim();
            string password = tbxPassword.Text.Trim();

            if (T_ACCOUNTservice.GetAccountByEmail(context, email) != null)
            {
                lblConfirmation.Text    = Messages.errorMailExists;
                lblConfirmation.Visible = true;
                tbxEmail.BorderColor    = Color.Red;
            }
            else
            {
                string    name       = tbxFirstName.Text;
                string    surname    = tbxSecondName.Text;
                bool      isMale     = dlstGender.SelectedItem.Text == "Male" ? true : false;
                T_ACCOUNT newAccount = new T_ACCOUNT()
                {
                    Email = email, Password = password, Name = name, Surname = surname, IsMale = isMale, Active = true
                };
                context.T_ACCOUNT.Add(newAccount);
                context.SaveChanges();
                lblConfirmation.Text    = string.Format("email '{0}' registered successfully", email);
                lblConfirmation.Visible = true;
                btnConfirm.Enabled      = false;
            }
        }
Пример #3
0
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            MyDataModel context  = new MyDataModel();
            string      userName = Page.User.Identity.Name;
            T_ACCOUNT   account  = T_ACCOUNTservice.GetAccountByEmail(context, userName);
            T_GOAL      newGoal  = T_GOALservice.AddNewGoal(context, userName, account);

            Response.Redirect("~/_GoalPage.aspx?GoalID=" + newGoal.GoalID);
        }