public bool Run(ProjectInSolution project, UpdateProjectOptions options) { var res = new SyncFolderNameTask().Run(project, options) | new SyncProjectNameTask().Run(project, options); return(res); }
public bool UpdateProject(int id, UpdateProjectOptions options) { if (id < 0) { return(false); } if (options == null) { return(false); } var updproject = getProjectById(id); if (updproject == null) { return(false); } if (updproject.Description != null) { updproject.Description = options.Description; } if (updproject.Title != null) { updproject.Title = options.Title; } context.Update(updproject); return(true); }
public bool Run(ProjectInSolution project, UpdateProjectOptions options) { bool updated; if (!string.IsNullOrEmpty(options.ReplaceNameFrom) && !string.IsNullOrEmpty(options.ReplaceNameTo)) { project.ProjectName = project.ProjectName.ReplaceSmartIgnoreCase(options.ReplaceNameFrom, options.ReplaceNameTo); var oldRelativeDir = project.Folder.GetRelativePath(Path.GetDirectoryName(options.SolutionFullPath)); updated = UpdateProject(oldRelativeDir, project.Folder, project, options.Preview, keepCsProjFileName: false); } else { string projectNewFolder = Path.Combine(Path.GetDirectoryName(project.Folder) ?? "", project.ProjectName); var newRelativeDir = projectNewFolder.GetRelativePath(Path.GetDirectoryName(options.SolutionFullPath)); updated = UpdateProject(newRelativeDir, projectNewFolder, project, options.Preview, keepCsProjFileName: false); } if (!updated) { return(false); } SolutionFile slnFile = SolutionFile.Parse(options.SolutionFullPath); UpdateSolutionFile(project, slnFile, options.Preview); return(true); }
public Project UpdateProject( int projectId, UpdateProjectOptions projectOptions) { if (projectOptions == null) { return(null); } var project = GetProjectById(projectId); if (project == null) { return(null); } if (!string.IsNullOrWhiteSpace(projectOptions.Description)) { project.Description = projectOptions.Description; } if (!string.IsNullOrWhiteSpace(projectOptions.Title)) { project.Title = projectOptions.Title; } //if (options.StatusProject.HasValue) //{ // project.StatusProject.Equals(options.StatusProject); //} must be a function in case a project budget is accomplished context_.SaveChanges(); return(project); }
public Project UpdateProject( int projectId, UpdateProjectOptions projectOptions) { if (projectOptions == null) { return(null); } var project = GetProjectById(projectId); if (project == null) { return(null); } if (!string.IsNullOrWhiteSpace(projectOptions.Description)) { project.Description = projectOptions.Description; } if (!string.IsNullOrWhiteSpace(projectOptions.Title)) { project.Title = projectOptions.Title; } context_.SaveChanges(); return(project); }
public Result <bool> UpdateProject(int projectId, UpdateProjectOptions options) { if (options == null) { return(Result <bool> .CreateFailed(StatusCode.BadRequest, "Null options")); } var project = GetProjectById(projectId).Data; if (project == null) { return(Result <bool> .CreateFailed(StatusCode.NotFound, $"Project with ID {projectId} was not found")); } if (project.IsValidTitle(options.Title)) { project.Title = options.Title; } //else { // return Result<bool>.UpdateFailed(StatusCode.BadRequest, "The Tittle is not valid"); } if (options.Category == null) { return(Result <bool> .CreateFailed(StatusCode.BadRequest, "Category not valid")); } var cat = (ProjectCategory)Enum.Parse(typeof(ProjectCategory), options.Category, true); if (project.IsValidCategory(cat)) { project.Category = cat; } if (project.IsValidDeadline(options.Deadline)) { project.Deadline = options.Deadline; } if (project.IsValidDescription(options.Description)) { project.Description = options.Description; } if (project.IsValidTotalFund(options.TotalFund)) { project.TotalFund = options.TotalFund; } if (context_.SaveChanges() == 0) { return(Result <bool> .CreateFailed(StatusCode.InternalServerError, "Project could not be updated")); } return(Result <bool> .CreateSuccessful(true)); }
public bool Run(IProject project, UpdateProjectOptions options) { return (new SyncXmlSingleNodeHelper() .AddOrUpdate( project.AbsolutePath, "AssemblyName", project.ProjectName, options.Preview)); }
public bool Run(IProject project, UpdateProjectOptions options) { return (new SyncXmlSingleNodeHelper() .AddOrUpdate( project.AbsolutePath, "RootNamespace", project.ProjectName.Replace("-", "_"), options.Preview)); }
public IActionResult UpdateProject(string projectid, [FromBody] UpdateProjectOptions options) { var projectid_ = int.Parse(projectid); var project = projectService_.UpdateProject(projectid_, options); if (project.Success) { return(Json(project.Data)); } return(StatusCode((int)project.ErrorCode, project.ErrorText)); }
public IActionResult UpdateProject([FromBody] UpdateProjectOptions updateProjectOptions) { var result = _projectservices.UpdateProject(updateProjectOptions); if (!result.Success) { return(StatusCode((int)result.ErrorCode, result.ErrorText)); } return(Json(result.Data)); }
public IActionResult Update(int id, [FromBody] UpdateProjectOptions options) { var result = projectService.UpdateProject(options, id); if (!result.Success) { return(StatusCode((int)result.ErrorCode, result.ErrorText)); } return(Ok()); }
public bool Run(bool preview) { Log.Information($"Task: {_taskCreator.Description}"); UpdateProjectOptions options = _project.Options; ProjectFinder projectFinder = new ProjectFinder(); ProjectUpdater projectUpdater = new ProjectUpdater(); bool atLeastOneUpdated = false; _onUpdate(); if (options.SolutionFullPath.IsNotEmpty()) { var projects = projectFinder .FindInTheSolution( solutionDirectory: Path.GetDirectoryName(options.SolutionFullPath), fileName: Path.GetFileName(options.SolutionFullPath)) .ToArray(); _onUpdate(); projectUpdater.Run( projects, project => { var task = _taskCreator.Create <ProjectInSolution>(); atLeastOneUpdated |= task.Run(project, (UpdateProjectOptions)options.WithPreview(preview)); _onUpdate(); }); } else { var projects = projectFinder .FindWithMask( workingDirectory: options.WorkingDirectory, options.CsProjFileMasks) .ToArray(); _onUpdate(); projectUpdater.Run( projects, project => { var task = _taskCreator.Create <ProjectInFileSystem>(); atLeastOneUpdated |= task.Run(project, (UpdateProjectOptions)options.WithPreview(preview)); _onUpdate(); }); } if (!atLeastOneUpdated) { Log.Information("\tTask completed. No changes."); } return(atLeastOneUpdated); }
public bool Update( UpdateProjectOptions options) { if (options == null) { return(false); } var project = Search( new SearchProjectOptions() { ProjectId = options.ProjectId }).SingleOrDefault(); if (!string.IsNullOrWhiteSpace(options.Title)) { project.Title = options.Title; } if (!string.IsNullOrWhiteSpace(options.Description)) { project.Description = options.Description; } project.DateCreated = DateTime.Now; //if (options.Photos != null) { // project.Photos = options.Photos; //} //if (options.Videos != null) //{ // project.Videos = options.Videos; //} if (options.Status != null) { project.Status = options.Status; } if (options.FundingPackages != null) { project.FundingPackages = options.FundingPackages; } if (options.TargetFund != null) { project.TargetFund = options.TargetFund.Value; } if (context_.SaveChanges() > 0) { return(true); } return(false); }
private static bool UpdateFolderName(string currentFolder, string newFolder, UpdateProjectOptions options) { if (currentFolder.Equals(newFolder, StringComparison.InvariantCultureIgnoreCase)) { return(false); } Log.Verbose($"Renaming folder '{currentFolder}' to '{newFolder}'"); if (!options.Preview) { Directory.Move(currentFolder, newFolder); } Log.Verbose("Renamed."); return(true); }
public bool Run(IProject project, UpdateProjectOptions options) { if (AreNamesSynced(project.ProjectName, project.Folder)) { Log.Verbose($"Skipped because of its name equality with the folder {project.Folder}"); return(false); } if (project.Folder.NormalizePath().Equals(options.WorkingDirectory, StringComparison.InvariantCultureIgnoreCase)) { Log.Verbose("Skipped because the project is placed in the same folder as its solution."); return(false); } string projectNewFolder = Path.Combine(Path.GetDirectoryName(project.Folder) ?? "", project.ProjectName); return(UpdateFolderName(project.Folder, projectNewFolder, options)); }
public IActionResult UpdateProject([FromBody] UpdateProjectFormOptions options) { var editProjectOptions = new UpdateProjectOptions() { ProjectId = options.ProjectId, Title = options.Title, Description = options.Description, MainImageUrl = options.MainImageUrl, DueTo = options.DueTo, Goal = options.Goal, CategoryId = options.CategoryId }; var result = _projectService.UpdateProject (Globals.UserId, editProjectOptions.ProjectId, editProjectOptions); if (!result.Success) { return(StatusCode((int)result.ErrorCode, result.ErrorText)); } return(Ok()); }
public ApiResult <bool> UpdateProject(int?id, UpdateProjectOptions options) { if (options == null) { return(ApiResult <bool> .Failed(StatusCode.BadRequest, "Null options")); } if (id == null) { return(ApiResult <bool> .Failed(StatusCode.BadRequest, "The Project Id is empty")); } var updateProject = context_ .Set <Project>() .Where(p => p.ProjectId == id) .SingleOrDefault(); if (options.Title != null) { updateProject.Title = options.Title; } if (options.Description != null) { updateProject.Description = options.Description; } if (options.Photos != null) { updateProject.Photos = options.Photos; } if (options.Videos != null) { updateProject.Videos = options.Videos; } if (options.PostStatusUpdates != null) { updateProject.PostStatusUpdates = options.PostStatusUpdates; } if (options.TotalAmount > 0) { updateProject.ProjectCost = options.TotalAmount.Value; } if (options.Progress != 0) { updateProject.Progress = options.Progress; } if (options.FundingPackages != null) { updateProject.Packages = options.FundingPackages; } try { var rows = context_.SaveChanges(); if (rows <= 0) { return(ApiResult <bool> .Failed( StatusCode.InternalServerError, "Project could not be Updated")); } } catch (Exception ex) { return(ApiResult <bool> .Failed(StatusCode.InternalServerError, ex.ToString())); } return(ApiResult <bool> .Successful(true)); }
public Result <Project> UpdateProject( UpdateProjectOptions options) { var result = new Result <Project>(); if (options == null) { result.ErrorCode = StatusCode.BadRequest; result.ErrorText = "Null options"; return(result); } var project = context_ .Set <Project>() .Where(x => x.ProjectId == options.ProjectId) .Include(x => x.Photos) .Include(x => x.Videos) .SingleOrDefault(); if (project == null) { result.ErrorCode = StatusCode.NotFound; result.ErrorText = $"Project with id {options.ProjectId} was not found"; return(result); } if (options.Category != null && options.Category > 0 && (int)options.Category < 9) { project.Category = options.Category.Value; } if (!string.IsNullOrWhiteSpace(options.Description)) { project.Description = options.Description; } if (!string.IsNullOrWhiteSpace(options.Name)) { project.Name = options.Name; } if (options.AmountRequired != null) { project.AmountRequired = options.AmountRequired.Value; } if (options.DueTo != null && options.DueTo.CompareTo(DateTime.Today) > 0) { project.DueTo = options.DueTo; } if (options.Photos != null) { if (options.Photos.Count > 0 && !string.IsNullOrWhiteSpace(options.Photos[0])) { var p = new Photo() { Url = options.Photos[0], }; project.Photos.Add(p); } } if (options.Videos != null) { if (options.Videos.Count > 0 && !string.IsNullOrWhiteSpace(options.Videos[0])) { var v = new Video() { Url = options.Videos[0], }; project.Videos.Add(v); } } var rows = 0; try { rows = context_.SaveChanges(); } catch (Exception ex) { return(Result <Project> .ActionFailed( StatusCode.InternalServerError, ex.ToString())); } if (rows <= 0) { return(Result <Project> .ActionFailed( StatusCode.InternalServerError, "Project could not be updated")); } return(Result <Project> .ActionSuccessful(project)); }
//Edit Project public Result <Project> UpdateProject(UpdateProjectOptions options) { if (options == null) { return(Result <Project> .CreateFailed( StatusCode.BadRequest, "Null options")); } if (string.IsNullOrWhiteSpace(options.ProjectTitle)) { return(Result <Project> .CreateFailed( StatusCode.BadRequest, "Null or empty ProjectTitle")); } if (string.IsNullOrWhiteSpace(options.ProjectDescription)) { return(Result <Project> .CreateFailed( StatusCode.BadRequest, "Null or empty ProjectDescription")); } if (options.ProjectTargetAmount == 0) { return(Result <Project> .CreateFailed( StatusCode.BadRequest, "Null or empty ProjectTargetAmount")); } if (string.IsNullOrWhiteSpace(options.ProjectCategory)) { return(Result <Project> .CreateFailed( StatusCode.BadRequest, "Null or empty ProjectCategory")); } var project = _db.Set <Project>().Find(options.ProjectId); if (options.ProjectTitle != null) { project.ProjectTitle = options.ProjectTitle; } if (options.ProjectDescription != null) { project.ProjectDescription = options.ProjectDescription; } if (project.ProjectCategory != null) { project.ProjectCategory = options.ProjectCategory; } if (project.ProjectTargetAmount != 0) { project.ProjectTargetAmount = options.ProjectTargetAmount; } //if (options.ProjectEndingDate != null) project.ProjectEndingDate = options.ProjectEndingDate; project.IsActive = options.IsActive; project.IsComplete = options.IsComplete; project.ProjectProgress = project.ProjectCurrentAmount / project.ProjectTargetAmount; var rows = 0; try { rows = _db.SaveChanges(); } catch (Exception ex) { return(Result <Project> .CreateFailed( StatusCode.InternalServerError, ex.ToString())); } if (rows <= 0) { return(Result <Project> .CreateFailed( StatusCode.InternalServerError, "Project could not be updated")); } return(Result <Project> .CreateSuccessful(project)); }
public Result <bool> UpdateProject(int?userId, int?projectId, UpdateProjectOptions updateProjectOptions) { if (projectId == null || userId == null) { return(Result <bool> .Failed(StatusCode.BadRequest, "Options Not Valid")); } var project = GetSingleProject(projectId); if (!project.Success) { return(Result <bool> .Failed(project.ErrorCode, project.ErrorText)); } if (Helpers.UserOwnsProject(_context, userId, projectId) == false) { return(Result <bool> .Failed(StatusCode.BadRequest, "Can Not Access A Project You Don't Own")); } if (!string.IsNullOrWhiteSpace(updateProjectOptions.Description)) { project.Data.Description = updateProjectOptions.Description; } if (!string.IsNullOrWhiteSpace(updateProjectOptions.MainImageUrl)) { project.Data.MainImageUrl = updateProjectOptions.MainImageUrl; } if (!string.IsNullOrWhiteSpace(updateProjectOptions.Title)) { project.Data.Title = updateProjectOptions.Title; } if (!string.IsNullOrWhiteSpace(updateProjectOptions.MainImageUrl)) { project.Data.MainImageUrl = updateProjectOptions.MainImageUrl; } if (updateProjectOptions.DueTo != null && updateProjectOptions.DueTo > DateTime.Now) { project.Data.DueTo = updateProjectOptions.DueTo.Value; } if (updateProjectOptions.DueTo <= DateTime.Now) { return(Result <bool> .Failed(StatusCode.BadRequest, "Not Valid Date")); } if (updateProjectOptions.DueTo != null && updateProjectOptions.Goal > 0) { project.Data.Goal = updateProjectOptions.Goal; } if (updateProjectOptions.Goal <= 0) { return(Result <bool> .Failed(StatusCode.BadRequest, "Not Valid Goal")); } project.Data.Category = (Category)updateProjectOptions.CategoryId; var rows = 0; try { rows = _context.SaveChanges(); } catch (Exception ex) { return(Result <bool> .Failed(StatusCode.InternalServerError, ex.Message)); } return(rows <= 0 ? Result <bool> .Failed(StatusCode.BadRequest, "No Changes Applied") : Result <bool> .Succeed(true)); }
public Result <bool> UpdateProject(UpdateProjectOptions options, int id) { var result = new Result <bool>(); if (options == null) { result.ErrorCode = StatusCode.BadRequest; result.ErrorText = "Null options"; return(result); } var project = dbContext .Set <Project>() .Where(p => p.ProjectId == id) .Include(p => p.Packages) .Include(p => p.Media) .SingleOrDefault(); if (project == null) { result.ErrorCode = StatusCode.NotFound; result.ErrorText = $"Project with id {id} was not found"; return(result); } if (!string.IsNullOrWhiteSpace(options.Title)) { project.Title = options.Title; } if (!string.IsNullOrWhiteSpace(options.Description)) { project.Description = options.Description; } if (options.Category != null) { project.Category = options.Category.Value; } if (options.MediaUrls != null) { project.Media.Clear(); var optionsVideo = options.MediaUrls[3]; options.MediaUrls.RemoveAt(3); foreach (var url in options.MediaUrls) { if (!string.IsNullOrWhiteSpace(url)) { project.Media.Add(new ProjectMedia() { MediaUrl = url }); } } if (!string.IsNullOrWhiteSpace(optionsVideo)) { if (optionsVideo.Contains("youtube")) { project.Media.Add(new ProjectMedia() { MediaUrl = optionsVideo }); } else { result.ErrorCode = StatusCode.BadRequest; result.ErrorText = $"Not a video from youtube"; return(result); } } } if (dbContext.SaveChanges() > 0) { result.ErrorCode = StatusCode.OK; result.Data = true; return(result); } result.ErrorCode = StatusCode.InternalServerError; result.ErrorText = $"Project could not be updated"; return(result); }
public Project UpdateProject([FromRoute] int id, [FromBody] UpdateProjectOptions options) { return(_projectService.UpdateProject(id, options)); }