示例#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();
            }
        }
示例#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);
            }
        }