public async virtual Task <Message> Get(Message message) { try { var resultMessage = new Message(); var model = message.DeSerializeObject <Model.User>(); bool isValid = false; using (var repository = new User_Repository(message.Connection)) { var returnObject = await repository.Get(model); Encryption encryption = new Encryption("8464261197043003"); string password = encryption.CreatePasswordHash(model.Password, returnObject.Password_Salt, ""); isValid = password == returnObject.Password; if (!isValid) { returnObject = new Model.User(); } resultMessage.Status = Status.Success; resultMessage.Result = "Proceso efectuado satisfactoriamente..."; resultMessage.MessageInfo = returnObject.SerializeObject(); return(resultMessage); } } catch (Exception ex) { var resultMessage = new Message(); resultMessage.Status = Status.Failed; resultMessage.Result = string.Format("{ 0}", ex.Message); resultMessage.MessageInfo = string.Empty; return(resultMessage); } }
private void btn_signin_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(this.txt_email.Text) || String.IsNullOrEmpty(this.txt_password.Text)) { MessageBox.Show("Please Insert Informations"); } else { User_Table user = new User_Table(); user = User_Repository.GetUserDetail(this.txt_email.Text, this.txt_password.Text); if (object.ReferenceEquals(null, user) || object.Equals(null, user)) { MessageBox.Show("No User Found"); return; } else { if (user.email == this.txt_email.Text && user.password == this.txt_password.Text) { if (user.role == "Admin") { DashBoard adminDash = new DashBoard(this, user); this.Hide(); adminDash.ShowDialog(); } else if (user.role == "Donor") { DashBoard donorDash = new DashBoard(this, user); this.Hide(); donorDash.ShowDialog(); } else if (user.role == "Requester") { DashBoard requesterDash = new DashBoard(this, user); this.Hide(); requesterDash.ShowDialog(); } } else { MessageBox.Show("No User Found"); } } } }
public AccountController(User_Repository repo) { _db = repo; }
private void btn_signUp_Click(object sender, EventArgs e) { var name = this.txt_name.Text; var email = this.txt_email.Text; var password = this.txt_password.Text; var retypePass = this.txt_retypePass.Text; var phone = this.txt_phone.Text; var address = this.txt_address.Text; var terms = this.chk_terms.Checked; var role = this.cmb_role.Text; var blood_group = this.cmb_bloodGroup.Text; if (String.IsNullOrEmpty(phone)) { this.user.phone = ""; } else if (String.IsNullOrEmpty(address)) { this.user.address = ""; } else if (String.IsNullOrEmpty(this.user.image)) { this.user.image = null; } else { this.user.address = address; this.user.phone = phone; } if (terms == true) { if (String.IsNullOrEmpty(name) || String.IsNullOrEmpty(email) || String.IsNullOrEmpty(password) || String.IsNullOrEmpty(retypePass) || String.IsNullOrEmpty(role) || String.IsNullOrEmpty(blood_group)) { MessageBox.Show("Please insert all informations.."); } else { if (String.IsNullOrEmpty(password) || String.IsNullOrEmpty(retypePass) && !password.Equals(retypePass)) { MessageBox.Show("Please insert same password.."); } else { bool validEmail = User_Repository.CheckUserExist(email); if (validEmail == true) { this.user.name = name; this.user.email = email; this.user.password = password; this.user.role = role; this.user.join_date = DateTime.Now; var insert = User_Repository.InsertUser(this.user); if (insert == true) { if (!String.IsNullOrEmpty(this.user.image)) { string destFile = Path.Combine(targetPath, this.user.image); File.Copy(this.file_path, destFile); } this.Hide(); new LoginForm().ShowDialog(); } else { MessageBox.Show("Error 404\n\n"); } } else { MessageBox.Show("Error 404..."); this.Hide(); new LoginForm().ShowDialog(); } } } } else { MessageBox.Show("Terms and Conditions not selected.."); } }