소스 검색

add tag service

BE_dev
Dzenis Hadzifejzovic 2 년 전
부모
커밋
7e2cbb92da

+ 0
- 1
Diligent.WebAPI.Business/Services/FileEntityService.cs 파일 보기

@@ -34,7 +34,6 @@ namespace Diligent.WebAPI.Business.Services
public async Task UploadFileAsync(FileEntity file)
{
await _context.Files.AddAsync(file);

await _context.SaveChangesAsync();
}


+ 1
- 0
Diligent.WebAPI.Business/Services/Interfaces/ITagService.cs 파일 보기

@@ -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);

}
}

+ 6
- 0
Diligent.WebAPI.Business/Services/TagService.cs 파일 보기

@@ -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();
}
}
}

+ 13
- 0
Diligent.WebAPI.Contracts/DTOs/Tags/CreateTagDto.cs 파일 보기

@@ -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; }
}
}

+ 7
- 0
Diligent.WebAPI.Host/Controllers/V1/TagsController.cs 파일 보기

@@ -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);
}
}
}

+ 1
- 1
Diligent.WebAPI.Host/Extensions/BusinessConfigurationExtension.cs 파일 보기

@@ -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>

Loading…
취소
저장