当前位置: 首页>>代码示例>>C#>>正文


C# UserService.Get方法代码示例

本文整理汇总了C#中UserService.Get方法的典型用法代码示例。如果您正苦于以下问题:C# UserService.Get方法的具体用法?C# UserService.Get怎么用?C# UserService.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserService的用法示例。


在下文中一共展示了UserService.Get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetUser

 public string GetUser(HttpContext context)
 {
     ISession session = SessionFactory.GetCurrentSession();
     UserService user = new UserService(session);
     var userlist = user.Get();
     SessionFactory.CloseSession();
     var str = "Hello";
     return str;
 }
开发者ID:BGCX262,项目名称:zw-subject-svn-to-git,代码行数:9,代码来源:UserHandler.ashx.cs

示例2: AddUser

        TestResult AddUser()
        {
            using (var unitOfWork = new UnitOfWork(new AuthorizationModuleFactory(true)))
            {
                var RoleService = new RoleService(unitOfWork);
                var UserService = new UserService(unitOfWork);

                var testUser = new User
                {
                    Login = "ivan_test",
                    Password = "ivan_test_pass",
                    //Password = "f5DBIwnAMS",
                    Email = "[email protected]",
                    CreatedDate = DateTime.Now,
                    //FirstName = "Ivan",
                    //MiddleName = "Semenovich",
                    //LastName = "Peresvetov",
                    FirstName = "Иван",
                    MiddleName = "Семенович",
                    LastName = "Пересветов",
                    Roles = new List<Role>(new Role[] { RoleService.Get().First() }),
                };

                UserService.Add(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't find added user.");
                else
                    return new TestResult(TestResultType.Success, MethodBase.GetCurrentMethod().Name, "User added successfully.");
            }
        }
开发者ID:vano-lukashuk,项目名称:StudentBank,代码行数:48,代码来源:UserTest.cs

示例3: Role

 private bool Role(HttpContextBase httpContext)
 {
     if (RoleList != null && RoleList.Any())
     {
         using (var unitOfWork = new UnitOfWork(new AuthorizationModuleFactory()))
         {
             var userService = new UserService(unitOfWork);
             var user = userService.Get(u => u.Login == httpContext.User.Identity.Name, null, u => u.Roles).First();
             Authentication.User = user;
             //if (users != null)
             {
                 //var user = users.First();
                 if (user.Roles != null)
                 {
                     if(user.Roles.Select(r=>(Roles)r.Id).Intersect(RoleList.ToList()).Any())
                         return true;
                 }
             }
         }
         return false;
     }
     return true;
 }
开发者ID:vano-lukashuk,项目名称:StudentBank,代码行数:23,代码来源:BankAuthorizedAttribute.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: Main

        static void Main(string[] args)
        {
            bool useAutoGeneration = false;
            bool useTests = false;
            bool useInitializers = true;

            if(useAutoGeneration)
            {
                using (var unitOfWork = new UnitOfWork(new BankModuleFactory(useInitializers)))
                {
                    var LoanApplicationService = new LoanApplicationService(unitOfWork);
                    var LoanAgreementService = new LoanAgreementService(unitOfWork);

                    Console.WriteLine("Автогенерация для заявок:");
                    foreach (var loanApplication in LoanApplicationService.Get())
                    {
                        if (loanApplication.Goal == "Смена гардероба" || loanApplication.Goal == "Пластическая операция" || loanApplication.Additional == "Car loan test"
                            || loanApplication.Additional == "Grad loan test 1" || loanApplication.Additional == "Grad loan test 2")
                        {
                            Console.WriteLine(string.Format("{0} {1} {2}", loanApplication.Client.FirstName, loanApplication.Goal, loanApplication.Term));

                            loanApplication.Status.Stage = ApplicationConsiderationStages.ApplicationConfirmationQueue;
                            LoanApplicationService.ApproveApplication(loanApplication);
                            loanApplication.Status.Stage = ApplicationConsiderationStages.Providing;
                            LoanAgreementService.CompleteAgreement(loanApplication.LoanAgreements.First());
                            unitOfWork.Commit();
                        }
                    }

                    Console.WriteLine("\nРезультаты:\n");
                    foreach (var loanApplication in LoanApplicationService.Get())
                    {
                        if (loanApplication.Goal == "Смена гардероба" || loanApplication.Goal == "Пластическая операция" || loanApplication.Additional == "Car loan test"
                            || loanApplication.Additional == "Grad loan test 1" || loanApplication.Additional == "Grad loan test 2")
                        {
                            Console.WriteLine(string.Format("{0} {1} {2}", loanApplication.Client.FirstName, loanApplication.Goal, loanApplication.Term));
                            Console.WriteLine("Создан кредитный договор:");
                            var loanAgreement = loanApplication.LoanAgreements.First();
                            Console.WriteLine(string.Format("Номер:{0} Кредитный аккаунт:{1} Аккаунт для оплаты:{2}", loanAgreement.Id, loanAgreement.LoanAccount.IBAN,
                                loanAgreement.RepaymentAccount.IBAN));
                            foreach(var bailAgreement in loanApplication.BailAgreements)
                            {
                                Console.WriteLine("Создан договор залога:");
                                Console.WriteLine(string.Format("Номер:{0} Объект:{1} Владелец:{2}", bailAgreement.Id, bailAgreement.BailObject,
                                    bailAgreement.BailObjectHolder));
                            }
                            foreach (var suretyAgreement in loanApplication.SuretyAgreements)
                            {
                                Console.WriteLine("Создан договор поручительства:");
                                Console.WriteLine(string.Format("Номер:{0} Поручитель:{1} Должник:{2}", suretyAgreement.Id, suretyAgreement.Guarantor.FirstName + " " + suretyAgreement.Guarantor.LastName,
                                    suretyAgreement.Client.FirstName));
                            }
                            Console.WriteLine();
                        }
                    }
                }
                System.Console.ReadKey(true);
                return;
            }

            if(useTests)
            {
                Console.WriteLine(new LoanTest().RunTest());
                Console.WriteLine(new UserTest().RunTest());
                System.Console.ReadKey(true);
                return;
            }

            List<LoanApplication> archiveApplications;

            using (var unitOfWork = new UnitOfWork(new BankModuleFactory(useInitializers)))
            {
                var AccountService = new AccountService(unitOfWork);
                Console.WriteLine("Accounts:");
                foreach(var account in AccountService.Get())
                {
                    System.Console.WriteLine(string.Format("{0} {1} {2} {3} Transfers From: {4}  Transfers To:{5}",
                        account.IBAN, account.AccountType, account.MoneyAmount, account.Currency, account.BankTransfersFrom.Count, account.BankTransfersTo.Count));
                }

                var BankTransferService = new BankTransferService(unitOfWork);
                Console.WriteLine("Transfers:");
                foreach (var transfer in BankTransferService.Get(includeProperties: "AccountFrom,AccountTo"))
                    Console.WriteLine(string.Format("From: {0} To: {1} {2} {3} {4}", transfer.AccountFrom.IBAN, transfer.AccountTo.IBAN,
                        transfer.Amount, transfer.Currency, transfer.TransferDate.ToShortDateString()));

                var LoanAgreementService = new LoanAgreementService(unitOfWork);
                Console.WriteLine("Loan Agreements:");
                foreach (var loanAgreement in LoanAgreementService.Get(includeProperties: "PayoutStatus"))
                    Console.WriteLine(string.Format("{0} {1} {2} {3} {4} {5} {6}", loanAgreement.Client.FirstName, loanAgreement.LoanType,
                        loanAgreement.LoanProviding, loanAgreement.LoanRepayment, loanAgreement.Term, loanAgreement.Amount, loanAgreement.Currency));

                var PayoutService = new PayoutService(unitOfWork);
                Console.WriteLine("Payouts:");
                foreach (var payout in PayoutService.Get())
                    Console.WriteLine(string.Format("{0} {1} {2} {3} {4} {5}", payout.PayoutWay, payout.LoanAmount, payout.ProcessingFee,
                        payout.InterestAmount, payout.TotalAmount, payout.Currency));

                var FineService = new FineService(unitOfWork);
                Console.WriteLine("Fines:");
//.........这里部分代码省略.........
开发者ID:vano-lukashuk,项目名称:StudentBank,代码行数:101,代码来源:Program.cs

示例6: Users

        public ActionResult Users(int? page, string sortOrder, string searchString)
        {
            //IEnumerable<User> users = _controleHelper.GetEntities<User>();

            IEnumerable<User> users = new List<User>();
            using (var unitOfWork = new UnitOfWork(new AuthorizationModuleFactory()))
            {
                var userService = new UserService(unitOfWork);
                users = userService.Get(GetSearchUser(searchString), GetOrderUser(sortOrder), user => user.Roles);
            }

            return View(users.ToPagedList(page ?? 1, pageSize));
        }
开发者ID:vano-lukashuk,项目名称:StudentBank,代码行数:13,代码来源:AdministrationController.cs

示例7: UserEdit

 public ActionResult UserEdit(long id, UserEditViewModel userEdit)
 {
     if (!ModelState.IsValid)
     {
         return View(userEdit);
     }
     using (var unitOfWork = new UnitOfWork(new AuthorizationModuleFactory()))
     {
         var userService = new UserService(unitOfWork);
         var roleService = new RoleService(unitOfWork);//add
         User user = userService.Get(u => u.Id == id, null, u => u.Roles, u => u.Roles).FirstOrDefault();
         user.Email = userEdit.Email;
         user.FirstName = userEdit.FirstName;
         user.LastName = userEdit.LastName;
         user.Login = userEdit.Login;
         user.MiddleName = userEdit.MiddleName;
         user.Roles = roleService.Get(role => userEdit.Roles.Contains(role.Id)).ToList();
         user.Roles = userEdit.Roles.Select(r => new Role { Id = r }).ToList();
         unitOfWork.Commit();
     }
     /*if (successUser == null)
     {
         ModelState.AddModelError("id", App_LocalResources.Resource.UpdateError);
         return View(userEdit);
     }*/
     return RedirectToAction("Index");
 }
开发者ID:vano-lukashuk,项目名称:StudentBank,代码行数:27,代码来源:AdministrationController.cs


注:本文中的UserService.Get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。