本文整理汇总了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>());
}
示例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>());
}
示例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);
}
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例9: TestApiController
public TestApiController()
{
_unitOfWork = new UnitOfWork(new ApplicationDbContext());
_menuForWeekService = new MenuForWeekService(_unitOfWork.RepositoryAsync<MenuForWeek>());
}
示例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());
}
}
示例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);
}
示例12: GetExcelTest
public GetExcelTest()
{
_unitOfWork = new UnitOfWork(new ApplicationDbContext());
_menuForWeekService = new MenuForWeekService(_unitOfWork.RepositoryAsync<MenuForWeek>());
}
示例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();
}
示例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;
}
示例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);
}
}