Exemplo n.º 1
0
        public async Task <ActionResult <DeleteUserResult> > DeleteUser(string id)
        {
            var currentUser = await _currentUser.GetUserAsync();

            var isAdmin = await _currentUser.IsUserAdminAsync();

            DeleteUserResult result = new DeleteUserResult();

            if (!(currentUser.Id == id || isAdmin))
            {
                result.IsSuccessful = false;
                result.ErrorMessages.Add("Not authorized");
                return(Unauthorized(result));
            }

            await _userGroupRepo.DeleteAllOfUser(id);

            await _userGroupRepo.RemoveUserFromAllGroups(id);

            await _shoppingListRepo.DeleteAllOfUser(id);


            result = await _authService.DeleteUser(new DeleteUserModel { UserId = id });

            return(Ok(result));
        }
Exemplo n.º 2
0
        /*************************************************************************************************/
        public DeleteUserResult DeleteUser(User user)
        {
            DeleteUserResult result = DeleteUserResult.Failed;

            if (user != null)
            {
                User getUser = _dbcontext.GetUserByUsername(user.Username);

                if (getUser != null)
                {
                    bool success = _dbcontext.DeleteUser(getUser);

                    if (success)
                    {
                        result = DeleteUserResult.Success;
                    }
                }
                else
                {
                    result = DeleteUserResult.Failed;
                }
            }

            return(result);
        }
        public JsonResult DeleteUser(string strUserId)
        {
            try
            {
                string[] strUser = strUserId.Split(',');
                strUserId = string.Empty;
                foreach (var item in strUser)
                {
                    strUserId += item.Decode() + ",";
                }

                strUserId = strUserId.Substring(0, strUserId.Length - 1);
                DeleteUserResult result = _objiClsUser.DeleteUser(strUserId, _mySession.UserId);
                if (result != null && result.TotalReference == 0)
                {
                    return(Json(_alertTextProvider.AlertMessage("User", MessageType.DeleteSuccess)));
                }
                else if (result != null && result.TotalReference > 0)
                {
                    return(Json(_alertTextProvider.AlertMessage("User", MessageType.DeletePartial, result.Name)));
                }

                return(Json(_alertTextProvider.AlertMessage("User", MessageType.DeleteFail)));
            }
            catch (Exception ex)
            {
                Logger.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.User, _mySession.UserId);
                return(Json(_alertTextProvider.AlertMessage("User", MessageType.DeleteFail)));
            }
        }
Exemplo n.º 4
0
        public ActionResult Delete(int id)
        {
            UserSessionObject user   = Session.GetUser();
            DeleteUserResult  result = UserService.Delete(id, user);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        public async Task UnsyncUserAsync(Guid userId, Guid scimAppSettingsId)
        {
            ScimUserSyncState syncState = await _authDbContext
                                          .ScimUserSyncStates
                                          .SingleAsync(s => s.SCIMAppSettings.Id == scimAppSettingsId && s.User.Id == userId);

            Gatekeeper.SCIM.Client.Client scimClient = await GetScimClient(scimAppSettingsId);

            DeleteUserAction deleteUser       = new DeleteUserAction(syncState.ServiceId);
            DeleteUserResult deleteUserResult = await scimClient.PerformAction <DeleteUserResult>(deleteUser);

            _authDbContext.Remove(syncState);
            await _authDbContext.SaveChangesAsync();
        }
Exemplo n.º 6
0
        public DeleteUserResult DeleteUser(string strUserId, long lgDeletedBy)
        {
            try
            {
                using (this.objDataContext = new UserDataContext(Functions.StrConnection))
                {
                    DeleteUserResult result = this.objDataContext.DeleteUser(strUserId, lgDeletedBy, PageMaster.User).FirstOrDefault();
                    if (result == null)
                    {
                        result = new DeleteUserResult();
                    }

                    return(result);
                }
            }
            catch (Exception ex)
            {
                Functions.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.User, mySession.Current.UserId);
                return(null);
            }
        }
Exemplo n.º 7
0
        public DeleteUserResult DeleteUser(string strUserId, long lgDeletedBy)
        {
            try
            {
                using (objDataContext = GetDataContext())
                {
                    DeleteUserResult result = objDataContext.DeleteUser(strUserId, lgDeletedBy, PageMaster.User).FirstOrDefault();
                    if (result == null)
                    {
                        result = new DeleteUserResult();
                    }

                    return(result);
                }
            }
            catch (Exception ex)
            {
                _logger.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name, PageMaster.User, _mySession.UserId);
                return(null);
            }
        }
Exemplo n.º 8
0
        public DeleteUserResult Delete(int?userId, UserSessionObject currentUser)
        {
            var result = new DeleteUserResult();

            if (userId.HasValue)
            {
                UserData domainModel = UserRepository.GetDataById(userId.Value);
                if (domainModel != null)
                {
                    List <RelationUserBookCopyData> loans = RelationUserBookCopyRepository.GetLoansForUser(userId.Value);
                    if (loans.Count == 0)
                    {
                        UserRepository.DeleteById(userId.Value, currentUser.UserId);
                        result = new DeleteUserResult(userId.Value, domainModel.FullFirstAndLastName);
                    }
                    else
                    {
                        result.Message = "Can't delete this user. There are some not returned loans.";
                    }
                }
            }

            return(result);
        }