Exemplo n.º 1
0
 //We can add an existing product too
 public Boolean AddEditor(Editor editor)
 {
     var editorBl = new EditorBL();
     if (editorBl.IsEditorExist(editor.GetUserName()))
     {
         return false;
     }
     _editorDal.AddEditor(editor);
     return true;
 }
Exemplo n.º 2
0
        protected void RegisterButton_Click(object sender, EventArgs e)
        {
            var textboxes = Controls.FindAll().OfType<TextBox>();
            var validator = textboxes.Any(t => t.Text.Trim().Equals(""));

            var firstName = FirstNameTextBox.Text.Trim();
            var lastName = LastNameTextBox.Text.Trim();
            var userName = UserNameTextBox.Text.Trim();
            var password = PasswordTextBox.Text.Trim();
            var email = EmailTextBox.Text.Trim();

            if (validator)
            {
                if (firstName.Equals(""))
                {
                    FirstName_Validator.Visible = true;
                }
                if (lastName.Equals(""))
                {
                    LastName_Validator.Visible = true;
                }
                if (userName.Equals(""))
                {
                    UserName_Validator.Text = "you have to enter username";
                    UserName_Validator.Visible = true;
                }
                if (password.Equals(""))
                {
                    Password_Validator.Visible = true;
                }
                if (email.Equals(""))
                {
                    Email_Validator.Visible = true;
                }
            }
            else
            {
                var editor = new Editor(firstName, lastName, userName, password, email, 0);
                var editorBL = new EditorBL();
                if (editorBL.AddEditor(editor))
                {
                    SendMail(firstName, lastName, userName, email);
                    RegisterTable.Visible = false;
                    ThankYouLabel.Visible = true;
                }
                else
                {
                    UserName_Validator.Text = "Username already exist";
                    UserName_Validator.Visible = true;
                }
            }
        }
Exemplo n.º 3
0
 protected void LoginButton_Click(object sender, EventArgs e)
 {
     var userName = UsernameTextBox.Text.Trim();
     var password = PasswordTextBox.Text.Trim();
     var validateEmpty = userName.Equals("") || password.Equals("");
     if (validateEmpty)
     {
         if (userName.Equals(""))
         {
             Username_Validator.Visible = true;
         }
         if (password.Equals(""))
         {
             Password_Validator.Visible = true;
         }
     }
     else
     {
         var editorBL = new EditorBL();
         var editor = editorBL.GetEditor(userName);
         if (editor != null)
         {
             if (editor.GetAuthorized() == 1)
             {
                 Response.Redirect("~/EditorFolder/EditorsDefault.aspx");
             }
             else
             {
                 RegisterLink.Visible = false;
                 LoginTable.Visible = false;
                 SorryLabel.Visible = true;
             }
         }
         else
         {
             ErrorLabel.Visible = true;
         }
     }
 }