本文整理汇总了C#中IUserService.GetByAutoId方法的典型用法代码示例。如果您正苦于以下问题:C# IUserService.GetByAutoId方法的具体用法?C# IUserService.GetByAutoId怎么用?C# IUserService.GetByAutoId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUserService
的用法示例。
在下文中一共展示了IUserService.GetByAutoId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
//.........这里部分代码省略.........