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


C# IProjectRepository.GetForUser方法代码示例

本文整理汇总了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;
//.........这里部分代码省略.........
开发者ID:AcklenAvenue,项目名称:Pepino,代码行数:101,代码来源:ProjectModule.cs


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