public async Task <IActionResult> PostGCIMS([FromBody] Guid id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // var project = await _context.Project.SingleOrDefaultAsync(p => p.ProjectId == id); var project = await _unitOfWork.Projects.GetAsync(id); GCIMSHelper gcimsHelper = new GCIMSHelper(_gcimsContext, project); var newGCIMSProject = gcimsHelper.CreateGCIMSproject(); return(CreatedAtAction("GetProject", new { id = project.ProjectId }, project)); // return Ok(newGCIMSProject.Result); }
public async Task <IActionResult> PutProject([FromRoute] Guid id, [FromBody] Project project) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != project.ProjectId) { return(BadRequest()); } _context.Entry(project).State = EntityState.Modified; if (project.SubmitGcims) { GCIMSHelper gcimsHelper = new GCIMSHelper(_gcimsContext, project); var newGCIMSProject = gcimsHelper.CreateGCIMSproject(); project.GcimsProjectID = newGCIMSProject.Result.ProjectID; project.GcimsClientId = newGCIMSProject.Result.ClientID; project.GcimsContactId = newGCIMSProject.Result.tblApplication.ContactID; } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!_unitOfWork.Projects.ProjectExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }