本文整理汇总了C#中UserService类的典型用法代码示例。如果您正苦于以下问题:C# UserService类的具体用法?C# UserService怎么用?C# UserService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserService类属于命名空间,在下文中一共展示了UserService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GeTeamRank
public string GeTeamRank()
{
UserGroupService usergSerivice = new UserGroupService();
UserService userService = new UserService();
List<UserGroup> usergList = usergSerivice.FindAll();
List<RankListTeam> rankListTeam = new List<RankListTeam>();
List<User> userList = new List<User>();
for (int i = 2; i < usergList.Count; i++) {
userList = userService.FindUsersByGroupId(usergList[i].Id);
int count = 0;
for (int j = 0; j < userList.Count; j++) {
//获取每个用户的发表的知识数量,并求和
AriticleService ariticleService = new AriticleService();
int n = ariticleService.GetAriticleCount(userList[j].Id);
count += n;
}
RankListTeam rlt = new RankListTeam();
rlt.Title = usergList[i].Title;
rlt.AriticleCount = count;
rankListTeam.Add(rlt);
}
//对结果排序
var queryResults =
from n in rankListTeam
orderby n.AriticleCount descending
select n;
List<RankListTeam> rktList = new List<RankListTeam>();
foreach (var n in queryResults)
{
rktList.Add(n);
}
string result = JsonConvert.SerializeObject(rktList);
return result;
}
示例2: UserApiController
public UserApiController(UserQueries queries, UserService service, IUserPermissionContext permissionContext, IEntryThumbPersister thumbPersister)
{
this.queries = queries;
this.service = service;
this.permissionContext = permissionContext;
this.thumbPersister = thumbPersister;
}
示例3: Factory
public static IUserService Factory()
{
var repo = new DefaultUserAccountRepository();
var userAccountService = new UserAccountService(config, repo);
var userSvc = new UserService<UserAccount>(userAccountService, repo);
return userSvc;
}
示例4: DeleteUser
TestResult DeleteUser()
{
using (var unitOfWork = new UnitOfWork(new AuthorizationModuleFactory(false)))
{
var UserService = new UserService(unitOfWork);
var testUser = UserService.Get(user => user.Login == "ivan_test++").FirstOrDefault();
UserService.Delete(testUser);
try
{
var result = unitOfWork.Commit();
if (result.Count > 0)
return new TestResult(TestResultType.Failure, MethodBase.GetCurrentMethod().Name, result.First().ErrorMessage);
}
catch (Exception ex)
{
while (ex.InnerException != null)
ex = ex.InnerException;
return new TestResult(TestResultType.Failure, MethodBase.GetCurrentMethod().Name, ex.Message);
}
}
using (var unitOfWork = new UnitOfWork(new AuthorizationModuleFactory(false)))
{
var UserService = new UserService(unitOfWork);
User testUser = UserService.Get(user => user.Login == "ivan_test++").FirstOrDefault();
if (testUser != null)
return new TestResult(TestResultType.Failure, MethodBase.GetCurrentMethod().Name, "Can find deleted user.");
else
return new TestResult(TestResultType.Success, MethodBase.GetCurrentMethod().Name, "User deleted successfully.");
}
}
示例5: Initialize
protected override void Initialize(System.Web.Routing.RequestContext requestContext)
{
if (_db == null) _db = new EpiloggerDB();
if (_es == null) _es = new EventService();
if (_us == null) _us = new UserService();
base.Initialize(requestContext);
}
示例6: CheckPasswd
public int CheckPasswd(string username, string password)
{
UserService userService = new UserService();
int type;
type = userService.CheckPasswd(username, password);
return type;
}
示例7: Execute
/// <summary>
/// Job that updates the JobPulse setting with the current date/time.
/// This will allow us to notify an admin if the jobs stop running.
///
/// Called by the <see cref="IScheduler" /> when a
/// <see cref="ITrigger" /> fires that is associated with
/// the <see cref="IJob" />.
/// </summary>
public virtual void Execute(IJobExecutionContext context)
{
// get the job map
JobDataMap dataMap = context.JobDetail.JobDataMap;
// delete accounts that have not been confirmed in X hours
int userExpireHours = Int32.Parse( dataMap.GetString( "HoursKeepUnconfirmedAccounts" ) );
DateTime userAccountExpireDate = DateTime.Now.Add( new TimeSpan( userExpireHours * -1,0,0 ) );
UserService userService = new UserService();
foreach (var user in userService.Queryable().Where(u => u.IsConfirmed == false && u.CreationDate < userAccountExpireDate))
{
userService.Delete( user, null );
}
userService.Save( null, null );
// purge exception log
int exceptionExpireDays = Int32.Parse( dataMap.GetString( "DaysKeepExceptions" ) );
DateTime exceptionExpireDate = DateTime.Now.Add( new TimeSpan( userExpireHours * -1, 0, 0 ) );
ExceptionLogService exceptionLogService = new ExceptionLogService();
foreach ( var exception in exceptionLogService.Queryable().Where( e => e.ExceptionDate < exceptionExpireDate ) )
{
exceptionLogService.Delete( exception, null );
}
exceptionLogService.Save( null, null );
}
示例8: getMemberById
//public string getMemberById(string userId) {
// UserService userservice = new UserService();
// User user = userservice.FindById(userId);
// MemberViewModel mvm = new MemberViewModel(user);
// UserGroupService ugs = new UserGroupService();
// List<UserGroup> list = ugs.FindAll();
// string memberResult = JsonConvert.SerializeObject(mvm);
// List<UserGroupViewModel> ugvlist = new List<UserGroupViewModel>();
// UserGroupViewModel ugv;
// for (int i = 0; i < list.Count; i++)
// {
// ugv = new UserGroupViewModel(list[i]);
// ugvlist.Add(ugv);
// }
// string result = JsonConvert.SerializeObject(ugvlist);
// return memberResult+"MemberAndGroupList"+result;
//}
public string getMemberById(string userId)
{
using (RRDLEntities db = new RRDLEntities())
{
UserService userservice = new UserService();
User user = userservice.FindById(userId);
MemberViewModel mvm = new MemberViewModel(user);
int approvedcount = 0;
int allcount = 0;
AriticleService ariticleService = new AriticleService();
Expression<Func<Ariticle, bool>> condition =
a => a.Approve.ApproveStatus == EnumAriticleApproveStatus.Approved
&& a.UserId == user.Id;
approvedcount = ariticleService.GetAriticleCount(condition);
condition =
a => a.UserId == user.Id;
allcount = ariticleService.GetAriticleCount(condition);
mvm.approvedArticleCount = approvedcount;
mvm.allArticleCount = allcount;
UserGroupService ugs = new UserGroupService();
List<UserGroup> list = ugs.FindAll();
string memberResult = JsonConvert.SerializeObject(mvm);
List<UserGroupViewModel> ugvlist = new List<UserGroupViewModel>();
UserGroupViewModel ugv;
for (int i = 0; i < list.Count; i++)
{
ugv = new UserGroupViewModel(list[i]);
ugvlist.Add(ugv);
}
string result = JsonConvert.SerializeObject(ugvlist);
return memberResult + "MemberAndGroupList" + result;
}
}
示例9: GridView1_RowUpdating
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
UserDetails userDetails = new UserDetails();
userDetails.userID = GridView1.Rows[e.RowIndex].Cells[0].Text;
userDetails.firstName = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text;
userDetails.lastName = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text;
userDetails.phone = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text;
userDetails.cityID = int.Parse(((DropDownList)(GridView1.Rows[e.RowIndex].Cells[3].FindControl("DropDownList1"))).SelectedValue);
userDetails.address = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[6].FindControl("TextBox1"))).Text;
userDetails.state = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[6].FindControl("TextBox3"))).Text;
userDetails.zipCode = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[6].FindControl("TextBox2"))).Text;
UserService userService = new UserService();
userService.UpdateUserDetails(userDetails);
GridView1.EditIndex = -1;
populateGrid();
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
}
示例10: ToggleFavorite
public ActionResult ToggleFavorite(int id)
{
var userService = new UserService();
var snippet = _snippetService.GetById(id);
var user = userService.GetByUsername(User.Identity.Name);
var favorite = user.Favorites.SingleOrDefault(s => s.Snippet.SnippetId == snippet.SnippetId);
if (favorite != null) {
snippet.Favorited--;
user.Favorites.Remove(favorite);
}
else {
snippet.Favorited++;
user.Favorites.Add(new Favorite {
DateCreated = DateTime.Now,
Snippet = snippet,
User = user
});
}
userService.Save();
if (Request.IsAjaxRequest())
return Json(new {success = true });
return Redirect(snippet.Link);
}
示例11: GetMembers
//无参数传入,返回当前所有会员的序列化字符串和当前会员总数
public ActionResult GetMembers(int numOnePage, int pageIndex)
{
UserService userservice = new UserService();
List<User> list = new List<User>();
list = userservice.FindUsersByApproveStatus(EnumUserApproveStatus.Approved, numOnePage, pageIndex);
//因为需要返回的用户属性信息只是一部分,所以要新建一个类型来保存User的部分属性即可
List<MemberViewModel> memberList = new List<MemberViewModel>();
for (int i = 0; i < list.Count; i++)
{
if ((list[i].AuthorityCategory == EnumUserCategory.Superman && list[i].RealName != "雷磊") || (list[i].AuthorityCategory != EnumUserCategory.Superman) )
{
MemberViewModel member = new MemberViewModel(list[i]);
member.RealName = list[i].RealName;
member.AuthorityCategory = list[i].AuthorityCategory;
//member.ContentGroup = list[i].ContentGroup;
member.Id = list[i].Id;
memberList.Add(member);
}
}
string result = JsonConvert.SerializeObject(memberList);
//以下获取所有会员的总个数
UserService userservice1 = new UserService();
int number = userservice1.GetUserCount(EnumUserApproveStatus.Approved);
result = result + "ContentAndCount" + number;
return Content(result);
}
示例12: Start
// Use this for initialization
void Start()
{
//nao executa o resto da função caso haja um estado salvo
// if (LevelSerializer.IsDeserializing) return;
_UserService = WebService.GetComponent<UserService>();
}
示例13: SaveUserPosts
/// <summary>
/// 保存用户评论数据
/// </summary>
/// <param name="context"></param>
public void SaveUserPosts(HttpContext context)
{
ZwJson zwJson = new ZwJson();
UserPostsService userPostsService = new UserPostsService(_session);
UserService userService = new UserService(_session);
var postid = context.Request.Params["postid"];
var khtml = context.Request.Params["khtml"];
var name = context.Session["UserName"];
if (name != null)
{
var data = userService.FindByName(name.ToString());
Posts posts = new Posts() { Id = postid };
UserPosts userPosts = new UserPosts()
{
Id = Guid.NewGuid().ToString(),
Contents = khtml,
CreateDt = DateTime.Now,
Posts = posts,
User = data[0]
};
userPostsService.Save(userPosts);
zwJson.IsSuccess = true;
zwJson.JsExecuteMethod = "ajax_SaveUserPosts";
}
else
{
zwJson.IsSuccess = false;
zwJson.Msg = "请先登录!";
}
context.Response.Write(_jss.Serialize(zwJson));
}
示例14: Configure
public void Configure(IApplicationBuilder app, IApplicationEnvironment env)
{
var certFile = env.ApplicationBasePath + "\\idsrv3test.pfx";
app.Map("/core", core =>
{
var factory = InMemoryFactory.Create(
clients: Clients.Get(),
scopes: Scopes.Get());
var userService = new UserService();
factory.UserService = new Registration<IUserService>(resolver => userService);
// factory.ViewService = new Registration<IViewService>(typeof(CustomViewService));
var idsrvOptions = new IdentityServerOptions
{
IssuerUri = "",
Factory = factory,
RequireSsl = false,
LoggingOptions =
// SigningCertificate = new X509Certificate2(certFile, "idsrv3test")
};
core.UseIdentityServer(idsrvOptions);
});
示例15: CanCreateUserWhenUserNotFound
public void CanCreateUserWhenUserNotFound()
{
// Arrange
_userByEmailQuery
.Execute(Arg.Any<UserByEmailParameters>())
.Returns((VouchercloudUser)null);
_createUserCommand.Execute(Arg.Any<CreateUserParameters>())
.Returns(
new VouchercloudUser
{
UserId = 1
});
var service = new UserService(_userByEmailQuery, _createUserCommand, _deleteUserCommand);
var request = new CreateUser
{
DateOfBirth = new DateTime(1980, 1, 1),
Email = "[email protected]",
FirstName = "James",
LastName = "Harper",
Password = "Password"
};
// Act
var response = service.Post(request);
// Assert
_createUserCommand
.Received(1)
.Execute(Arg.Any<CreateUserParameters>());
response.Should().NotBeNull();
response.UserId.Should().Be(1);
}