当前位置: 首页>>代码示例>>C#>>正文


C# IUserService.DeleteUser方法代码示例

本文整理汇总了C#中IUserService.DeleteUser方法的典型用法代码示例。如果您正苦于以下问题:C# IUserService.DeleteUser方法的具体用法?C# IUserService.DeleteUser怎么用?C# IUserService.DeleteUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IUserService的用法示例。


在下文中一共展示了IUserService.DeleteUser方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeleteUserShouldCallRepository

        public void DeleteUserShouldCallRepository()
        {
            const int userId = 42;
            m_UserRepositoryMock = new Mock<IUserRepository>();
            m_BetRepositoryMock = new Mock<IBetRepository>();
            m_MatchRepositoryMock = new Mock<IMatchRepository>();
            m_UserService = new UserService(m_UserRepositoryMock.Object, m_BetRepositoryMock.Object, m_MatchRepositoryMock.Object);

            m_UserService.DeleteUser(userId);

            m_UserRepositoryMock.Verify(x => x.DeleteUser(userId), Times.Once);
        }
开发者ID:PeterParushev,项目名称:BoxingParadise,代码行数:12,代码来源:UserServiceTests.cs

示例2: UserModule

        public UserModule(IUserService _userService,
            ISiteService _siteService,
            IRoleService _roleService,
            IUserRoleMappingService _userRoleMappingService)
            : base("/user")
        {
            UserValidator uservalidator = new UserValidator();
            Get["/list"] = x =>
            {
                return View["User/List",_userService.GetAllUser()];
            };

            Get["/add"] = x =>
            {
                ViewBag.Errored = false;
                return View["User/Add", new User()];
            };

            Post["/add"] = x =>
            {
                User user = this.Bind<User>();
                ValidationResult results = uservalidator.Validate(user);
                if (!results.IsValid)
                {
                    ViewBag.ErrorMsg = HtmlUtils.GetCharisma_Alert(Charisma_AlertType.error,"错误信息", results.Errors);
                    ViewBag.Errored = true;
                    return View["User/Add", user];
                }
                if (_userService.CreateUser(user))
                {
                    ViewBag.ErrorMsg = "<strong>OK~</strong>";
                    ViewBag.Errored = true;
                    return View["User/Add", user];
                }

                ViewBag.ErrorMsg = "<strong>出错啦~</strong>";
                ViewBag.Errored = true;
                return View["User/Add", user];
                //return this.Context.GetRedirect("~/user/add?error=true");
                //return View["User/Add"];
            };

            Get["/edit/{id}"] = x =>
            {
                return View["User/Edit", _userService.GetByAutoId((int)x.id)];
            };

            Post["/edit/{id}"] = x =>
            {
                ViewBag.Errored = true;
                var user = this.Bind<User>();
                var model = _userService.GetById(user.ID);
                if (!String.IsNullOrEmpty(user.Password))
                {
                    model.PasswordSalt = PasswordUtil.GenerateSalt();
                    model.Password = PasswordUtil.EncodePassword(user.Password, model.PasswordFormat, model.PasswordSalt);
                    model.passwordConfirm = PasswordUtil.EncodePassword(user.passwordConfirm, model.PasswordFormat, model.PasswordSalt);
                }
                else
                {
                    model.passwordConfirm = model.Password;
                }
                model.PrivateEmail = user.PrivateEmail;
                model.Nickname = user.Nickname;
                model.Gender = user.Gender;
                model.Status = user.Status;
                ValidationResult results = uservalidator.Validate(model);
                if (!results.IsValid)
                {
                    ViewBag.ErrorMsg = HtmlUtils.GetCharisma_Alert(Charisma_AlertType.error, "错误信息", results.Errors);
                    return View["User/Edit", user];
                }
                if (user.ID == Guid.Empty)
                {
                    return Response.AsRedirect("/user/list");
                }
                if (_userService.ModifyUser(model))
                {
                    ViewBag.ErrorMsg = HtmlUtils.GetCharisma_Alert(Charisma_AlertType.success, "成功信息", "修改用户信息成功");
                }
                else
                {
                    ViewBag.ErrorMsg = HtmlUtils.GetCharisma_Alert(Charisma_AlertType.error, "错误信息", "未知错误,请联系管理员");
                }
                return View["User/Edit", user];
            };

            Get["/delete/{id}"] = x =>
            {
                var model = _userService.GetByAutoId((int)x.id);
                _userService.DeleteUser(model.ID);
                return Response.AsRedirect("/user/list");
            };

            Get["/editrole"] = x =>
            {
                Guid userId = new Guid(Request.Query.userId);
                dynamic SiteId = null;
                SiteId = !String.IsNullOrEmpty(Request.Query.siteId.ToString()) && Request.Query.siteId != null ? new Guid(Request.Query.siteId) : Guid.Empty;
                var usermodel = _userService.GetById(userId);
//.........这里部分代码省略.........
开发者ID:vvvsrx,项目名称:AUserCenter,代码行数:101,代码来源:UserModule.cs

示例3: DeleteUser_returnsTrueIfUserExists

 public void DeleteUser_returnsTrueIfUserExists()
 {
     bool validate;
     var user = Builder<User>.CreateNew().Build();
     _userRepository = Mockery.Stub<IUserRepository>();
     using (Mockery.Record())
     {
         Expect.Call(_userRepository.GetUserByLogin(null)).IgnoreArguments().Return(user);
         Expect.Call(() => _userRepository.Delete(Arg<User>.Is.Anything)).Repeat.Once();
     }
     using (Mockery.Playback())
     {
         _userService = new UserService(_userRepository, _passwordMethodsProvider);
         validate = _userService.DeleteUser(user.Login);
     }
     Assert.AreEqual(true, validate);
 }
开发者ID:AndreyB1990,项目名称:Task1,代码行数:17,代码来源:UserServiceTests.cs

示例4: DeleteUser_returnsFalseIfUserNotExists

 public void DeleteUser_returnsFalseIfUserNotExists()
 {
     bool validate;
     _userRepository = Mockery.Stub<IUserRepository>();
     using (Mockery.Record())
     {
         Expect.Call(_userRepository.GetUserByLogin(null)).IgnoreArguments().Return(null);
         DoNotExpect.Call(() => _userRepository.Delete(Arg<User>.Is.Anything));
     }
     using (Mockery.Playback())
     {
         _userService = new UserService(_userRepository, _passwordMethodsProvider);
         validate = _userService.DeleteUser("UnknownUser");
     }
     Assert.AreEqual(false, validate);
 }
开发者ID:AndreyB1990,项目名称:Task1,代码行数:16,代码来源:UserServiceTests.cs

示例5: UserModule

        public UserModule(IUserService userService, IMappingEngine mappingEngine)
            : base("data/users", mappingEngine, UserRole.Admin)
        {
            Get["/"] = args =>
            {
                var entities = userService.Search(
                    Context.RequestedPage(),
                    null,
                    Context.SortCriteria<User>(),
                    Context.SearchTerms<User>());

                return MapToResultList<SystemUser, Encore.Web.Models.User>(entities);
            };

            Get["/{id}"] = args =>
            {
                var entity = userService.Get(new Guid(args.id));

                if (entity == null)
                {
                    return Negotiate.WithStatusCode(HttpStatusCode.NotFound);
                }

                return MapTo<Encore.Web.Models.User>(entity);
            };

            Put["/{id}"] = args =>
            {
                var model = this.BindAndValidate<Models.User>();

                if (!ModelValidationResult.IsValid)
                {
                    return RespondWithValidationFailure(ModelValidationResult);
                }

                var authorizedUser = Context.GetAuthorizedUser();

                var updateEntity = MapTo<SystemUser>(model);
                var updateId = new Guid(args.id);
                var updatedUser = userService.UpdateUser(authorizedUser.Id, updateId, updateEntity);

                if (authorizedUser.Id == updateId)
                {
                    Context.SetupSession(updatedUser);
                }

                return MapTo<User>(updatedUser);
            };

            Post["/"] = args =>
            {
                var model = this.BindAndValidate<Models.User>();

                if (!ModelValidationResult.IsValid)
                {
                    return RespondWithValidationFailure(ModelValidationResult);
                }

                var addEntity = MapTo<SystemUser>(model);
                var user = userService.Add(addEntity);

                if (user == null)
                {
                    return HttpStatusCode.Unauthorized;
                }

                return MapTo<User>(user);
            };

            Delete["/{id}"] = args =>
            {
                var authorizedUser = Context.GetAuthorizedUser();
                var deleteId = new Guid(args.id);

                return userService.DeleteUser(authorizedUser.Id, deleteId);
            };
        }
开发者ID:apxnowhere,项目名称:Encore,代码行数:77,代码来源:UserModule.cs


注:本文中的IUserService.DeleteUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。