Exemplo n.º 1
0
        public async Task Put(CategoryDTO item)
        {
            using (var repo = new CategoryRepository())
            {
                Category existing = await repo.GetById(item.Id);

                if (existing == null)
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }
                item.Save(existing);
                await repo.Commit();
            }
        }
Exemplo n.º 2
0
        public async Task <int> Post(CategoryDTO item)
        {
            using (var repo = new CategoryRepository())
            {
                Category category = new Category();
                item.Save(category);

                await repo.Create(category);

                await repo.Commit();

                return(category.Id);
            }
        }
Exemplo n.º 3
0
        public async Task Delete(CategoryDTO item)
        {
            using (var repo = new CategoryRepository())
            {
                Category existing = await repo.GetById(item.Id);

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

                await repo.Commit();
            }
        }