public async Task <IActionResult> PutRepository(string id, RepositoryDto repositorydto) { if (id != repositorydto.name) { return(BadRequest()); } var repository = repositorydto.ToModel(); _context.Repositories.Update(repository); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RepositoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <RepositoryDto> > PostRepository(RepositoryDto repositoryDto) { var repository = repositoryDto.ToModel(); if (repository == null) { return(UnprocessableEntity($"The repository type {repositoryDto.repositoryType} is not supported!")); } _context.Repositories.Add(repository); await _context.SaveChangesAsync(); return(CreatedAtAction("GetRepository", new { id = repository.Name }, repository)); }