CompanyRepository
unknown
csharp
a year ago
1.1 kB
6
Indexable
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();
}
}
}
Editor is loading...
Leave a Comment