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


C# UnitOfWork.RepositoryAsync方法代码示例

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


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

示例1: TestEmployeerOrderApiController

 public TestEmployeerOrderApiController()
 {
     _unitOfWork = new UnitOfWork(new ApplicationDbContext());
     _userManager = new ApplicationUserManager(new UserStore<User>(_unitOfWork.GetContext()));
     _weekOrderMenuService = new OrderMenuService(_unitOfWork.RepositoryAsync<WeekOrderMenu>());
     _weekMenuService = new MenuForWeekService(_unitOfWork.RepositoryAsync<MenuForWeek>());
     _weekPaimentService = new WeekPaimentService(_unitOfWork.RepositoryAsync<WeekPaiment>());
 }
开发者ID:densem-2013,项目名称:ACSDining,代码行数:8,代码来源:TestEmployeerOrderApiController.cs

示例2: StoredQueryTest

 public StoredQueryTest()
 {
     _unitOfWork = new UnitOfWork(new ApplicationDbContext());
     _userManager = new ApplicationUserManager(new UserStore<User>(_unitOfWork.GetContext()));
     _weekOrderMenuRepository = _unitOfWork.RepositoryAsync<WeekOrderMenu>();
     _weekMenuRepository = _unitOfWork.RepositoryAsync<MenuForWeek>();
     _weekPaimentService = new WeekPaimentService(_unitOfWork.RepositoryAsync<WeekPaiment>());
 }
开发者ID:densem-2013,项目名称:ACSDining,代码行数:8,代码来源:StoredQueryTest.cs

示例3: EnsurePutUpdatesExistingChoreAndSetsHttpStatus

		public async Task EnsurePutUpdatesExistingChoreAndSetsHttpStatus()
		{
			using (var dbInfo = Utility.CreateSeededTestDatabase())
			using (var context = new EntitiesContext(dbInfo.ConnectionString))
			using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context))
			{
				IChoreService service = new ChoreService(unitOfWork.RepositoryAsync<Chore>());
				ChoresController controller = new ChoresController(unitOfWork, service, new FakeTimeService(new DateTime(2015, 11, 1)));
					
				controller.SetControllerContext(HttpMethod.Post, "http://localhost/RowanAdams/api/chores");
				var result = await controller.Post(new Chore { Name = "Test Chore 1", Value = 10 });
				var chore = context.Chores.Single();
				chore.Active = false;

				controller.SetControllerContext(HttpMethod.Put, "http://localhost/RowanAdams/api/chores");
				result = await controller.Put(chore);
				var response = await result.ExecuteAsync(new CancellationToken());

				var chore2 = context.Chores.Single();
				Assert.AreEqual(chore.Id, chore2.Id);
				Assert.IsFalse(chore.Active);
				Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode);
				Assert.AreEqual($"/api/chores/{chore2.Id}", response.Headers.Location.AbsolutePath);
			}
		}
开发者ID:ItWorksOnMyMachine,项目名称:RowanPAdams,代码行数:25,代码来源:ChoresControllerTests.cs

示例4: Initialize

		public void Initialize()
		{
			dbInfo = Utility.CreateSeededTestDatabase();

			using (var context = new EntitiesContext(dbInfo.ConnectionString))
			using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context))
			{
				IChoreService service = new ChoreService(unitOfWork.RepositoryAsync<Chore>());
				ChoresController controller = new ChoresController(unitOfWork, service, new FakeTimeService(new DateTime(2015, 11, 1)))
					.SetControllerContext(HttpMethod.Post, "http://localhost/RowanAdams/api/chores");

				var result = controller.Post(new Chore { Name = "Test Chore 1", Value = 10 });
				result.Wait();
			}
		}
开发者ID:ItWorksOnMyMachine,项目名称:RowanPAdams,代码行数:15,代码来源:LogEntriesControllerTests.cs

