Exemplo n.º 1
0
        public IActionResult Create()
        {
            ViewBag.Title = "Add Product Category";
            AddProductCategoryViewModel addProductCategoryViewModel = new AddProductCategoryViewModel();

            return(View());
        }
        public async Task <IActionResult> addProductCategory([FromBody] AddProductCategoryViewModel addProductCategoryViewModel)
        {
            var respond = await _productCategoryService.AddProductAsync(addProductCategoryViewModel);

            if (respond.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return(Ok(respond.data));
            }
            else
            {
                return(BadRequest(new { Message = respond.Message }));
            }
        }
Exemplo n.º 3
0
        public IActionResult Create(AddProductCategoryViewModel addProductCategoryViewModel)
        {
            if (ModelState.IsValid)
            {
                ProductCategory newCategory = new ProductCategory
                {
                    Name = addProductCategoryViewModel.Name
                };

                _context.Categories.Add(newCategory);
                _context.SaveChanges();

                return(Redirect("/productcategory"));
            }
            return(View());
        }
Exemplo n.º 4
0
        public async Task <RespondModel> AddProductAsync(AddProductCategoryViewModel addProductCategoryViewModel)
        {
            var addUser = AutoMapper.Mapper.Map <ProductCategory>(addProductCategoryViewModel);

            return(await _productCategoryRepository.InsertAsync(addUser));
        }