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")); } }
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")); } }
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; } }
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); }
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); }
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 } }
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); } } }
public void ShoudlNotDelete(int id) { var result = UserBLO.Delete(id); Assert.AreEqual((int)ResultCode.Fail, result.Code); }
public void ShouldNotUpdatePassword(int id, string password) { var result = UserBLO.UpdatePassword(id, password); Assert.AreEqual((int)ResultCode.Fail, result.Code); }
public void ShoudlNotGetById(int id) { var result = UserBLO.GetById(id); Assert.AreEqual(null, result); }
public void ShouldNotValidatePassword(string password) { var result = UserBLO.ValidatePassword(password); Assert.AreEqual(false, result); }
public void ShouldNotValidateId(int id) { var result = UserBLO.ValidateId(id); Assert.AreEqual(false, result); }
public void ShouldNotValidateCPF(string cpf) { var result = UserBLO.ValidateCPF(cpf); Assert.AreEqual(false, result); }
public void ShouldNotValidatePhone(string phone) { var result = UserBLO.ValidatePhone(phone); Assert.AreEqual(false, result); }
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 ); } }