public async Task <IActionResult> PutTrainingClient([FromRoute] int id, [FromBody] TrainingClient trainingClient) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != trainingClient.TrainingId) { return(BadRequest()); } //_context.Entry(trainingClient).State = EntityState.Modified; try { await _unitOfWork.TrainingClients.UpdateAsync(trainingClient); } catch (DbUpdateConcurrencyException) { if (!(await TrainingClientExists(id))) { return(NotFound()); } else { throw; } } return(NoContent()); }
public Iteration GetIteration(string IterationName = "", Guid IterationId = new Guid(), int IterationNumber = -1) { if (ProjectId == Guid.Empty) { return(null); } if (IterationId != Guid.Empty && string.IsNullOrEmpty(IterationName)) { return(TrainingClient.GetIteration(ProjectId, IterationId)); } else if (IterationId == Guid.Empty && !string.IsNullOrEmpty(IterationName)) { return(GetIterations().Where(x => x.Name == IterationName).FirstOrDefault(null)); } else if (IterationId != Guid.Empty && !string.IsNullOrEmpty(IterationName)) { var temp = TrainingClient.GetIteration(ProjectId, IterationId); if (temp.Name.ToLower() == IterationName.ToLower()) { return(temp); } } else if (IterationNumber > -1) { return(GetIterations()[IterationNumber]); } return(null); }
public Project GetProject(string ProjectName = "", Guid ProjectId = new Guid(), int ProjectNumber = -1) { if (TrainingClient == null) { return(null); } if (ProjectId != Guid.Empty && string.IsNullOrEmpty(ProjectName)) { return(TrainingClient.GetProject(ProjectId)); } else if (ProjectId == Guid.Empty && !string.IsNullOrEmpty(ProjectName)) { return(GetProjects().Where(x => x.Name == ProjectName).FirstOrDefault(null)); } else if (ProjectId != Guid.Empty && !string.IsNullOrEmpty(ProjectName)) { var temp = TrainingClient.GetProject(ProjectId); if (temp.Name.ToLower() == ProjectName.ToLower()) { return(temp); } } else if (ProjectNumber > -1) { return(GetProjects()[ProjectNumber]); } return(null); }
public static async Task UploadTrainingImage(byte[] bytes) { var projectId = Environment.GetEnvironmentVariable("CustomVisionProjectId"); var projectGuid = Guid.Parse(projectId); using (var stream = new MemoryStream(bytes)) { var summary = await TrainingClient.CreateImagesFromDataAsync(projectGuid, stream, null); } }
public async Task <IActionResult> PostTrainingClient([FromBody] TrainingClient trainingClient) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _unitOfWork.TrainingClients.AddAsync(trainingClient); return(CreatedAtAction("GetTrainingClient", new { id = trainingClient.TrainingId }, trainingClient)); }
public List <Iteration> GetIterations() { if (ProjectId != Guid.Empty) { List <Iteration> temp = TrainingClient.GetIterations(ProjectId).ToList(); return(temp); } else { return(new List <Iteration>()); } }
public List <Project> GetProjects() { if (TrainingClient != null) { List <Project> temp = TrainingClient.GetProjects().ToList(); return(temp); } else { return(new List <Project>()); } }