本文整理汇总了C#中IUowData类的典型用法代码示例。如果您正苦于以下问题:C# IUowData类的具体用法?C# IUowData怎么用?C# IUowData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IUowData类属于命名空间,在下文中一共展示了IUowData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ToAccountViewModel
public static AccountViewModel ToAccountViewModel(this ApplicationUser user, IUowData context)
{
return new AccountViewModel(context)
{
Id = user.Id,
PhoneNumber = user.PhoneNumber,
Email= user.Email,
UserInRole = user.Roles,
UserName = user.UserName
};
}
开发者ID:NikolayKostadinov,项目名称:Homeworks,代码行数:11,代码来源:ApplicationUserExtentions.cs
示例2: GetTweetFromViewModel
protected Tweet GetTweetFromViewModel(TweetsViewModel tweet, string username, IUowData db)
{
// Security risk...
var tweetUser = db.Users.All().ToList().Find(x => x.UserName == username);
Tweet result = new Tweet()
{
Id = tweet.Id,
Content = tweet.Content,
Title = tweet.Title,
User = tweetUser
};
return result;
}
开发者ID:hristo-iliev,项目名称:TelerikHW,代码行数:14,代码来源:BaseController.cs
示例3: UserAdministrationControllerTests
/// <summary>
/// Initializes a new instance of the <see cref="UserAdministrationControllerTests" /> class.
/// </summary>
public UserAdministrationControllerTests()
{
this.roles = new List<RoleIntPk>()
{
new RoleIntPk(){ Id = 1, Name="Administrator" },
new RoleIntPk(){ Id = 2, Name="User" },
new RoleIntPk(){ Id = 3, Name="Uploader" },
};
this.users = new List<ApplicationUser>()
{
new ApplicationUser(){ Id = 1, Email="[email protected]", UserName = "user1"},
new ApplicationUser(){ Id = 2, Email="[email protected]", UserName = "user2"},
new ApplicationUser(){ Id = 3, Email="[email protected]", UserName = "user3"},
};
foreach (var user in this.users)
{
user.Roles.Add(new UserRoleIntPk() { UserId = user.Id, RoleId = 1 });
user.Roles.Add(new UserRoleIntPk() { UserId = user.Id, RoleId = 2 });
user.Roles.Add(new UserRoleIntPk() { UserId = user.Id, RoleId = 3 });
}
//Create Mock repositories
Mock<IRepository<RoleIntPk, int>> mockRolesRepository = new Mock<IRepository<RoleIntPk, int>>();
mockRolesRepository.Setup(r => r.All()).Returns(this.roles.AsQueryable());
mockRolesRepository.Setup(u => u.GetById(It.IsAny<int>())).Returns((int x) => { return this.roles[x - 1]; });
this.rolesRepository = mockRolesRepository.Object;
Mock<IRepository<ApplicationUser, int>> mockUsersRepository = new Mock<IRepository<ApplicationUser, int>>();
mockUsersRepository.Setup(u => u.All()).Returns(this.users.AsQueryable());
mockUsersRepository.Setup(u => u.GetById(It.IsAny<int>())).Returns((int x) => { return this.users[x - 1]; });
mockUsersRepository.Setup(u => u.Delete(It.IsAny<ApplicationUser>())).Callback((ApplicationUser x) => { this.users.RemoveAt(0); });
mockUsersRepository.Setup(u => u.Update(It.Is<ApplicationUser>(
au => !au.Email.Contains("@")
))).Throws(new ArgumentException("Email"));
this.usersRepository = mockUsersRepository.Object;
Mock<IUowData> mockUow = new Mock<IUowData>();
mockUow.Setup(p => p.Roles).Returns(this.rolesRepository);
mockUow.Setup(p => p.Users).Returns(this.usersRepository);
this.uowData = mockUow.Object;
var mockControllerContext = new Mock<ControllerContext>();
mockControllerContext.Setup(x => x.HttpContext).Returns(GetMockedHttpContext());
//mockControllerContext.Setup(x=>x.HttpContext.User).Returns(new GenericPrincipal(new GenericIdentity("Test"),new string[]{"test"}));
//mockControllerContext.Setup(x => x.HttpContext.GetOwinContext);
this.controllerContext = mockControllerContext.Object;
}
开发者ID:NikolayKostadinov,项目名称:Homeworks,代码行数:52,代码来源:UserAdministrationControllerTests.cs
示例4: FileUploadControllerTests
public FileUploadControllerTests()
{
this.files = new List<FileDescription>()
{
new FileDescription(){ Id = 1, FileName="File1", Size = 1, UserId = 1, ApplicationUser = new ApplicationUser(){ UserName = "test1"}},
new FileDescription(){ Id = 2, FileName="File2", Size = 1, UserId = 2, ApplicationUser = new ApplicationUser(){ UserName = "test2"}},
new FileDescription(){ Id = 3, FileName="File3", Size = 1, UserId = 1, ApplicationUser = new ApplicationUser(){ UserName = "test1"}},
};
this.uploadResults = new List<UploadResult>();
int id = 1;
foreach (var file in this.files)
{
this.uploadResults.Add(new UploadResult(){ Id=id++, FileId = file.Id, File = file, Message="UploadDescription1", RowNumber=1, Status=Status.Ok});
this.uploadResults.Add(new UploadResult(){ Id=id++, FileId = file.Id, File = file, Message="UploadDescription2", RowNumber=2, Status=Status.Warning});
this.uploadResults.Add(new UploadResult(){ Id=id++, FileId = file.Id, File = file, Message="UploadDescription3", RowNumber=3, Status=Status.Error});
}
foreach (var ur in this.uploadResults)
{
this.files[ur.FileId-1].UploadResults.Add(ur);
}
//Create Mock repositories
Mock<IRepository<FileDescription, int>> mockFileDescriptionRepository = new Mock<IRepository<FileDescription, int>>();
mockFileDescriptionRepository.Setup(r => r.All()).Returns(this.files.AsQueryable());
mockFileDescriptionRepository.Setup(r => r.GetById(It.IsAny<int>())).Returns((int x) => (this.files[x - 1]));
Mock<IRepository<UploadResult,int>> mockUploadResultRepository = new Mock<IRepository<UploadResult,int>>();
mockUploadResultRepository.Setup(r => r.All()).Returns(this.uploadResults.AsQueryable());
//initializing repositories
this.fileRepository = mockFileDescriptionRepository.Object;
this.uploadResultsRepository = mockUploadResultRepository.Object;
//Create UowData
Mock<IUowData> mockUow = new Mock<IUowData>();
mockUow.Setup(uow => uow.FileDescriptions).Returns(this.fileRepository);
mockUow.Setup(uow => uow.UploadResults).Returns(this.uploadResultsRepository);
this.uowData = mockUow.Object;
}
开发者ID:NikolayKostadinov,项目名称:Homeworks,代码行数:41,代码来源:FileUploadControllerTests.cs
示例5: HomeController
public HomeController(IUowData data)
: base(data)
{
}
开发者ID:NikitoG,项目名称:TelerikAcademyHomeworks,代码行数:4,代码来源:HomeController.cs
示例6: DevicesController
public DevicesController(IUowData data, IRemoteControl remoteControl)
: base(data, remoteControl)
{
}
开发者ID:ktrajkov,项目名称:SmartHome,代码行数:4,代码来源:DevicesController.cs
示例7: CommentController
public CommentController(IUowData data)
: base(data)
{
}
开发者ID:ben12345,项目名称:Movie-Room,代码行数:4,代码来源:CommentController.cs
示例8: BaseController
public BaseController(IUowData db)
{
this.db = db;
}
开发者ID:niki-funky,项目名称:Telerik_Academy,代码行数:4,代码来源:BaseController.cs
示例9: CuisinesController
public CuisinesController(IUowData db)
: base(db)
{
this.db = db;
}
开发者ID:nikolaZ,项目名称:AreYouHungry,代码行数:5,代码来源:CuisinesController.cs
示例10: NewsService
public NewsService(IUowData data) : base(data)
{
}
开发者ID:bonchovylkov,项目名称:Sport-Classifier,代码行数:4,代码来源:NewsService.cs
示例11: RoomsController
public RoomsController(IUowData data, IRemoteControl remoteControl)
: base(data, remoteControl)
{
}
开发者ID:ktrajkov,项目名称:SmartHome,代码行数:4,代码来源:RoomsController.cs
示例12: FileUpploadController
public FileUpploadController(IUowData db)
{
this.db = db;
}
开发者ID:NikolayKostadinov,项目名称:Homeworks,代码行数:4,代码来源:FileUpploadController.cs
示例13: QuestionsController
public QuestionsController(IUowData data)
: base(data)
{
}
开发者ID:TeamLich,项目名称:TellToAsk,代码行数:4,代码来源:QuestionsController.cs
示例14: TweetsController
public TweetsController(IUowData data)
: base(data)
{
}
开发者ID:quela,项目名称:myprojects,代码行数:4,代码来源:TweetsController.cs
示例15: HouseSettingsController
public HouseSettingsController(IUowData data, IRemoteControl remoteControl)
: base(data, remoteControl)
{
}
开发者ID:ktrajkov,项目名称:SmartHome,代码行数:4,代码来源:HouseSettingsController.cs
示例16: BaseController
public BaseController(IUowData data)
{
this.Data = data;
}
开发者ID:didimitrov,项目名称:Cars,代码行数:4,代码来源:BaseController.cs
示例17: KeyTypeKeyValueService
public KeyTypeKeyValueService(IUowData data) : base(data)
{
}
开发者ID:bonchovylkov,项目名称:Sport-Classifier,代码行数:4,代码来源:KeyTypeKeyValueService.cs
示例18: TagsController
public TagsController(IUowData data)
: base(data)
{
}
开发者ID:vphilipov,项目名称:TelerikAcademy,代码行数:4,代码来源:TagsController.cs
示例19: CategoryController
public CategoryController(IUowData data)
: base(data)
{
}
开发者ID:ben12345,项目名称:Movie-Room,代码行数:4,代码来源:CategoryController.cs
示例20: CataloguesController
//private string nameOfTheSearch = "";
public CataloguesController(IUowData data)
: base(data)
{
}
开发者ID:CyclopsTeam,项目名称:TheTorrentSystem,代码行数:5,代码来源:CataloguesController.cs
注:本文中的IUowData类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论