public async Task <ActionResult <long> > CreateAsync([FromBody] CompanyForCreation company)
        {
            var companyEntity = _mapper.Map <EfDataAccess.Entities.Company>(company);

            _companies.AddCompany(companyEntity);

            await _companies.SaveChangesAsync();

            return(CreatedAtRoute("GetCompany",
                                  new { id = companyEntity.Id },
                                  companyEntity));
        }
Exemplo n.º 2
0
        public async Task <Company> AddCompany(Company company)
        {
            var addedCompany = _companiesRepository.Add(company);

            if (await _companiesRepository.SaveChangesAsync())
            {
                return(addedCompany);
            }
            else
            {
                return(null);
            }
        }