示例5: EnsurePostReturnsErrorWhenInvalidModel

		public async Task EnsurePostReturnsErrorWhenInvalidModel()
		{
			using (var context = new EntitiesContext(dbInfo.ConnectionString))
			using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context))
			{
				var chore = context.Chores.Single();
				ILogEntryService service = new LogEntryService(unitOfWork.RepositoryAsync<LogEntry>());
				var controller = new LogEntriesController(unitOfWork, service);
				controller.ModelState.AddModelError("TestError", new Exception());
				controller.SetControllerContext(HttpMethod.Post, "http://localhost/RowanAdams/api/logentries");
				var result = await controller.Post(new LogEntry { });
				var response = await result.ExecuteAsync(new CancellationToken());
				Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
			}
		}
开发者ID:ItWorksOnMyMachine,项目名称:RowanPAdams,代码行数:15,代码来源:LogEntriesControllerTests.cs

示例6: EnsurePostReturnsErrorWhenInvalidModel

		public async Task EnsurePostReturnsErrorWhenInvalidModel()
		{
			using (var dbInfo = Utility.CreateSeededTestDatabase())
			using (var context = new EntitiesContext(dbInfo.ConnectionString))
			using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context))
			{
				IChoreService service = new ChoreService(unitOfWork.RepositoryAsync<Chore>());
				ChoresController controller = new ChoresController(unitOfWork, service, new FakeTimeService(new DateTime(2015, 11, 1)));

				controller.ModelState.AddModelError("TestError", new Exception());
				controller.SetControllerContext(HttpMethod.Post, "http://localhost/RowanAdams/api/chores");
				var result = await controller.Post(new Chore { });
				var response = await result.ExecuteAsync(new CancellationToken());
				Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
			}
		}
开发者ID:ItWorksOnMyMachine,项目名称:RowanPAdams,代码行数:16,代码来源:ChoresControllerTests.cs

示例7: EnsurePostCreatesNewLogEntryAndSetsHttpStatus

		public async Task EnsurePostCreatesNewLogEntryAndSetsHttpStatus()
		{
			using (var context = new EntitiesContext(dbInfo.ConnectionString))
			using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context))
			{
				var chore = context.Chores.Single();
				ILogEntryService service = new LogEntryService(unitOfWork.RepositoryAsync<LogEntry>());
				var controller = new LogEntriesController(unitOfWork, service);
					
				controller.SetControllerContext(HttpMethod.Post, "http://localhost/RowanAdams/api/logentries");
				var result = await controller.Post(new LogEntry { ChoreId = chore.Id, CompletedDate = new DateTime(2015, 1, 1)});
				var response = await result.ExecuteAsync(new CancellationToken());

				Assert.AreEqual(1, context.LogEntries.Count());
				var logEntry = context.LogEntries.Single();
				Assert.AreNotEqual(Guid.Empty, logEntry.Id);
				Assert.AreEqual(chore.Id, logEntry.ChoreId);
				Assert.AreEqual(new DateTime(2015, 1, 1), logEntry.CompletedDate);
				Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
				Assert.AreEqual($"/api/logentries/{logEntry.Id}", response.Headers.Location.AbsolutePath);
			}
		}
开发者ID:ItWorksOnMyMachine,项目名称:RowanPAdams,代码行数:22,代码来源:LogEntriesControllerTests.cs

示例8: SessionData

    internal SessionData(User loggingUser)
    {
      IRepositoryProvider repositoryProvider = new RepositoryProvider(new RepositoryFactories());
  
      UserId = loggingUser.PersonId;
      Username = loggingUser.UserName;

      var unitofWork = new UnitOfWork(new MisukaDBContext(), repositoryProvider);
      var personInfo = unitofWork.RepositoryAsync<Person>()
         .Query(m => m.PersonId == loggingUser.PersonId)
         .Select()
         .FirstOrDefault();

      if (personInfo != null)
      {
        FirstName = personInfo.FullName;
        Email = personInfo.Email;
        ImageUrl = personInfo.ImageUrl;
        ImageCoverUrl = personInfo.ImageCoverUrl;
      }

      IsAuthenticated = true;
      Saved = false;
    }
