本文整理汇总了C#中IProjectRepository.GetForUser方法的典型用法代码示例。如果您正苦于以下问题:C# IProjectRepository.GetForUser方法的具体用法?C# IProjectRepository.GetForUser怎么用?C# IProjectRepository.GetForUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProjectRepository
的用法示例。
在下文中一共展示了IProjectRepository.GetForUser方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProjectModule
public ProjectModule(IDispatcherFactory dispatcherFactory,
IProjectRepository projectRepository, IMappingEngine mappingEngine)
{
Post["/projects/{id}/run"] =
p =>
{
Guid id = Guid.Parse((string) p.id);
var command = new QueueProject(id);
dispatcherFactory.Create(this.UserLoginSession(), command)
.Dispatch(this.UserLoginSession(), command);
return null;
};
Get["/projects"] =
_ =>
{
User user = this.UserLoginSession().User;
IEnumerable<Project> projects = projectRepository.GetForUser(user);
IEnumerable<ProjectListingResponse> projectListingResponses =
mappingEngine.Map<IEnumerable<Project>, IEnumerable<ProjectListingResponse>>(projects);
return new ProjectListResponse(projectListingResponses);
};
Get["/projects/{projectId}"] =
p =>
{
Guid projectId = Guid.Parse((string) p.projectId);
Guid userId = this.UserLoginSession().User.Id;
Project project = projectRepository.GetById(projectId);
ProjectDetailsResponse response = mappingEngine.Map<Project, ProjectDetailsResponse>(project);
if (response == null) throw new ItemNotFoundException<Project>(projectId);
return response;
};
Get["/projects/{id}/backup"] =
p =>
{
throw new NotImplementedException();
//Guid id = Guid.Parse((string) p.id);
//Project project = projectRepository.GetById(id);
//if (project.Collaborators.All(x => x.UserId != this.UserLoginSession().User.Id))
//{
// throw new UnauthorizedAccessException("That's not your project!");
//}
//if (project == null) throw new ItemNotFoundException<Project>(id);
//var projectBackupResponse = new ProjectBackupResponse
// {
// Name = project.Name,
// Id = project.Id,
// History = GetFilteredEventd(project)
// };
//return projectBackupResponse;
};
Post["/projects/restore"] =
p =>
{
throw new NotImplementedException();
//string body = Request.Body.AsString();
//var projectBackupResponse = JsonConvert.DeserializeObject<ProjectBackupResponse>(body,
// new JsonSerializerSettings {TypeNameHandling = TypeNameHandling.Objects});
//var command = new RestoreProject(projectBackupResponse.History);
//dispatcherFactory.Create(this.UserLoginSession(), command)
// .Dispatch(this.UserLoginSession(), command);
//return null;
};
Post["/projects"] =
_ =>
{
var projectData = this.Bind<NewProjectRequest>();
var command = new CreateNewProject(Guid.NewGuid(), projectData.Name);
dispatcherFactory.Create(this.UserLoginSession(), command)
.Dispatch(this.UserLoginSession(), command);
return null;
};
Put["/projects/{projectId}"] =
p =>
{
Guid projectId = Guid.Parse((string) p.projectId);
var projectData = this.Bind<ChangeNameRequest>();
var command = new ChangeProjectName(projectId, projectData.Name);
dispatcherFactory.Create(this.UserLoginSession(), command)
.Dispatch(this.UserLoginSession(), command);
return null;
};
Delete["/projects/{id}"] =
p =>
{
Guid projectId = Guid.Parse((string) p.id);
var command = new DeleteProject(projectId);
dispatcherFactory.Create(this.UserLoginSession(), command)
.Dispatch(this.UserLoginSession(), command);
return null;
//.........这里部分代码省略.........