Пример #1
0
 public ActionResult <string> Delete(string ApiToken, int id)
 {
     if (Helper.ValidateApiToken(ApiToken))
     {
         return(JsonConvert.SerializeObject(UserBLO.Delete(id)));
     }
     else
     {
         return(JsonConvert.SerializeObject("Token inválido"));
     }
 }
Пример #2
0
 public ActionResult <string> UpdatePassword(string ApiToken, int id, string password)
 {
     if (Helper.ValidateApiToken(ApiToken))
     {
         return(JsonConvert.SerializeObject(UserBLO.UpdatePassword(id, password)));
     }
     else
     {
         return(JsonConvert.SerializeObject("Token inválido"));
     }
 }
Пример #3
0
 public ActionResult <string> Update(string ApiToken, UserModel model)
 {
     if (Helper.ValidateApiToken(ApiToken))
     {
         return(JsonConvert.SerializeObject(UserBLO.Update(model)));
     }
     else
     {
         return(JsonConvert.SerializeObject("Token inválido"));
     }
 }
        public void RefreshControl()
        {
            UserBLO userBLO = new UserBLO();

            // Read configuration file
            if (userBLO.GetUserCagegory() == UserCategory.Former)
            {
                this.pictureBox1.Image = Resources.usb;
            }
            else
            {
                this.pictureBox1.Image = Resources.root_directory;
            }
        }
Пример #5
0
            public void ShouldNotValidateModel(string name, string CPF, string phone, string email, string password)
            {
                var model = new UserModel
                {
                    Name     = name,
                    CPF      = CPF,
                    Phone    = phone,
                    Email    = email,
                    Password = password
                };

                var result = UserBLO.ValidateModel(model);

                Assert.AreEqual(false, result);
            }
Пример #6
0
            public void ShouldNotInsertUser(string name, string CPF, string phone, string email, string password)
            {
                var model = new UserModel
                {
                    Name     = name,
                    CPF      = CPF,
                    Phone    = phone,
                    Email    = email,
                    Password = password
                };

                var result = UserBLO.Insert(model);

                Assert.AreEqual((int)ResultCode.Fail, result.Code);
            }
Пример #7
0
    protected void LoginButton_Click(object sender, EventArgs e)
    {
        TextBox   usernameTextBox = UserName;
        TextBox   passwordTextBox = Password;
        Usermodel model           = UserBLO.getUserInfoByUseranme(usernameTextBox.Text, passwordTextBox.Text);

        if (model != null) // redirect
        {
            Session["userid"]      = model.user_id.ToString();
            Session["username"]    = model.first_name;
            Session["useremail"]   = model.Email;
            Session["useraddress"] = model.Address;
            Session["role_type"]   = model.role_type;
            Response.Redirect("Default.aspx");
        }
        else
        {
            //alert
        }
    }
Пример #8
0
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        Usermodel mdl = new Usermodel();

        mdl.first_name = txtFName.Text;
        mdl.last_name  = txtLName.Text;
        mdl.Password   = txtPassword.Text;
        mdl.Email      = txtEmail.Text;
        mdl.Address    = txtAddress.Text;

        int result = UserBLO.CreateUser(mdl);

        if (result == 1)
        {
            if (!ClientScript.IsStartupScriptRegistered("alert"))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(),
                                                        "alert", "alertMe();", true);
            }
        }
    }
Пример #9
0
            public void ShoudlNotDelete(int id)
            {
                var result = UserBLO.Delete(id);

                Assert.AreEqual((int)ResultCode.Fail, result.Code);
            }
Пример #10
0
            public void ShouldNotUpdatePassword(int id, string password)
            {
                var result = UserBLO.UpdatePassword(id, password);

                Assert.AreEqual((int)ResultCode.Fail, result.Code);
            }
Пример #11
0
            public void ShoudlNotGetById(int id)
            {
                var result = UserBLO.GetById(id);

                Assert.AreEqual(null, result);
            }
Пример #12
0
            public void ShouldNotValidatePassword(string password)
            {
                var result = UserBLO.ValidatePassword(password);

                Assert.AreEqual(false, result);
            }
Пример #13
0
            public void ShouldNotValidateId(int id)
            {
                var result = UserBLO.ValidateId(id);

                Assert.AreEqual(false, result);
            }
Пример #14
0
            public void ShouldNotValidateCPF(string cpf)
            {
                var result = UserBLO.ValidateCPF(cpf);

                Assert.AreEqual(false, result);
            }
Пример #15
0
            public void ShouldNotValidatePhone(string phone)
            {
                var result = UserBLO.ValidatePhone(phone);

                Assert.AreEqual(false, result);
            }
Пример #16
0
        private void txtCreate_Click(object sender, EventArgs e)
        {
            try
            {
                checkForm();
                txtUsername.Focus();

                if (txtPassword != txtConfirmPassword &&
                    string.IsNullOrEmpty(txtUsername.Text) &&
                    string.IsNullOrEmpty(txtPassword.Text) &&
                    string.IsNullOrEmpty(txtConfirmPassword.Text))
                {
                    MessageBox.Show
                    (
                        "- Please Confirm password !" +
                        "- field can't empty",
                        "Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error
                    );
                }
                else
                {
                    User newUser = new User
                                   (
                        txtUsername.Text.ToUpper(),
                        txtPassword.Text,
                        txtConfirmPassword.Text
                                   );

                    UserBLO userBLO = new UserBLO(ConfigurationManager.AppSettings["DbFolder"]);

                    if (this.oldUser == null)
                    {
                        userBLO.CreateUser(newUser);
                    }
                    else
                    {
                        userBLO.EditUser(oldUser, newUser);
                    }

                    MessageBox.Show
                    (
                        "Compte creer",
                        "Confirmation",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information
                    );

                    if (callBack != null)
                    {
                        callBack();
                    }

                    if (oldUser != null)
                    {
                        Close();
                    }
                    txtUsername.Clear();
                    txtPassword.Clear();
                    txtConfirmPassword.Clear();
                    Form f = new FrmParent();
                    f.Show();
                    this.Hide();
                }
            }
            catch (TypingException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Typing error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
            catch (DuplicateNameException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Duplicate error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
            catch (KeyNotFoundException ex)
            {
                MessageBox.Show
                (
                    ex.Message,
                    "Not found error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning
                );
            }
            catch (Exception ex)
            {
                ex.WriteToFile();
                MessageBox.Show
                (
                    "An error occurred! Please try again later.",
                    "Erreur",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                );
            }
        }