本文整理汇总了C#中System.Web.Http.User.SetPassword方法的典型用法代码示例。如果您正苦于以下问题:C# User.SetPassword方法的具体用法?C# User.SetPassword怎么用?C# User.SetPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Http.User
的用法示例。
在下文中一共展示了User.SetPassword方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateUser
public IHttpActionResult CreateUser(UserDO user)
{
User newUser = new User();
newUser.Username = user.Username;
newUser.Fullname = user.Fullname;
newUser.HasPassword = true;
newUser.CertificateThumbprint = user.CertificateThumbprint.Replace(" ", null).ToUpperInvariant();
newUser.IsActive = user.IsActive;
newUser.AppointmentDate = user.AppointmentDate;
newUser.ResignationDate = user.ResignationDate;
newUser.Notes = user.Notes;
newUser.Version = user.Version;
newUser.Email = user.Email;
//UnitUser unitUser = new UnitUser();
//unitUser.User = newUser;
//unitUser.UnitId = user.UnitId.Value;
//unitUser.IsActive = true;
newUser.SetPassword(user.Password);
foreach (var role in user.Roles)
{
newUser.Roles.Add(this.unitOfWork.DbContext.Set<Role>().Find(role.RoleId));
}
this.unitOfWork.DbContext.Set<User>().Add(newUser);
//this.unitOfWork.DbContext.Set<UnitUser>().Add(unitUser);
this.unitOfWork.Save();
//
//int unitId = user.UnitId.Value;
//var oldUnitClassifications = this.unitOfWork.DbContext.Set<UnitClassification>()
// .Where(e => e.UnitId == unitId)
// .ToList();
//this.unitOfWork.DbContext.Set<UnitClassification>().RemoveRange(oldUnitClassifications);
List<int> roleIds = user.Roles.Select(e => e.RoleId).ToList();
//var roleClassifications = this.unitOfWork.DbContext.Set<RoleClassification>()
// .Where(e => roleIds.Contains(e.RoleId))
// .ToList();
//foreach (var item in roleClassifications)
//{
// UnitClassification uc = new UnitClassification();
// uc.UnitId = unitId;
// uc.ClassificationId = item.ClassificationId;
// uc.ClassificationPermissionId = item.ClassificationPermissionId;
// this.unitOfWork.DbContext.Set<UnitClassification>().Add(uc);
//}
this.unitOfWork.Save();
//this.userRepository.spSetUnitTokens(unitId);
return Ok();
}