Example #1
0
        public static bool DisableUserAccount(int userId)
        {
            var context = new ClearOfficeEntities();

            try
            {
                var user = context.Users.First(u => u.UserId == userId);
                user.Disabled = user.Disabled.HasValue ? !user.Disabled : true;
                context.SaveChanges();
                return(true);
            }
            catch (Exception exception)
            {
                throw new ApplicationException("Error disabling/enabling user account", exception);
            }
        }
Example #2
0
        public static bool ChangePassword(int userId, string password)
        {
            var context = new ClearOfficeEntities();

            try
            {
                var user = context.Users.First(u => u.UserId == userId);
                user.Password = HashPassword(password);
                context.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #3
0
        public void SaveChanges()
        {
            try
            {
                userDetailBindingSource.EndEdit();
                var user = userDetailBindingSource.Current as User;
                context.Users.AddObject(user);
                context.SaveChanges();
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception exception)
            {
                ViewHelper.ShowErrorMessage("Error adding new record", exception);
            }

            this.Close();
        }