/// <summary> /// 新規プロジェクト作成ダイアログを開く /// </summary> void RaiseNewProjectCommand() { var notification = new NewProjectNotification { Title = "New Project" }; notification.ProjectName = this.ProjectName.Value; notification.BaseFolderPath = this.BaseFolderPath.Value; notification.ProjectComment = this.ProjectComment.Value; NewProjectRequest.Raise(notification); if (notification.Confirmed) { this.ProjectName.Value = notification.ProjectName; this.BaseFolderPath.Value = notification.BaseFolderPath; this.ProjectComment.Value = notification.ProjectComment; if (Directory.Exists(this.ProjectFolderPath.Value)) { OpenMessageBox(this.Title.Value, MessageBoxImage.Error, MessageBoxButton.OK, MessageBoxResult.OK, this.ProjectFolderPath.Value + "は既に存在しています。新しい名前を指定してください。"); } else { Directory.CreateDirectory(this.ProjectFolderPath.Value); // コメントを出力 using (var fs = new FileStream(Path.Combine(this.ProjectFolderPath.Value, "Comment.txt"), FileMode.CreateNew)) { using (var sw = new StreamWriter(fs)) { sw.WriteLine(this.ProjectComment.Value); } } FileTree.Clear(); FileTree.Add(new FileTreeItem(this.ProjectFolderPath.Value)); } } }
protected UserProject ConvertProject(NewProjectRequest request) { return(new UserProject() { Id = request.Id, Title = request.Title }); }
/// <summary> /// Initializes the project. /// </summary> /// <param name="projectName">Name of the project.</param> /// <param name="start">The start.</param> /// <param name="end">The end.</param> public void InitializeProject(string projectName, Position start, Position end) { var ub = new UriBuilder(Settings.ServerUrl) { Path = $"api/project" }; var request = new NewProjectRequest(projectName, start.ToString(), end.ToString()); HttpFacade.PostJsonAsync(ub.Uri, request, null).GetAwaiter().GetResult(); }
public async Task <IActionResult> PostWithUserName([FromBody] NewProjectRequest request, string username) { var project = ConvertProject(request); var targetUser = await _context.Users.FirstOrDefaultAsync(x => x.Username == username); _context.Update(targetUser); targetUser.Projects.Add(project); await _context.SaveChangesAsync(); var projectResponse = ConvertToProjectResponse(project); return(Created(Url.RouteUrl(projectResponse.Id), projectResponse)); }
public void Create_Project_From_Request() { // arrange var builder = new ProjectAccessBuilder(); var controller = new ProjectController(); controller.ProjectsAccess = builder.Build(); var request = new NewProjectRequest("testing", "0:0", "1:1"); // act var actionResult = controller.Post(request); // assert builder.Mock.Verify(access => access.CreateProject("testing", new Position(0, 0), new Position(1, 1)), Times.Once); }
public void Initialize_Projects() { // arrange var httpBuilder = new HttpFacadeBuilder(); httpBuilder.WithPostAsync(new HttpResponseMessage(HttpStatusCode.OK)); var settings = new Settings { ServerUrl = "https://some.server.net", ProjectName = "testing" }; var serverClient = new ServerClient { HttpFacade = httpBuilder.Build(), Settings = settings }; var expected = new NewProjectRequest("testing", "35:0", "1000:0"); // act serverClient.InitializeProject("testing", new Position(0x35, 0), new Position(0x1000, 0)); // assert httpBuilder.Mock.Verify( f => f.PostJsonAsync(new Uri("https://some.server.net/api/project"), expected, null), Times.Once); }
/// <summary> /// Raise new project request /// </summary> private void NewProject() { NewProjectRequest.Raise(new Notification { Title = Strings.WizardCreateNewProject }); }
public IHttpActionResult Post([FromBody] NewProjectRequest request) { ProjectsAccess.CreateProject(request.ProjectName, Position.Parse(request.StartingPosition), Position.Parse(request.EndingPosition)); return(Ok()); }