public async Task <IActionResult> GetAsync() { var fileTypes = await this._repositoryManager .FileTypeRepository.GetAsync(); return(Ok(fileTypes.Select(ft => FileTypeMapper.Map(ft)))); }
public async Task <IActionResult> DeleteAsync([FromRoute] int id) { var fileType = await _repositoryManager .FileTypeRepository.GetAsync(id); if (fileType == null) { return(NotFound()); } _repositoryManager.FileTypeRepository.Delete(fileType); await _repositoryManager.SaveAsync(); return(Ok(FileTypeMapper.Map(fileType))); }
public async Task <IActionResult> CreateAsync([FromBody] InFileTypeDTO fileTypeDTO) { if (await _repositoryManager .FileTypeRepository.ExistsAsync(fileTypeDTO.Name)) { return(BadRequest()); } var fileType = FileTypeMapper.Map(fileTypeDTO); fileType = _repositoryManager.FileTypeRepository.Create(fileType); await _repositoryManager.SaveAsync(); return(Ok(FileTypeMapper.Map(fileType))); }
public async Task <IActionResult> UpdateAsync([FromRoute] int id, [FromBody] InFileTypeDTO fileTypeDTO) { var fileType = await _repositoryManager .FileTypeRepository.GetAsync(id); if (fileType == null) { return(NotFound()); } fileType = _repositoryManager .FileTypeRepository.Update(fileType, fileTypeDTO.Name); await _repositoryManager.SaveAsync(); return(Ok(FileTypeMapper.Map(fileType))); }