Пример #1
0
        public ActionResult <CategoryViewModel> Post(CategoryImputModel categoryInput)
        {
            CategoryProduct category = Map(categoryInput);
            var             response = categoryService.Save(category);

            if (response.Error)
            {
                return(BadRequest(response.Message));
            }
            return(Ok(response.Category));
        }
Пример #2
0
        private CategoryProduct Map(CategoryImputModel categoryInput)
        {
            var category = new CategoryProduct();

            category.IdCategory = categoryInput.IdCategory;
            category.Name       = categoryInput.Name;

            category.TypeProduct        = new TypeProduct();
            category.TypeProduct.IdType = categoryInput.TypeProduct.IdType;
            category.TypeProduct.Name   = categoryInput.TypeProduct.Name;

            return(category);
        }