本文整理汇总了C#中IUserService.Register方法的典型用法代码示例。如果您正苦于以下问题:C# IUserService.Register方法的具体用法?C# IUserService.Register怎么用?C# IUserService.Register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUserService
的用法示例。
在下文中一共展示了IUserService.Register方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertTest
public void InsertTest()
{
try
{
_logger = _container.Resolve<ILog>();
_accountService = _container.Resolve<IUserService>();
_accountService.Register(new Service.Models.RegisterViewModel
{
Username = "abdurrahman",
Password = "71106761",
Email = "[email protected]"
});
_logger.Info("User has registered successfully !");
//var user = new User
//{
// Email = "[email protected]",
// FirstName = "Abdurrahman",
// IPAddress = "192.168.2.1",
// LastActivity = DateTime.Now,
// LastName = "Işık",
// Password = "12345678",
// Username = "xJason21",
// UserRoleId = 1
//};
////_unitOfWork.UserRepository.Insert(user);
//_userRepository.Insert(user);
//_unitOfWork.Save();
}
catch (Exception ex)
{
// {"Unable to resolve the type 'Walltage.Domain.UnitOfWork' because the lifetime scope it belongs in can't be located. The following services are exposed by this registration:\n- Walltage.Domain.IUnitOfWork\r\n\nDetails ---> No scope with a tag matching 'AutofacWebRequest' is visible from the scope in which the instance was requested.\n\nIf you see this during execution of a web application, it generally indicates that a component registered as per-HTTP request is being requested by a SingleInstance() component (or a similar scenario). Under the web integration always request dependencies from the dependency resolver or the request lifetime scope, never from the container itself. (See inner exception for details.)"}
//{"None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Walltage.Service.AccountService' can be invoked with the available services and parameters:\r\nCannot resolve parameter 'Walltage.Domain.IRepository`1[Walltage.Domain.Entities.User] userRepository' of constructor 'Void .ctor(Walltage.Domain.IUnitOfWork, log4net.ILog, Walltage.Domain.IRepository`1[Walltage.Domain.Entities.User])'."}
//"The context cannot be used while the model is being created. This exception may be thrown if the context is used inside the OnModelCreating method or if the same context instance is accessed by multiple threads concurrently. Note that instance members of DbContext and related classes are not guaranteed to be thread safe."
throw;
}
}
示例2: AuthenticationModule
public AuthenticationModule(IUserService userService)
{
this.userService = userService;
Get["/login"] = x =>
{
dynamic model = new ExpandoObject();
model.Errored = this.Request.Query.error.HasValue;
return View["login", model];
};
Get["/logout"] = x => this.LogoutAndRedirect("~/");
Post["/login"] = x =>
{
Guid? userGuid = this.userService.Authenticate(this.Request.Form.Email, this.Request.Form.Password);
if (!userGuid.HasValue)
{
return Context.GetRedirect("~/login?error=true&email=" + (string)this.Request.Form.Email);
}
DateTime? expiry = null;
if (this.Request.Form.RememberMe.HasValue)
{
expiry = DateTime.Now.AddDays(7);
}
return this.LoginAndRedirect(userGuid.Value, expiry);
};
Get["/logout"] = x => this.LogoutAndRedirect("~/");
Get["/register"] = x =>
{
dynamic model = new ExpandoObject();
model.Errored = this.Request.Query.error.HasValue;
return View["register", model];
};
Post["/register"] = x =>
{
try
{
Guid userGuid = userService.Register(Request.Form.Email,
Request.Form.Password,
Request.Form.ConfirmPassword);
DateTime? expiry = null;
if (this.Request.Form.RememberMe.HasValue)
{
expiry = DateTime.Now.AddDays(7);
}
return this.LoginAndRedirect(userGuid, expiry);
}
catch (ArgumentException)
{
return Context.GetRedirect("~/register?error=true");
}
};
}