public async Task <ActionResult <Company> > Put(int id, [FromBody] CompanyDTO request) { var company = await _service.GetByIdAsync(id); await _service.DeletePrefixesByCompanyAsync(company); company.Name = request.Name; company.Prefixes = request.Prefixes.Select(p => new Prefix { Number = p.Number }).ToList(); _db.Entry(company).State = EntityState.Modified; await _db.SaveChangesAsync(); return(Ok(company)); }