开发者ID:johnpipo1712,项目名称:Misuka,代码行数:24,代码来源:SessionData.cs

示例9: TestApiController

 public TestApiController()
 {
     _unitOfWork = new UnitOfWork(new ApplicationDbContext());
     _menuForWeekService = new MenuForWeekService(_unitOfWork.RepositoryAsync<MenuForWeek>());
 }
开发者ID:densem-2013,项目名称:ACSDining,代码行数:5,代码来源:TestApiController.cs

示例10: GetAllGetsActiveAndInactiveChores

		public async Task GetAllGetsActiveAndInactiveChores()
		{
			using (var dbInfo = Utility.CreateSeededTestDatabase())
			using (var context = new EntitiesContext(dbInfo.ConnectionString))
			using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context))
			{
				IChoreService service = new ChoreService(unitOfWork.RepositoryAsync<Chore>());
				ChoresController controller = new ChoresController(unitOfWork, service, new FakeTimeService(new DateTime(2015, 11, 1)));
					
				controller.SetControllerContext(HttpMethod.Post, "http://localhost/RowanAdams/api/chores");
				await controller.Post(new Chore { Name = "Test Chore 1", Value = 1 });
				await controller.Post(new Chore { Name = "Test Chore 2", Value = 2 });
				await controller.Post(new Chore { Name = "Test Chore 3", Value = 3 });
				await controller.Post(new Chore { Name = "Test Chore 4", Value = 4 });

				var chore = context.Chores.First();
				chore.Active = false;

				controller.SetControllerContext(HttpMethod.Put, "http://localhost/RowanAdams/api/chores");
				await controller.Put(chore);

				controller.SetControllerContext(HttpMethod.Get, "http://localhost/RowanAdams/api/chores/all");
				var chores = await controller.GetAll();

				Assert.AreEqual(4, chores.Count());
			}
		}
开发者ID:ItWorksOnMyMachine,项目名称:RowanPAdams,代码行数:27,代码来源:ChoresControllerTests.cs

示例11: CreateUser


//.........这里部分代码省略.........
        }
        else
        {
          status = MembershipCreateStatus.InvalidProviderUserKey;
          return null;
        }
      }
      catch
      {
        status = MembershipCreateStatus.InvalidProviderUserKey;
        return null;
      }

      #endregion

      #region Test for valid email
      //if ((RequiresUniqueEmail || EnablePasswordRetrieval || EnablePasswordReset) && !password.Equals(SOCIAL_LOGIN_DEFAULT_PASSWORD))
      //{

      //  if (email == null || EmailUtilities.ValidateEmailAddress(email) == false)
      //  {
      //    status = MembershipCreateStatus.InvalidEmail;
      //    return null;
      //  }
      //}
      #endregion

      #region Test for valid password


      if (!SecurityUtility.IsPasswordValid(password))
      {
        status = MembershipCreateStatus.InvalidPassword;
        return null;
      }


      #endregion

      IRepositoryProvider _repositoryProvider = new RepositoryProvider(new RepositoryFactories());
      var unitofWork = new UnitOfWork(new MisukaDBContext(), _repositoryProvider);

      #region Check for unique username
      Domain.Entity.User user = unitofWork.Repository<User>().Query(u => String.Compare(u.UserName, username, StringComparison.InvariantCultureIgnoreCase) == 0).Select().FirstOrDefault();
      if (user != null)
      {
        status = MembershipCreateStatus.DuplicateUserName;
        return null;
      }
      #endregion

      #region Test for valid question/answer
      if (RequiresQuestionAndAnswer)
      {
        if (passwordQuestion == null || passwordQuestion.Length > 200 || passwordQuestion.Length < 1)
        {
          status = MembershipCreateStatus.InvalidQuestion;
          return null;
        }

        if (passwordAnswer == null || passwordAnswer.Length > 200 || passwordAnswer.Length < 1)
        {
          status = MembershipCreateStatus.InvalidAnswer;
          return null;
        }
      }

      #endregion

      DateTime dt = DateTime.Now;
      user = new User
      {
        UserName = _username,
        CreationDate = dt,
        Domain = _domain,
        PersonId = personId,
        Locked = locked,
        FailedLoginTimes = 0,
        CurrentLanguage = System.Threading.Thread.CurrentThread.CurrentCulture.ToString()
      };


      user.Password = Cryptography.EncryptPassword(password, user.Salt);
      try
      {
        unitofWork.RepositoryAsync<Domain.Entity.User>().Insert(user);
        unitofWork.SaveChanges();
      }
      catch
      {
        status = MembershipCreateStatus.UserRejected;
        //  Log.Debug(this, string.Format("Create new user: {0} - failed", identity.Username));
        return null;
      }

      status = MembershipCreateStatus.Success;
      //Log.Debug(this, string.Format("Create new user: {0} - successfully", identity.Username));
      return new MembershipUser(_providerName, username, providerUserKey, email, passwordQuestion, "", isApproved, false, dt, dt, dt, dt, DateTime.MinValue);

    }
