本文整理汇总了C#中UserRepository类的典型用法代码示例。如果您正苦于以下问题:C# UserRepository类的具体用法?C# UserRepository怎么用?C# UserRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserRepository类属于命名空间,在下文中一共展示了UserRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestMethod1
public void TestMethod1()
{
var dbContext = new DanwuDbContext();
var context = new EntityFrameworkRepositoryContext();
var unitOfWork = new EntityFrameworkUnitOfWork(dbContext);
IUserRepository userRepository = new UserRepository(context);
userRepository.Create(new User()
{
UserName = "wudan",
NickName = "坏坏男孩",
RealName = "吴丹",
PhoneNum = "18916765826",
Email = "[email protected]",
Status = UserStatus.Enabled,
PassWord = "123456",
RegisterTime = DateTime.Now,
LastLogonTime = DateTime.Now
});
userRepository.Create(new User()
{
UserName = "wudan1",
NickName = "坏坏男孩1",
RealName = "吴丹1",
PhoneNum = "18916765000",
Email = "[email protected]",
Status = UserStatus.Disabled,
PassWord = "123456",
RegisterTime = DateTime.Now,
LastLogonTime = DateTime.Now
});
var result = context.Commit();
//var result = unitOfWork.Commit();
}
示例2: GetUCError
public List<Guid> GetUCError()
{
List<Guid> ret = new List<Guid>();
using (UserRepository repo = new UserRepository())
{
foreach(var v in repo.GetAllUserAcadmic())
{
if(!string.IsNullOrEmpty(v.Association) && string.IsNullOrEmpty(v.AssociationPost))
{
if (!ret.Contains(v.AccountEmail_uuid))
ret.Add(v.AccountEmail_uuid);
}
if (!string.IsNullOrEmpty(v.Magazine) && string.IsNullOrEmpty(v.MagazinePost))
{
if (!ret.Contains(v.AccountEmail_uuid))
ret.Add(v.AccountEmail_uuid);
}
if (!string.IsNullOrEmpty(v.Fund) && string.IsNullOrEmpty(v.FundPost))
{
if (!ret.Contains(v.AccountEmail_uuid))
ret.Add(v.AccountEmail_uuid);
}
}
}
return ret;
}
示例3: GetRolesForUser
public override string[] GetRolesForUser(string login)
{
string[] role = new string[] { };
using (IModelRepository<User> _user = new UserRepository())
{
try
{
IModelRepository<Role> _role = new RoleRepository();
// Get User
var user = (from u in _user.Items
where u.Login == login
select u).FirstOrDefault();
if (user != null)
{
// Get role
var userRole = _role.Items.FirstOrDefault(x=>x.Id==user.RoleId);
if (userRole != null)
{
role = new string[] { userRole.Name };
}
}
}
catch
{
role = new string[] { };
}
}
return role;
}
示例4: UserService
public UserService()
{
_userManager = _userManager ?? new ApplicationUserManager(new UserStore<ApplicationUserEntity>());
_userRepository = _userRepository ?? new UserRepository<ApplicationUserEntity>();
UserMappingConfig.RegisterMappings();
}
示例5: AccountController
public AccountController(IUnitOfWork unitOfWork)
: base(unitOfWork)
{
_repository = new UserRepository(unitOfWork);
_departRepository= new DepartRepository(unitOfWork);
_roleRepository = new RoleRepository(unitOfWork);
}
示例6: GroupMemberService
public GroupMemberService(
UserRepository userRepository,
GroupRepository groupRepository)
{
this.GroupRepository = groupRepository;
this.UserRepository = userRepository;
}
示例7: GetById_UserDoesNotExist
public void GetById_UserDoesNotExist()
{
var repository = new UserRepository(_contextFactory);
var retrievedUser = repository.GetById(123);
Assert.IsNull(retrievedUser);
}
示例8: OnActionExecutedAsync
public override Task OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)
{
//加入访问次数
foreach (var v in getActionArgumentsValues(actionExecutedContext))
{
if (v is DualParameter)
{
var u = v as DualParameter;
NameCardAccessCountOP.AddScore(u.uuid.ToString(), 1);
using (UserRepository repo = new UserRepository())
{
UserInfo user = repo.GetUserInfoByUuid_TB(u.uuid);
if(user!=null)
{
if(user.IsBusiness!= null)
{
if (user.IsBusiness == 0)
new RedisManager2<WeChatRedisConfig>().AddScoreAsync<NameCardRedis, NameCardPCountZsetAttribute>(u.uuid.ToString(), 1);
else if(user.IsBusiness==2)
new RedisManager2<WeChatRedisConfig>().AddScoreAsync<NameCardRedis, NameCardSCountZsetAttribute>(u.uuid.ToString(), 1);
}
}
}
break;
}
}
return base.OnActionExecutedAsync(actionExecutedContext, cancellationToken);
}
示例9: GetUserRepository
protected override IUserRepository GetUserRepository()
{
var userRepository = new UserRepository(this.repositoryStrategy);
userRepository.RepositoryGlass = new UserRepositoryGlass();
return userRepository;
}
示例10: IsAdmin
public static Boolean IsAdmin(this IPrincipal principal)
{
UserRepository userRepository = new UserRepository();
User user = userRepository.GetBy(x => x.Email == principal.Identity.Name);
return user != null && user.Role == Role.Admin;
}
示例11: Execute
public override bool Execute(string input)
{
if (String.IsNullOrEmpty(input)) return false;
var repository = new UserRepository();
int userId;
if (!Int32.TryParse(input, out userId))
{
return false;
}
var user = repository.GetById(userId);
if (user != null)
{
repository.Delete(user);
}
try
{
repository.SaveChanges();
Success = true;
}
catch
{
Success = false;
}
return Success;
}
示例12: ReturnsTrueIfEmailExistsForDifferentUser
public void ReturnsTrueIfEmailExistsForDifferentUser()
{
var repository = new UserRepository(null, SessionSource.CreateSession());
var user = new User { Name = "test", Credentials = new Credentials("[email protected]", "pass") };
repository.Save(new User {Name = "test", Credentials = new Credentials("[email protected]", "pass")});
Assert.True(repository.EmailExists(user));
}
示例13: CreateUser
public static BaseActionResult CreateUser(User obj4create)
{
string msg;
if (obj4create == null)
{
msg = string.Format(XiaoluResources.MSG_CREATE_SUCCESS, XiaoluResources.STR_USER) + string.Format(XiaoluResources.STR_FAIL_RESAON, XiaoluResources.MSG_OBJECT_IS_NULL);
return new BaseActionResult(false, msg);
}
try
{
using (var context = new XiaoluEntities())
{
var repository = new UserRepository(context);
string newId = Guid.NewGuid().ToString();
obj4create.Id = newId;
repository.Create(obj4create);
context.SaveChanges();
msg = string.Format(XiaoluResources.MSG_CREATE_SUCCESS, obj4create.Name);
return new BaseActionResult(true, msg);
}
}
catch (Exception e)
{
msg = string.Format(XiaoluResources.MSG_CREATE_FAIL, obj4create.Name) + string.Format(XiaoluResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e));
return new BaseActionResult(false, msg);
}
}
示例14: BulkDeleteUserByIds
public static BaseActionResult BulkDeleteUserByIds(string idsStr)
{
string msg;
string[] idArr = idsStr.Split(',');
if (idArr.Length == 0)
{
msg = XiaoluResources.ERR_MSG_NO_RECORD_FOR_ACTION;
return new BaseActionResult(false, msg);
}
try
{
List<User> list4delete = new List<User>();
foreach (string id in idArr)
{
var obj4delete = GetUserById(id);
list4delete.Add(obj4delete);
}
using (var context = new XiaoluEntities())
{
var repository = new UserRepository(context);
repository.BulkDelete(list4delete);
context.SaveChanges();
msg = string.Format(XiaoluResources.MSG_BULK_ACTION_SUCCESS, XiaoluResources.STR_USER, idArr.Length);
return new BaseActionResult(true, msg);
}
}
catch (Exception e)
{
msg = string.Format(XiaoluResources.MSG_BULK_ACTION_FAIL, XiaoluResources.STR_DELETE, idArr.Length) + string.Format(XiaoluResources.STR_FAIL_RESAON, ExceptionHelper.GetInnerExceptionInfo(e));
return new BaseActionResult(false, msg, e);
}
}
示例15: Delete
public ActionResult Delete(int id)
{
UserRepository userRep = new UserRepository();
userRep.Delete(id);
return RedirectToAction("List");
}