public async Task <ContestCategoryModel> SaveCategory(ContestCategoryModel categoryModel)
        {
            var category = _mapper.Map <ContestCategory>(categoryModel);
            await _repository.Save(category);

            categoryModel.Id = category.Id;
            return(categoryModel);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Remove([FromBody] ContestCategoryModel category)
        {
            try
            {
                await _categoriesService.RemoveCategory(category.Id);

                return(Ok(category.Id));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Save([FromBody] ContestCategoryModel category)
        {
            try
            {
                var savedCategory = await _categoriesService.SaveCategory(category);

                return(Created("Add", savedCategory));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }