private void InsertUser() { if (!ValidaUser()) return; try { var user = new AppUsers { UserName = txtUserName.Text, UserDescription = txtUserDescription.Text, ProfileID = Convert.ToInt32(cboProfile.SelectedValue), CreatedBy = FrmPrincipal.UserId, Password = "******", Activated = "Y", CreationDate = DateTime.Now }; _db.InsertUser(user); } catch (EntityException ex) { MessageBox.Show(Resources.ERROR_INSERT_USER + ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); cmdSalvar.Enabled = true; return; } _frmUtil.SetMessageError(ref tssStatus, true, "Usuário inserido com sucesso!", AppFormUtil.StatusForm.Success); GetAllUsers(); }
//Limpar as Propriedades public void ClearPropertys() { User = null; InitializePropertys(); }
public void UpdateUser(AppUsers user) { var passwordCrypted = _fn.GetMd5Hash(user.Password); user.Password = passwordCrypted; _db.AppUsers.AddOrUpdate(user); Commit(); }
private void InitializePropertys() { User = new AppUsers(); if (!_db.AppUsers.Any()) { _db.Database.ExecuteSqlCommand("dbo.InitializeDatabase"); } }
public void InsertUser(AppUsers user) { var passwordCrypted = _fn.GetMd5Hash(user.Password); user.Password = passwordCrypted; _db.AppUsers.Add(user); Commit(); }