public async Task <Guid> CreateWithLink(ProjectInput Projects) { var @project = Project.CreateWithLink(Projects.Title, Projects.Type, Projects.LinkURL); await _projectRespository.InsertAsync(@project); return(project.Id); }
public void EditProject(ProjectInput input) { var project = _projectManager.GetProject(input.Id); var editedProject = input.MapTo(project); _projectManager.CreateProject(editedProject); }
public Task <ProjectResult> CreateProject(IOrganizationProjectManager pm, ProjectInput input) { input.ProjectManagerOrganizationId = pm.OrganizationId; input.ProjectManagerId = pm.OrganizationId; return(CreateProject(input)); }
public int CreateProject(ProjectInput input) { var project = Project.CreateProject(input.Name, input.Description, input.StartDate, input.EndDate, StatusTypes.Status.InProcess); var id = _projectManager.CreateProject(project, input.InitialBudget); return(id); }
private void Create(ProjectInput projectInput) { var projectEntity = ObjectMapper.Map <Project>(projectInput); SetAuditInsert(projectEntity); projectRepository.Insert(projectEntity); CurrentUnitOfWork.SaveChanges(); }
public async Task <IActionResult> Create(string organizationId) { var model = new ProjectInput { OrganizationId = organizationId, }; return(View(model)); }
public async Task <dynamic> CreateProject( [FromRoute] Guid organizationId, [FromBody] ProjectInput input ) { var output = await _projectService .CreateProject(_agencyOwner, input); return(Ok(output)); }
public void CreateOrEditProject(ProjectInput projectInput) { if (projectInput.Id == 0) { Create(projectInput); } else { Update(projectInput); } }
public async Task <(string result, bool isError)> CreateProjects(ProjectInput vm) { var result = await _client.CreateProject.ExecuteAsync(new CreateProjectVmInput { Title = vm.Title, Description = vm.Description }); if (result.IsErrorResult()) { return(string.Join('\n', result.Errors.Select(x => x.Message)), true); } return("", false); }
public async Task <dynamic> CreateProject( [FromRoute] Guid organizationId, [FromBody] ProjectInput input ) { var project = await _projectService .CreateProject( _accountManager, input); return(Ok(project)); }
private void Update(ProjectInput projectInput) { var projectEntity = projectRepository.GetAll().Where(x => !x.IsDelete).SingleOrDefault(x => x.Id == projectInput.Id); if (projectEntity == null) { } ObjectMapper.Map(projectInput, projectEntity); SetAuditEdit(projectEntity); projectRepository.Update(projectEntity); CurrentUnitOfWork.SaveChanges(); }
public async Task <IActionResult> Update(ProjectInput input) { if (!ModelState.IsValid) { return(View(input)); } var result = await _projectService.UpdateAsync(input); ValidateResult(result); return(View(input)); }
public void write_initial_model() { // You need to compile everything before trying to use this var input = new ProjectInput { Path = AppDomain.CurrentDomain.BaseDirectory.ParentDirectory() .ParentDirectory() .ParentDirectory() .AppendPath("Storyteller.Samples"), ProfileFlag = "Safari" }; using (var controller = input.BuildRemoteController()) { controller.Start(EngineMode.Batch).Wait(30.Seconds()); var hierarchy = HierarchyLoader.ReadHierarchy(input.Path.AppendPath("Specs")); var request = new BatchRunRequest { SpecPath = input.SpecPath }; var response = controller.Send(request).AndWaitFor <BatchRunResponse>(); var cache = new ResultsCache(); response.Result.records.Each( x => { var completed = new SpecExecutionCompleted(x.specification.id, x.results, x.specification); cache.Store(completed); }); response.Result.fixtures = controller.LatestSystemRecycled.fixtures; var hierarchyLoaded = new HierarchyLoaded(hierarchy, cache); var initialization = new InitialModel(controller.LatestSystemRecycled, hierarchyLoaded) { wsAddress = "ws://localhost:" + 8200 }; writeResponse(response.Result); //writeInitialization(initialization); } }
public async Task <IActionResult> PostProjectInput([FromBody] ProjectInput projectInput) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} var project = projectInput; project.CreatedUserId = 1; _context.ProjectInput.Add(project); await _context.SaveChangesAsync(); return(CreatedAtAction("GetProjectInput", project)); }
//[Fact] public void write_initial_model() { // You need to compile everything before trying to use this var input = new ProjectInput(EngineMode.Batch) { Path = samplesFolder, ProfileFlag = "Safari" }; using (var controller = input.BuildEngine()) { controller.Start().Wait(30.Seconds()); var hierarchy = HierarchyLoader.ReadHierarchy(input.Path.AppendPath("Specs")); var request = new BatchRunRequest { SpecPath = input.SpecPath }; var response = controller.Send(request).AndWaitFor <BatchRunResponse>(); var cache = new ResultsCache(); response.Result.records.Each( x => { var completed = new SpecExecutionCompleted(x.specification.id, x.results, x.specification); cache.Store(completed); }); response.Result.fixtures = controller.LatestSystemRecycled.fixtures; var hierarchyLoaded = new HierarchyLoaded(hierarchy, cache); writeResponse(response.Result); //writeInitialization(initialization); } }
public async Task <IActionResult> PutProjectInput([FromRoute] int id, [FromBody] ProjectInput projectInput) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} //if (id != projectInput.ProjectInputId) //{ // return BadRequest(); //} var project = projectInput; project.CreatedUserId = 1; project.ProjectInputId = id; project.IsActive = true; _context.Entry(project).State = EntityState.Modified; try { await _context.SaveChangesAsync(); return(CreatedAtAction("GetProjectInput", new { id = projectInput.ProjectInputId }, project)); } catch (DbUpdateConcurrencyException) { if (!ProjectInputExists(id)) { return(NotFound()); } throw; } return(NoContent()); }
/// <summary> /// /// </summary> public async Task <Result <CommandResult> > UpdateAsync(ProjectInput input) { var updateCommand = _mapper.Map <UpdateProjectCommand>(input); return(await SendCommandAsync(updateCommand)); }
/// <summary> /// /// </summary> public async Task <Result <CommandResult> > CreateAsync(ProjectInput input) { var project = _mapper.Map <CreateProjectCommand>(input); return(await SendCommandAsync(project)); }
private async Task <ProjectResult> CreateProject(ProjectInput input) { _logger.LogInformation(GetLogMessage("Creating Project: {@input}"), input); var retVal = new ProjectResult(); var candidate = await Repository.Queryable().Where(x => x.Abbreviation == input.Abbreviation && x.ProjectManagerOrganizationId == input.ProjectManagerOrganizationId || x.ProjectManagerOrganizationId == input.ProjectManagerOrganizationId && x.Name == input.Name) .FirstOrDefaultAsync(); if (candidate != null) { retVal.ErrorMessage = "Project with same name or abbreviation already exists"; return(retVal); } var pm = _pmService.GetById <OrganizationProjectManagerOutput>(input.ProjectManagerId, input.ProjectManagerOrganizationId); var acct = _accountService.GetAccount <CustomerAccountOutput>(input.ProjectManagerOrganizationId, input.AccountNumber); await Task.WhenAll(pm, acct); if (acct.Result == null) { retVal.ErrorMessage = "No customer account found"; return(retVal); } _logger.LogDebug(GetLogMessage("Preparing to create project")); var project = new Project { Name = input.Name, CustomerId = acct.Result.CustomerId, CustomerOrganizationId = acct.Result.CustomerOrganizationId, ProjectManagerId = pm.Result.ProjectManagerId, ProjectManagerOrganizationId = pm.Result.OrganizationId, AccountManagerId = acct.Result.AccountManagerId, AccountManagerOrganizationId = acct.Result.AccountManagerOrganizationId, UpdatedById = _userInfo.UserId, CreatedById = _userInfo.UserId, Status = ProjectStatus.Pending, Abbreviation = input.Abbreviation, AutoApproveTimeEntries = acct.Result.AutoApproveTimeEntries }.InjectFrom(input) as Project; project.StatusTransitions.Add(new ProjectStatusTransition() { Status = project.Status, ObjectState = ObjectState.Added }); var records = await Repository.InsertAsync(project, true); _logger.LogDebug(GetLogMessage("{0} Records Updated"), records); if (records > 0) { retVal.Succeeded = true; retVal.ProjectId = project.Id; await Task.Run(() => { RaiseEvent(new ProjectCreatedEvent { ProjectId = project.Id }); }); } return(retVal); }
public async Task <List <KeyValuePair <string, string> > > GetAllProjectInWorkSpace(ProjectInput input) { return(await _asanaManager.GetAllProjectInWorkSpace(input)); }
public Task <ProjectResult> CreateProject(IOrganizationAccountManager am, ProjectInput input) { input.ProjectManagerOrganizationId = am.OrganizationId; return(CreateProject(input)); }
public Task <ProjectResult> CreateProject(IProviderAgencyOwner ao, ProjectInput input) { input.ProjectManagerOrganizationId = ao.OrganizationId; return(CreateProject(input)); }
public async Task <List <KeyValuePair <string, string> > > GetAllProjectInWorkSpace(ProjectInput input) { var httpClient = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, $"workspaces/{input.WorkspaceId}/projects"); httpClient.BaseAddress = new Uri("https://app.asana.com/api/1.0/"); // to do: get uri from appsettings httpClient.DefaultRequestHeaders.Add("Accept", "application/json"); httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {input.Token}"); var response = await httpClient.SendAsync(request); if (response.StatusCode == HttpStatusCode.BadRequest) { throw new UserFriendlyException("an error occurred"); } var stringData = await response.Content.ReadAsStringAsync(); var workspaces = JsonConvert.DeserializeObject <BaseAsana <AsanaProject> >(stringData); var list = new List <KeyValuePair <string, string> >(); workspaces.data.ForEach(a => { list.Add(new KeyValuePair <string, string>(a.gid, a.name)); }); return(list); }
public async Task <JsonResult> DeleteUserProject([FromBody] ProjectInput project) { string sErr = ""; JsonResult response = null; List <Project> allProjects = new List <Project>(); string userID = ""; try { await Task.Run(() => { userID = _userRepository.GetUserID(project.Username); }); if (String.IsNullOrEmpty(userID)) { sErr += "Cannot find user!"; goto Get_Out; } await Task.Run(() => { allProjects = _projectRepository.GetNonDeletedByUserID(userID); }); var findProject = allProjects.FirstOrDefault(x => x.Name == project.Name); if (findProject == null) { sErr += $"Cannot find project named as {project.Name}"; goto Get_Out; } await Task.Run(() => { sErr = _projectRepository.Delete(findProject); }); } catch (Exception ex) { sErr += ex.Message + "\r\n" + ex.StackTrace; } Get_Out: if (!String.IsNullOrEmpty(sErr)) { response = Json(new AjaxResponse { Succeed = false, Status = "failed", Message = "Delete projects failed:" + sErr }); return(response); } else { response = Json(new AjaxResponse { Succeed = true, Status = "success", Message = "Delete projects success", }); return(response); } }
public async Task <JsonResult> CreateNewPorject([FromBody] ProjectInput input) { string sErr = ""; JsonResult response = null; string userID = ""; try { Project existProject = null; if (String.IsNullOrEmpty(input.Name)) { sErr = "Project name cannot be empty!"; goto Get_Out; } if (String.IsNullOrEmpty(input.Username)) { sErr = "User name cannot be empty!"; goto Get_Out; } await Task.Run(() => { userID = _userRepository.GetUserID(input.Username); }); if (String.IsNullOrEmpty(userID)) { sErr = "Cannot find user!"; goto Get_Out; } await Task.Run(() => { existProject = this._projectRepository.Get(input.Name, userID); }); if (existProject != null) { sErr += "Project name cannot be duplicated!"; goto Get_Out; } Project project = new Project() { UserID = userID, Name = input.Name, ProjectType = input.ProjectType, Description = input.Description, }; await Task.Run(() => { sErr = _projectRepository.Add(project); }); if (sErr != "") { goto Get_Out; } //using (ConfigContext db = new ConfigContext(new DbContextOptions<ConfigContext>())) //{ // db.Porjects.Add(project); // db.SaveChanges(); //} } catch (Exception ex) { sErr += "\r\n" + ex.Message + "\r\n" + ex.StackTrace; goto Get_Out; } Get_Out: if (!String.IsNullOrEmpty(sErr)) { sErr += "\r\nRoutine=" + MethodInfo.GetCurrentMethod().ReflectedType.Name + "." + MethodInfo.GetCurrentMethod().ToString(); //_logger.LogError(sErr); response = Json(new AjaxResponse { Succeed = false, Status = "failed", Message = "Create project failed:" + sErr }); return(response); } else { sErr = "Create Model Success!"; //_logger.LogInformation(sErr); response = Json(new AjaxResponse { Succeed = true, Status = "success", Message = "Create project success!" }); return(response); } }
public void CreateOrEditProject([FromBody] ProjectInput input) { projectAppService.CreateOrEditProject(input); }