本文整理汇总了C#中IUserService.GetUser方法的典型用法代码示例。如果您正苦于以下问题:C# IUserService.GetUser方法的具体用法?C# IUserService.GetUser怎么用?C# IUserService.GetUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUserService
的用法示例。
在下文中一共展示了IUserService.GetUser方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUsersShouldCallRepository
public void GetUsersShouldCallRepository()
{
m_UserRepositoryMock = new Mock<IUserRepository>();
m_UserRepositoryMock.Setup(x => x.GetUsers(It.IsAny<int>(), It.IsAny<int>())).Returns(new Task<IList<User>>(() => new List<User>()));
m_BetRepositoryMock = new Mock<IBetRepository>();
m_MatchRepositoryMock = new Mock<IMatchRepository>();
m_UserService = new UserService(m_UserRepositoryMock.Object, m_BetRepositoryMock.Object, m_MatchRepositoryMock.Object);
m_UserService.GetUser(10, 10);
m_UserRepositoryMock.Verify(x => x.GetUsers(It.IsAny<int>(), It.IsAny<int>()), Times.Once);
}
示例2: GetByIdShouldCallRepository
public void GetByIdShouldCallRepository()
{
const int userId = 42;
m_UserRepositoryMock = new Mock<IUserRepository>();
m_BetRepositoryMock = new Mock<IBetRepository>();
m_UserRepositoryMock.Setup(x => x.GetById(userId)).Returns(new Task<User>(() => new User()));
m_MatchRepositoryMock = new Mock<IMatchRepository>();
m_UserService = new UserService(m_UserRepositoryMock.Object, m_BetRepositoryMock.Object, m_MatchRepositoryMock.Object);
m_UserService.GetUser(userId);
m_UserRepositoryMock.Verify(x => x.GetById(userId), Times.Once);
}
示例3: GetUser
private System.Web.Security.MembershipUser GetUser(
IUserService service, string username)
{
var user = service.GetUser(username);
return ToMembershipUser(user);
}
示例4: GetProfileNotifications
internal IEnumerable<NotificationsViewModel> GetProfileNotifications(string userid, IGoalService goalService, ICommentService commentService, IUpdateService updateService, ISupportService supportService, IUserService userService, IGroupService groupService, IGroupUserService groupUserSevice, IGroupGoalService groupGoalService, IGroupCommentService groupcommentService, IGroupUpdateService groupupdateService, ICommentUserService commentUserService)
{
var goals = goalService.GetTop20Goals(userid);
var comments = commentService.GetTop20CommentsOfPublicGoals(userid);
var updates = updateService.GetTop20Updates(userid);
var groupusers = groupUserSevice.GetTop20GroupsUsersForProfile(userid);
var supports = supportService.GetTop20Support(userid);
return (from g in goals
select new NotificationsViewModel()
{
GoalId = g.GoalId,
UserId = g.UserId,
CreatedDate = g.CreatedDate,
UserName = g.User.UserName,
GoalName = g.GoalName,
Desc = g.Desc,
ProfilePicUrl = g.User.ProfilePicUrl,
Goal = g,
NotificationDate = DateCalculation(g.CreatedDate),
NotificationType = (int)NotificationType.createdGoal
})
.Concat(from c in comments
select new NotificationsViewModel()
{
CommentId = c.CommentId,
CreatedDate = c.CommentDate,
UserName = commentUserService.GetUser(c.CommentId).UserName,
UserId = commentUserService.GetUser(c.CommentId).Id,
ProfilePicUrl = commentUserService.GetUser(c.CommentId).ProfilePicUrl,
CommentText = c.CommentText,
UpdateId = c.UpdateId,
GoalName = c.Update.Goal.GoalName,
GoalId = c.Update.GoalId,
NumberOfComments = commentService.GetCommentsByUpdate(c.UpdateId).Count(),
Updatemsg = updateService.GetUpdate(c.UpdateId).Updatemsg,
NotificationDate = DateCalculation(c.CommentDate),
NotificationType = (int)NotificationType.commentedOnUpdate
})
.Concat(from u in updates
select new NotificationsViewModel()
{
Update = u,
UpdateId = u.UpdateId,
GoalId = u.GoalId,
ProfilePicUrl = u.Goal.User.ProfilePicUrl,
GoalName = u.Goal.GoalName,
Updatemsg = u.Updatemsg,
UserId = u.Goal.UserId,
UserName = u.Goal.User.UserName,
NumberOfComments = commentService.GetCommentsByUpdate(u.UpdateId).Count(),
CreatedDate = u.UpdateDate,
NotificationDate = DateCalculation(u.UpdateDate),
NotificationType = (int)NotificationType.updatedGoal
})
.Concat(from s in supports
select new NotificationsViewModel()
{
Support = s,
SupportId = s.SupportId,
GoalName = s.Goal.GoalName,
ProfilePicUrl = userService.GetUser(s.UserId).ProfilePicUrl,
UserName = userService.GetUser(s.UserId).UserName,
UserId = s.UserId,
CreatedDate = s.SupportedDate,
GoalId = s.GoalId,
NotificationType = (int)NotificationType.supportGoal
})
.Concat(from gu in groupusers
select new NotificationsViewModel()
{
GroupUser = gu,
GroupUserId = gu.GroupUserId,
UserName = userService.GetUser(gu.UserId).UserName,
ProfilePicUrl = userService.GetUser(gu.UserId).ProfilePicUrl,
UserId = gu.UserId,
GroupName = groupService.GetGroup(gu.GroupId).GroupName,
GroupId = gu.GroupId,
CreatedDate = gu.AddedDate,
NotificationDate = DateCalculation(gu.AddedDate),
NotificationType = (int)NotificationType.joinGroup
})
.OrderByDescending(n => n.CreatedDate);
}
示例5: GetNotifications
internal IEnumerable<NotificationsViewModel> GetNotifications(string userId, IGoalService goalService, ICommentService commentService, IUpdateService updateService, ISupportService supportService, IUserService userService, IGroupService groupService, IGroupUserService groupUserSevice, IGroupGoalService groupGoalService, IGroupCommentService groupcommentService, IGroupUpdateService groupupdateService, IFollowUserService followUserService, IGroupCommentUserService groupCommentUserService, ICommentUserService commentUserService, IGroupUpdateUserService groupUpdateUserService)
{
var goals = goalService.GetTop20GoalsofFollowing(userId);
var comments = commentService.GetTop20CommentsOfPublicGoalFollwing(userId);
var updates = updateService.GetTop20UpdatesOfFollowing(userId);
var groupusers = groupUserSevice.GetTop20GroupsUsers(userId);
var supports = supportService.GetTop20SupportsOfFollowings(userId);
var groupgoals = groupGoalService.GetTop20GroupsGoals(userId, groupUserSevice);
var groupupdates = groupupdateService.GetTop20Updates(userId, groupUserSevice);
var groupComments = groupcommentService.GetTop20CommentsOfPublicGoals(userId, groupUserSevice);
var followers = followUserService.GetTop20Followers(userId);
// var groups = groupService.GetTop20Groups(groupids);
return (from g in goals
select new NotificationsViewModel()
{
GoalId = g.GoalId,
UserId = g.UserId,
CreatedDate = g.CreatedDate,
UserName = g.User.UserName,
GoalName = g.GoalName,
Desc = g.Desc,
ProfilePicUrl = g.User.ProfilePicUrl,
Goal = g,
NotificationDate = DateCalculation(g.CreatedDate),
NotificationType = (int)NotificationType.createdGoal
})
.Concat(from c in comments
select new NotificationsViewModel()
{
CommentId = c.CommentId,
CreatedDate = c.CommentDate,
CommentText = c.CommentText,
UpdateId = c.UpdateId,
GoalName = c.Update.Goal.GoalName,
GoalId = c.Update.GoalId,
NumberOfComments = commentService.GetCommentsByUpdate(c.UpdateId).Count(),
Updatemsg = updateService.GetUpdate(c.UpdateId).Updatemsg,
NotificationDate = DateCalculation(c.CommentDate),
UserName = commentUserService.GetUser(c.CommentId).UserName,
UserId = commentUserService.GetUser(c.CommentId).Id,
ProfilePicUrl = commentUserService.GetUser(c.CommentId).ProfilePicUrl,
NotificationType = (int)NotificationType.commentedOnUpdate
})
.Concat(from u in updates
select new NotificationsViewModel()
{
Update = u,
UpdateId = u.UpdateId,
GoalId = u.GoalId,
ProfilePicUrl = u.Goal.User.ProfilePicUrl,
GoalName = u.Goal.GoalName,
Updatemsg = u.Updatemsg,
UserId = u.Goal.UserId,
UserName = u.Goal.User.UserName,
NumberOfComments = commentService.GetCommentsByUpdate(u.UpdateId).Count(),
CreatedDate = u.UpdateDate,
NotificationDate = DateCalculation(u.UpdateDate),
NotificationType = (int)NotificationType.updatedGoal
})
.Concat(from gr in groupgoals
select new NotificationsViewModel()
{
GroupGoalId = gr.GroupGoalId,
CreatedDate = gr.CreatedDate,
UserId = gr.GroupUser.UserId,
UserName = userService.GetUser(gr.GroupUser.UserId).UserName,
ProfilePicUrl = userService.GetUser(gr.GroupUser.UserId).ProfilePicUrl,
GroupName = gr.Group.GroupName,
GroupGoalName = gr.GoalName,
GroupId = gr.GroupId,
NotificationDate = DateCalculation(gr.CreatedDate),
NotificationType = (int)NotificationType.createGroup
})
.Concat(from gu in groupusers
select new NotificationsViewModel()
{
GroupUser = gu,
GroupUserId = gu.GroupUserId,
UserId = gu.UserId,
UserName = userService.GetUser(gu.UserId).UserName,
ProfilePicUrl = userService.GetUser(gu.UserId).ProfilePicUrl,
GroupName = groupService.GetGroup(gu.GroupId).GroupName,
GroupId = gu.GroupId,
CreatedDate = gu.AddedDate,
NotificationDate = DateCalculation(gu.AddedDate),
NotificationType = (int)NotificationType.joinGroup
})
.Concat(from s in supports
select new NotificationsViewModel()
{
Support = s,
SupportId = s.SupportId,
//.........这里部分代码省略.........
示例6: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IUserService userService)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseIISPlatformHandler();
app.UseCors(builder =>
{
builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials();
});
app.UseBearerAuthentication(options =>
{
options.Events = new BearerAuthenticationEvents
{
OnSigningIn = async context =>
{
await Task.Run(() =>
{
Debug.WriteLine("Signing in...");
});
},
OnSignedIn = async context =>
{
await Task.Run(() =>
{
Debug.WriteLine("Signed in...");
});
},
OnValidatePrincipal = async context =>
{
await Task.Run(() =>
{
Debug.WriteLine("Validate principal...");
var userIdClaim = context.Principal.FindFirst(x => x.Type == "UserId");
int userId;
User user;
if (userIdClaim == null ||
!int.TryParse(userIdClaim.Value, out userId) ||
(user = userService.GetUser(userId)) == null ||
!user.IsActive)
context.RejectPrincipal();
});
},
OnSigningOut = async context =>
{
await Task.Run(() =>
{
Debug.WriteLine("Signing out...");
});
},
OnUnauthorized = async context =>
{
await Task.Run(() =>
{
Debug.WriteLine("Unauthorized...");
});
},
OnForbidden = async context =>
{
await Task.Run(() =>
{
Debug.WriteLine("Forbidden...");
});
}
};
});
app.UseStaticFiles();
app.UseMvc();
}