CompanyRepository

mail@pastecode.io avatar
unknown
csharp
9 days ago
1.1 kB
1
Indexable
Never
using HeadHunterClone.Domain.Models;
using HeadHunterClone.Infrastructure.Data;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Security.Cryptography.X509Certificates;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;

namespace HeadHunterClone.API.Repositories
{
    public class CompanyRepository
    {
        private readonly ApplicationDbContext _dbContext;

        public CompanyRepository(ApplicationDbContext dbContext)
        {
            _dbContext = dbContext;
        }

        public List<Company> Get()
        {
            return _dbContext.Companies.ToList();
        }
        public void Create(CreateCompanyDto companyDto)
        {
            // mapping
            var company = new Company()
            {
                
                Name = companyDto.Name,
                Description = companyDto.Description,
                DateOfRegistration = companyDto.DateOfRegistration,
                
            };

           _dbContext.Companies.Add(company);
           _dbContext.SaveChanges();
        }
    }
}


Leave a Comment