| @@ -34,7 +34,6 @@ namespace Diligent.WebAPI.Business.Services | |||
| public async Task UploadFileAsync(FileEntity file) | |||
| { | |||
| await _context.Files.AddAsync(file); | |||
| await _context.SaveChangesAsync(); | |||
| } | |||
| @@ -9,6 +9,7 @@ namespace Diligent.WebAPI.Business.Services.Interfaces | |||
| Task<FileFiltersReturnDTO> GetFilters(); | |||
| Task<List<TagNameResponse>> GetTagsNames(); | |||
| Task<Tag> GetTagEntityById(int id); | |||
| Task CreateTag(string name); | |||
| } | |||
| } | |||
| @@ -45,5 +45,11 @@ namespace Diligent.WebAPI.Business.Services | |||
| public async Task<Tag> GetTagEntityById(int id) => | |||
| await _databaseContext.Tags.Where(x => x.Id == id).FirstOrDefaultAsync(); | |||
| public async Task CreateTag(string name) | |||
| { | |||
| await _databaseContext.Tags.AddAsync(new Tag { Name = name }); | |||
| await _databaseContext.SaveChangesAsync(); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,13 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| namespace Diligent.WebAPI.Contracts.DTOs.Tags | |||
| { | |||
| public class CreateTagDto | |||
| { | |||
| public string Name { get; set; } | |||
| } | |||
| } | |||
| @@ -21,5 +21,12 @@ namespace Diligent.WebAPI.Host.Controllers.V1 | |||
| [HttpGet("names")] | |||
| public async Task<IActionResult> GetTagsNames() => Ok(await _tagService.GetTagsNames()); | |||
| [HttpPost] | |||
| public async Task<IActionResult> CreateTag(CreateTagDto createTagDto) | |||
| { | |||
| await _tagService.CreateTag(createTagDto.Name); | |||
| return StatusCode((int)HttpStatusCode.Created); | |||
| } | |||
| } | |||
| } | |||
| @@ -42,9 +42,9 @@ namespace Diligent.WebAPI.Host.Extensions | |||
| services.AddScoped<IScreeningTestService, ScreeningTestService>(); | |||
| services.AddScoped<IFileService, FileService>(); | |||
| services.AddScoped<IFileEntityService, FileEntityService>(); | |||
| services.AddScoped<ITagService, TagService>(); | |||
| services.AddScoped<ICategoryService, CategoryService>(); | |||
| services.AddScoped<IDocumentService, DocumentService>(); | |||
| services.AddScoped<ITagService, TagService>(); | |||
| } | |||
| /// <summary> | |||