本文整理汇总了C#中IUserRepository.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IUserRepository.Get方法的具体用法?C# IUserRepository.Get怎么用?C# IUserRepository.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUserRepository
的用法示例。
在下文中一共展示了IUserRepository.Get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExampleSecureModule
public ExampleSecureModule(IUserRepository userRepo)
{
this.RequiresAuthentication();
this.Get["/api/examples/ambientContext"] = args =>
{
ICustomClaimsIdentity currentUser = AmbientContext.CurrentClaimsPrinciple.ClaimsIdentity;
string guid = currentUser.GetAttribute(AmbientContext.UserPrincipalGuidAttributeKey).ToString();
var user = userRepo.Get(guid);
user.Password = null;
return JsonConvert.SerializeObject(user);
//return 200;
};
this.Get["/api/examples/context"] = args =>
{
var currentUser = this.Context.CurrentUser;
string username = currentUser.UserName;
var user = userRepo.GetByUsername(username);
user.Password = null;
return JsonConvert.SerializeObject(user);
};
}
示例2: GetUser
public static User GetUser(string login, string password, IUserRepository userRepository)
{
using (var sha1 = SHA1.Create())
{
var hashedPassword = HexStringFromBytes(sha1.ComputeHash(Encoding.UTF8.GetBytes(password)));
return userRepository.Get(login, hashedPassword);
}
}
示例3: AddUserAndCopyAccess
public static void AddUserAndCopyAccess(IUserRepository userRepository, INetworkRepository networkRepository, INetworkGuestRepository networkGuestRepository, string username, string password, string referenceUsername)
{
var user = User.Create(string.Join(":", "internal", username));
user.Secret = Web.Persistence.Helpers.Secrets.BCryptSecret.FromPassword(password);
userRepository.Add(user);
var referenceUser = userRepository.Get(string.Join(":", "internal", referenceUsername));
var networks = networkRepository.Get(referenceUser);
foreach (var network in networks)
{
networkGuestRepository.Add(network, user);
}
}
示例4: DoLoggingIn
private void DoLoggingIn()
{
this.err.Clear();
userRepo = new UserRepository();
var isValid = userRepo.Login(this.txtUser.Text, this.txtPass.Text, AppContext.CurrentClinicId);
if (isValid)
{
AppContext.Authenticated = true;
AppContext.LoggedInUser = userRepo.Get(this.txtUser.Text, AppContext.CurrentClinicId);
IClinicRepository clinicRepository = new ClinicRepository();
AppContext.CurrentClinic = clinicRepository.Get(AppContext.CurrentClinicId);
this.Close();
}
else
{
this.err.SetError(txtPass, "Tài khoản không hợp lệ");
this.err.SetError(txtUser, "Tài khoản không hợp lệ");
}
}
示例5: UpdateFavoriteProperty
public static void UpdateFavoriteProperty(IUserRepository userRepository)
{
var user = userRepository.Get(GetUserId());
HttpContext.Current.Session["propertyId"] = user.FavoriteProperty.Id;
HttpContext.Current.Session["propertyName"] = user.FavoriteProperty.Name;
}
示例6: UserModule
public UserModule(IBus bus, IAdvancedBus eBus, IUserRepository userRepository)
{
if (_defaultJsonMaxLength == 0)
_defaultJsonMaxLength = JsonSettings.MaxJsonLength;
//Hackeroonie - Required, due to complex model structures (Nancy default restriction length [102400])
JsonSettings.MaxJsonLength = Int32.MaxValue;
Get["/Users/All"] = _ => Response.AsJson(Mapper.Map<IEnumerable<User>, IEnumerable<UserDto>>(userRepository));
Get["/Users"] = _ =>
{
var search = Context.Request.Query["search"];
var offset = Context.Request.Query["offset"];
var limit = Context.Request.Query["limit"];
if (offset == null) offset = 0;
if (limit == null) limit = 10;
var model = this.Bind<DataTablesViewModel>();
var dto = Mapper.Map<IEnumerable<User>, IEnumerable<UserDto>>(userRepository.Where(x => x.IsActive != false));//.Search(Context.Request.Query["search[value]"].Value, model.Start, model.Length));
return Negotiate
.WithView("Index")
.WithMediaRangeModel(MediaRange.FromString("application/json"), new { data = dto.ToList() });
};
Get["/UserLookup/{filter}"] = _ =>
{
var filter = (string)_.filter;
var dto = Mapper.Map<IEnumerable<User>, IEnumerable<UserDto>>(userRepository.Where(x => x.IsActive == true && (x.Individual.Name.StartsWith(filter) || x.Individual.Surname.StartsWith(filter))));
return Negotiate
.WithView("Index")
.WithMediaRangeModel(MediaRange.FromString("application/json"), new { dto });
};
Get["/UserCustomers/{userId:guid}"] = _ =>
{
var userId = (Guid)_.userId;
var customers = userRepository.Where(x => x.Id == userId && x.IsActive == true).SelectMany(x => x.CustomerUsers.Select(cu => cu.Customer));
return Negotiate
.WithView("Index")
.WithMediaRangeModel(MediaRange.FromString("application/json"), Mapper.Map<IEnumerable<Customer>, IEnumerable<CustomerDto>>(customers));
};
Get["/Userlist"] = parameters =>
{
var filter = "";
if (Context.Request.Query["q_word[]"].HasValue)
filter = (string)Context.Request.Query["q_word[]"].Value.ToString();
var pageIndex = 0;
var pageSize = 0;
int.TryParse(Context.Request.Query["page_num"].Value, out pageIndex);
int.TryParse(Context.Request.Query["per_page"].Value, out pageSize);
Expression<Func<User, bool>> predicate = x => x.IsActive == true && x.UserType == UserType.Internal && (x.Individual.Name.StartsWith(filter) || x.Individual.Surname.StartsWith(filter));
var users = new PagedList<User>(userRepository, pageIndex != 0 ? pageIndex - 1 : pageIndex, pageSize == 0 ? 10 : pageSize, predicate);
return Negotiate
.WithView("Index")
.WithMediaRangeModel(MediaRange.FromString("application/json"), new { result = Mapper.Map<IEnumerable<User>, IEnumerable<UserDto>>(users), cnt_whole = users.RecordsFiltered });
};
Get["/Users/Add"] = _ => View["Save", new UserDto()];
Get["/Users/{id:guid}"] = parameters =>
{
var guid = (Guid)parameters.id;
var dto = Mapper.Map<User, UserDto>(userRepository.Get(guid));
return View["Save", dto];
};
Get["/Users/Details/{id:guid}"] = parameters =>
{
var guid = (Guid)parameters.id;
var dto = Mapper.Map<User, UserDto>(userRepository.Get(guid));
return Response.AsJson(dto);
};
Post["/Users"] = _ =>
{
var dto = this.BindAndValidate<UserDto>();
dto.CreatedBy = Context.CurrentUser.UserName;
dto.IsActive = true;
if (dto.TrialExpiration == null) dto.TrialExpiration = DateTime.UtcNow.Date;
if (ModelValidationResult.IsValid)
{
//var clientUsersDto = this.Bind<List<ClientUserDto>>();
//dto.ClientUsers = clientUsersDto;
var entity = Mapper.Map(dto, userRepository.Get(dto.Id) ?? new User());
entity.HashPassword(dto.Password);
bus.Publish(new CreateUpdateEntity(entity, "Create"));
//.........这里部分代码省略.........