private void AddCompanyCities()
        {
            var companies = _context.Companies.ToArray();
            var cities    = _context.Cities.ToArray();

            var companyCities = new CompanyCity[]
            {
                new CompanyCity {
                    CompanyId = companies[0].Id, CityId = cities[0].Id
                },
                new CompanyCity {
                    CompanyId = companies[1].Id, CityId = cities[1].Id
                },
                new CompanyCity {
                    CompanyId = companies[2].Id, CityId = cities[2].Id
                },
                new CompanyCity {
                    CompanyId = companies[3].Id, CityId = cities[2].Id
                },
                new CompanyCity {
                    CompanyId = companies[4].Id, CityId = cities[1].Id
                },
            };

            _context.CompanyCities.AddRange(companyCities);
            _context.SaveChanges();
        }
Beispiel #2
0
        public async Task AddCompanyToCityAsync(CompanyCity companyCity)
        {
            await _uow.CompanyCities.AddAsync(companyCity);

            await _uow.SaveChangesAsync();
        }
        public async Task <ActionResult <CompanyCity> > AddCompanyToCityAsync(CompanyCity companyCity)
        {
            await _companyService.AddCompanyToCityAsync(companyCity);

            return(Ok(companyCity));
        }
Beispiel #4
0
 public async Task RemoveCompanyFromCityAsync(CompanyCity companyCity)
 {
     _uow.CompanyCities.Remove(companyCity);
     await _uow.SaveChangesAsync();
 }
        public async Task <ActionResult <CompanyCity> > RemoveCompanyFromCitiesAsync(CompanyCity companyCity)
        {
            await _companyService.RemoveCompanyFromCityAsync(companyCity);

            return(Ok(companyCity));
        }