| 123456789101112131415161718192021222324252627 |
- using Diligent.WebAPI.Contracts.DTOs.Categories;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace Diligent.WebAPI.Business.Services
- {
- public class CategoryService : ICategoryService
- {
- private readonly DatabaseContext _context;
- private readonly IMapper _mapper;
-
- public CategoryService(DatabaseContext context, IMapper mapper)
- {
- _context = context;
- _mapper = mapper;
- }
-
- public async Task<List<CategoriesNamesResponse>> GetCategoriesNamesAsync() =>
- _mapper.Map<List<CategoriesNamesResponse>>(await _context.Categories.ToListAsync());
-
- public async Task<Category> GetCategoryEntityById(int id) =>
- await _context.Categories.Where(x => x.Id == id).FirstOrDefaultAsync();
- }
- }
|