Beispiel #1
0
        public CheckResult DeleteUser(UserModel focusedUser)
        {
            CheckResult check = CheckResult.Default;
            using (var db = DbManager.CreateInstance())
            {
                try
                {
                    UserRepository rep = new UserRepository();
                    rep.DeleteUser(db, focusedUser);
                    db.SaveChanges();
                    this.Users.Remove(focusedUser);
                }
                catch (Exception ex)
                {
                    check.Details.Add(new CheckResultDetail(CheckResultDetail.ErrorType.Error, "InvalidDeletion", "Cannot delete this user!"));
                    return check;
                }

                return check;
            }
        }
Beispiel #2
0
        public CheckResult DeleteUser(UserModel focusedUser)
        {
            CheckResult check = CheckResult.Default;
            using (var db = DbManager.CreateInstance())
            {
                try
                {
                    UserRepository rep = new UserRepository();
                    rep.DeleteUser(db, focusedUser);
                    db.SaveChanges();
                    this.Users.Remove(focusedUser);
                }
                catch (NullReferenceException nREx)
                {
                    //TODO Log
                    check.Details.Add(new CheckResultDetail(CheckResultDetail.ErrorType.Error, "", nREx.Message));
                    return check;
                }
                catch (DataStoreException)
                {
                    check.Details.Add(
                        new CheckResultDetail(
                            CheckResultDetail.ErrorType.Error,
                            "InvalidDeletion",
                            Messages.CannotDeleteLinkedItem));
                    return check;
                }
                catch (Exception)
                {
                    //TODO Log
                    check.Details.Add(
                        new CheckResultDetail(
                            CheckResultDetail.ErrorType.Error,
                            "InvalidDeletion",
                            "Deletion failed!"));
                    return check;
                }

                return check;
            }
        }