Ejemplo n.º 1
0
        public UserDeleteResponse Delete([FromBody] UserDeleteRequest request)
        {
            var response = new UserDeleteResponse();

            _facade.Delete(request.Id);
            return(response);
        }
Ejemplo n.º 2
0
        public async Task <UserDeleteResponse> DeleteOne(ApplicationUser currentUser, UserTypeVM userType, long id)
        {
            var response            = new UserDeleteResponse();
            var applicationUserType = GetApplicationUserType(currentUser);

            if (applicationUserType != UserType.Admin && applicationUserType != UserType.Manager) // удалить может только админ или менеджер
            {
                response.AddError(_stringLocalizer[CustomStringLocalizer.NO_RIGHTS_TO_DELETE_USER]);
                return(response);
            }

            if (applicationUserType == UserType.Manager && userType == UserTypeVM.Admin) // менеджер хочет удалить админа
            {
                response.AddError(_stringLocalizer[CustomStringLocalizer.NO_RIGHTS_TO_DELETE_USER]);
                return(response);
            }

            var applicationUserValue = await ApplicationUserFactory.GetApplicationUserAsync(_fuelContext, userType, id);

            if (applicationUserValue == null)
            {
                response.AddError(_stringLocalizer[CustomStringLocalizer.USER_NOT_FOUND]);
                return(response);
            }

            var result = await _userManager.DeleteAsync(applicationUserValue);

            response.IsSuccess = result.Succeeded;
            return(response);
        }
Ejemplo n.º 3
0
        public UserDeleteResponse Execute(UserDeleteRequest request)
        {
            UserDeleteResponse userDeleteResponse = new UserDeleteResponse();

            ServiceHelper.LoadService <IUserService>().Delete(ServiceHelper.LoadService <IUserService>().Get(request.UserId));
            return(userDeleteResponse);
        }
Ejemplo n.º 4
0
        private void DeleteUser(UserModel model)
        {
            if (MessageBox.Show("确认删除该用户吗?", "提示", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
            {
                return;
            }
            UserDeleteResponse userDeleteResponse = LocalApi.Execute(new UserDeleteRequest()
            {
                UserId = model.UserId
            });

            this.RefreshData();
        }
Ejemplo n.º 5
0
 public async Task <ActionResult> Delete(string id, [FromBody] UserDeleteRequest rq)
 {
     try
     {
         rq.User.Id = id;
         UserDeleteResponse rs = await(new UserDeleteService(Context, _userModRepo)).RunAsync(rq);
         return(new ApiActionResult(Context.Request, rs));
     }
     catch (Exception ex)
     {
         return(new ApiActionResult(Context.Request, ex));
     }
 }
Ejemplo n.º 6
0
        public UserDelete(UserDeleteRequest request)
        {
            if (request != null && request.Identifiers != null && request.Identifiers.Any())
            {
                using (var dbContext = new ApplicationDbContext())
                {
                    var usersToDelete = dbContext.Users.Where(aUser
                                                              => request.Identifiers.Contains(aUser.Identifier));

                    dbContext.Users.RemoveRange(usersToDelete);
                    dbContext.SaveChanges();
                }

                Response = new UserDeleteResponse();
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 逻辑删除用户信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public UserDeleteResponse UserDelete(UserDeleteRequest request)
        {
            UserDeleteResponse response = new UserDeleteResponse();

            var res = UserDal.Instance.UserDelete(request.ID);

            if (res <= 0)
            {
                response.Status  = false;
                response.Message = "删除失败,请重试";
            }
            else
            {
                response.Status  = true;
                response.Message = "删除成功";
            }
            return(response);
        }
        public async Task <IActionResult> Delete(DeleteModel user)
        {
            try
            {
                Enums.Account.Delete res = await _AccountRepository.Delete(user.UserID);

                UserDeleteResponse deleteResponse = new UserDeleteResponse();
                switch (res)
                {
                case Enums.Account.Delete.Deleted:
                    deleteResponse.Message = "Usuario eliminado";
                    deleteResponse.Status  = "Ok";
                    break;

                case Enums.Account.Delete.Not_Deleted:
                    deleteResponse.Message = "Usuario no eliminado";
                    deleteResponse.Status  = "Ok";
                    break;

                case Enums.Account.Delete.Error_Deleting:
                    deleteResponse.Message = "Error eliminando usuario";
                    deleteResponse.Status  = "Ok";
                    break;

                case Enums.Account.Delete.Unknown_error:
                    deleteResponse.Message = "Error desconocido";
                    deleteResponse.Status  = "Ok";
                    return(BadRequest(deleteResponse));

                case Enums.Account.Delete.User_Not_Found:
                    deleteResponse.Message = "Usuario no encontrado";
                    deleteResponse.Status  = "Ok";
                    break;
                }
                return(Ok(deleteResponse));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }
Ejemplo n.º 9
0
        public async Task <UserDeleteResponse> DeleteUser(UserDeleteRequest request)
        {
            var response = new UserDeleteResponse();

            var currentUser = _cacheManager.GetCachedCurrentUser(request.CurrentUserId);

            if (!currentUser.IsAdmin)
            {
                response.SetInvalid();
                return(response);
            }

            if (await _organizationRepository.Any(x => x.Id == currentUser.OrganizationId && !x.IsActive))
            {
                response.SetInvalid();
                response.ErrorMessages.Add("organization_not_found");
                return(response);
            }

            var entity = _cacheManager.GetCachedUser(request.UserUid);

            if (entity.OrganizationId != currentUser.OrganizationId)
            {
                response.SetInvalid();
                return(response);
            }

            var result = await _userRepository.Delete(request.CurrentUserId, entity.Id);

            if (result)
            {
                _cacheManager.RemoveUser(entity);

                response.Status = ResponseStatus.Success;
                return(response);
            }

            response.SetFailed();
            return(response);
        }
Ejemplo n.º 10
0
 public UserDeleteResponse DelUser(UserDeleteRequest model)
 {
     try
     {
         string             url      = string.Format("https://oapi.dingtalk.com/user/delete?access_token={0}&userid={1}", DDHelper.GetToken(), model.Userid);
         string             response = Infrastructure.Web.WebHelper.HttpWebRequest(url);
         UserDeleteResponse res      = response.ToObject <UserDeleteResponse>();
         if (res.Errcode == 0)
         {
             _OtherUserApp.SetStatus(model.Userid, res.Errmsg, true);
         }
         else
         {
             _OtherUserApp.SetStatus(model.Userid, res.Errmsg, false);
         }
         return(res);
     }
     catch (Exception ex)
     {
         _OtherUserApp.SetStatus(model.Userid, ex.Message, false);
         return(null);
     }
 }