Ejemplo 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();
            }
        }
Ejemplo 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);
            }
        }