Beispiel #1
0
        public async Task Put(CityDTO item)
        {
            using (var repo = new CityRepository())
            {
                City existing = await repo.GetById(item.Id);

                if (existing == null)
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }
                item.Save(existing);
                await repo.Commit();
            }
        }
Beispiel #2
0
        public async Task <int> Post(CityDTO item)
        {
            using (var repo = new CityRepository())
            {
                City city = new City();
                item.Save(city);

                await repo.Create(city);

                await repo.Commit();

                return(city.Id);
            }
        }
Beispiel #3
0
        public async Task Delete(CityDTO item)
        {
            using (var repo = new CityRepository())
            {
                City existing = await repo.GetById(item.Id);

                if (existing == null)
                {
                    return;
                }
                await repo.Delete(existing);

                await repo.Commit();
            }
        }