开发者ID:johnpipo1712,项目名称:Misuka,代码行数:101,代码来源:CustomMembershipProvider.cs

示例12: GetExcelTest

 public GetExcelTest()
 {
     _unitOfWork = new UnitOfWork(new ApplicationDbContext());
     _menuForWeekService = new MenuForWeekService(_unitOfWork.RepositoryAsync<MenuForWeek>());
 }
开发者ID:densem-2013,项目名称:ACSDining,代码行数:5,代码来源:GetExcelTest.cs

示例13: UpdateUserInformation

 public void UpdateUserInformation(User loggingUser)
 {
   IRepositoryProvider repositoryProvider = new RepositoryProvider(new RepositoryFactories());
   var unitofWork = new UnitOfWork(new MisukaDBContext(), repositoryProvider);
   unitofWork.RepositoryAsync<User>().Update(loggingUser);
   unitofWork.SaveChanges();
 }
开发者ID:johnpipo1712,项目名称:Misuka,代码行数:7,代码来源:SecurityUtility.cs

示例14: GetUserWithDomain

    private User GetUserWithDomain(string username, string domain)
    {
      IRepositoryProvider repositoryProvider = new RepositoryProvider(new RepositoryFactories());
      var unitofWork = new UnitOfWork(new MisukaDBContext(), repositoryProvider);
      var user = unitofWork.RepositoryAsync<User>()
         .Query(
                  m => string.Compare(m.UserName, username, StringComparison.InvariantCultureIgnoreCase) == 0 &&
                  string.Compare(m.Domain, domain, StringComparison.InvariantCultureIgnoreCase) == 0
           )
         .Select()
         .FirstOrDefault();

      return user;
    }
开发者ID:johnpipo1712,项目名称:Misuka,代码行数:14,代码来源:SecurityUtility.cs

示例15: EnsureGetLogEntryGetsLogEntry

		public async Task EnsureGetLogEntryGetsLogEntry()
		{
			using (var context = new EntitiesContext(dbInfo.ConnectionString))
			using (IUnitOfWorkAsync unitOfWork = new UnitOfWork(context))
			{
				var chore = context.Chores.Single();
				ILogEntryService service = new LogEntryService(unitOfWork.RepositoryAsync<LogEntry>());
				var controller = new LogEntriesController(unitOfWork, service);

				controller.SetControllerContext(HttpMethod.Post, "http://localhost/RowanAdams/api/logentries");
				var result = await controller.Post(new LogEntry { ChoreId = chore.Id, CompletedDate = new DateTime(2015, 1, 1) });
				var logEntry = context.LogEntries.Single();

				controller.SetControllerContext(HttpMethod.Get, $"http://localhost/RowanAdams/api/logentries/{logEntry.Id}");
				var logEntry2 = await controller.GetLogEntry(logEntry.Id);

				Assert.AreEqual(logEntry.Id, logEntry2.Id);
			}
		}
开发者ID:ItWorksOnMyMachine,项目名称:RowanPAdams,代码行数:19,代码来源:LogEntriesControllerTests.cs


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