本文整理汇总了C#中UserService类的典型用法代码示例。如果您正苦于以下问题:C# UserService类的具体用法?C# UserService怎么用?C# UserService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserService类属于命名空间,在下文中一共展示了UserService类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:34,代码来源:RankListController.cs
示例2: UserApiController
public UserApiController(UserQueries queries, UserService service, IUserPermissionContext permissionContext, IEntryThumbPersister thumbPersister)
{
this.queries = queries;
this.service = service;
this.permissionContext = permissionContext;
this.thumbPersister = thumbPersister;
}
开发者ID:realzhaorong,项目名称:vocadb,代码行数:7,代码来源:UserApiController.cs
示例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;
}
开发者ID:ErikM040566,项目名称:Thinktecture.IdentityServer.v3,代码行数:7,代码来源:UserServiceFactory.cs
示例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.");
}
}
开发者ID:vano-lukashuk,项目名称:StudentBank,代码行数:33,代码来源:UserTest.cs
示例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);
}
开发者ID:jonezy,项目名称:Epilogger,代码行数:7,代码来源:HomeController.cs
示例6: CheckPasswd
public int CheckPasswd(string username, string password)
{
UserService userService = new UserService();
int type;
type = userService.CheckPasswd(username, password);
return type;
}
开发者ID:zlmoment,项目名称:CourseSelectionSystem,代码行数:7,代码来源:UserBusiness.cs
示例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 );
}
开发者ID:jh2mhs8,项目名称:Rock-ChMS,代码行数:39,代码来源:RockCleanup.cs
示例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;
}
}
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:52,代码来源:MemberManageController.cs
示例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;
}
}
开发者ID:yanoovoni,项目名称:Rdroid,代码行数:27,代码来源:UserManagmnent.aspx.cs
示例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);
}
开发者ID:simplyio,项目名称:snippet-box,代码行数:28,代码来源:SnippetController.cs
示例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);
}
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:27,代码来源:MemberManageController.cs
示例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>();
}
开发者ID:urgamedev,项目名称:TinyChoice,代码行数:8,代码来源:Aluno.cs
示例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));
}
开发者ID:BGCX262,项目名称:zw-subject-svn-to-git,代码行数:37,代码来源:UserPostsHandler.ashx.cs
示例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);
});
开发者ID:reddychaitanya,项目名称:Identity,代码行数:26,代码来源:Startup.cs
示例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);
}
开发者ID:james00harper,项目名称:AutoFixtureDemo,代码行数:35,代码来源:UserServiceTests.cs
示例16: AddUser
public JsonResult AddUser([DataSourceRequest] DataSourceRequest request, UserModel userModel)
{
try
{
if (userModel != null)
{
this.userService = new UserService();
var user = DataTransfer.Transfer<User>(userModel, typeof(UserModel));
userModel.ID = this.userService.AddUser(user);
if (userModel.ID <= 0)
{
return this.Json(string.Empty);
}
userModel.UserLevelName = "普通会员";
userModel.StateName = "锁定会员";
LogUtils.Log("用户" + this.SystemUserSession.LoginName + "成功添加会员" + userModel.Email, "AddUser", Category.Info, Session.SessionID);
return this.Json(new[] { userModel }.ToDataSourceResult(request, this.ModelState));
}
return this.Json(string.Empty);
}
catch (Exception exception)
{
throw new Exception(exception.Message, exception);
}
}
开发者ID:jxzly229190,项目名称:OnlineStore,代码行数:27,代码来源:User.Default.cs
示例17: HttpErrorThrownWhenCreatingUserAlreadyExists
public void HttpErrorThrownWhenCreatingUserAlreadyExists()
{
// Arrange
_userByEmailQuery
.Execute(Arg.Any<UserByEmailParameters>())
.Returns(new VouchercloudUser());
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, Assert
service
.Invoking(s => s.Post(request))
.ShouldThrow<HttpError>().And.Message.Should().Be("User already exists");
_createUserCommand
.DidNotReceive()
.Execute(Arg.Any<CreateUserParameters>());
}
开发者ID:james00harper,项目名称:AutoFixtureDemo,代码行数:27,代码来源:UserServiceTests.cs
示例18: GetTaskByProjIdAndGroupId
/// <summary>
/// 传入项目ID 分组ID 得到此条件下的全部任务 列表
/// </summary>
/// <param name="projId"></param>
/// <param name="groupId"></param>
/// <returns></returns>
public ActionResult GetTaskByProjIdAndGroupId(int projId, int groupId)
{
RRWMEntities er = new RRWMEntities();
//获取这个groupID下的全部的用户ID
List<string> idString = new List<string>();
UserService us = new UserService();
List<User> userList = us.FindUsersByGroupId(groupId);
foreach (var u in userList)
{
idString.Add(u.Id);
}
//过滤结果
TaskService ts = new TaskService(er);
List<Task> list = ts.FindByProjectID(projId).ToList();
List<Task> resultList = new List<Task>();
foreach (var l in list)
{
if (idString.Contains(l.TaskerID) && l.TaskProcessStatus == EnumTaskProcessStatus.None)
{
resultList.Add(l);
}
}
List<ComplexTask> comList = ConvertToComplexTaskList(resultList);
return Json(comList);
}
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:31,代码来源:WMTaskController.cs
示例19: MemberManageSearch
//
// GET: /MemberManageSearch/
//会员的NickName、RealName、用户组名
public ActionResult MemberManageSearch(int numOnePage, int pageIndex, string keyword)
{
keyword = System.Web.HttpUtility.UrlDecode(keyword);
UserService userService = new UserService();
List<User> list = new List<User>();
list = userService.FindMembersByKeyword(keyword, numOnePage, pageIndex);
int count = userService.FindMembersByKeywordCount(keyword);
UserViewModel uvm;
List<UserViewModel> uvmlist = new List<UserViewModel>();
for (int i = 0; i < list.Count; i++)
{
if ((list[i].AuthorityCategory == EnumUserCategory.Superman && list[i].RealName != "雷磊") || (list[i].AuthorityCategory != EnumUserCategory.Superman))
{
uvm = new UserViewModel();
uvm.Id = list[i].Id;
uvm.AuthorityCategory = list[i].AuthorityCategory;
uvm.NickName = list[i].NickName;
uvm.PersonalDescription = list[i].PersonalDescription;
uvm.RegisterName = list[i].RegisterName;
uvm.RealName = list[i].RealName;
uvm.Gender = list[i].Gender;
uvmlist.Add(uvm);
}
}
string result = JsonConvert.SerializeObject(uvmlist);//到这里获取当前所有待审核的用户并序列化
result = result + "ContentAndCount" + count;
return Content(result);
}
开发者ID:hiyouth,项目名称:R2.RRDL,代码行数:31,代码来源:MemberManageSearchController.cs
示例20: Application_AcquireRequestState
protected void Application_AcquireRequestState(Object sender, EventArgs e)
{
if (!(Context.Handler is IRequiresSessionState)) return;
if (Context.User == null || !Context.User.Identity.IsAuthenticated || Context.Session == null) return;
try {
User user = null;
if (Context.Session["User"] != null) {
user = Context.Session["User"] as User;
}
else {
UserService userService = new UserService();
user = userService.GetByUsername(Context.User.Identity.Name);
if (user == null) {
FormsAuthentication.SignOut();
return;
}
Context.Session.Add("User", user);
}
Thread.CurrentPrincipal = Context.User = user;
}
catch { }
}
开发者ID:simplyio,项目名称:snippet-box,代码行数:27,代码来源:Global.asax.cs
注:本文中的UserService类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论