public async Task <IActionResult> CreatProductCategory(CreatProductCategory request)
        {
            var creat = await _productCategoryConnectAPI.CreatProductCategory(request);

            return(Json(new
            {
                status = true
            }));
        }
Beispiel #2
0
        public async Task <bool> CreatProductCategory(CreatProductCategory request)
        {
            var json       = JsonConvert.SerializeObject(request);
            var jsonstring = new StringContent(json, Encoding.UTF8, "application/json");
            var creat      = _httpClientFactory.CreateClient();

            creat.BaseAddress = new Uri(_configuration["URLAPI:Url"]);
            var post = await creat.PostAsync("api/ProductCategory/CreatProductCategory", jsonstring);

            return(post.IsSuccessStatusCode);
        }
        public async Task <int> CreatProductCategoryViewModel(CreatProductCategory request)
        {
            if (request.Id >= 0)
            {
                var productcategoryUpdate = await _context.ProductCategories.FindAsync(request.Id);

                productcategoryUpdate.Name        = request.Name;
                productcategoryUpdate.Decripstion = request.Decripstion;
                if (request.ParentId == 0)
                {
                    productcategoryUpdate.ParentId = null;
                }
                else
                {
                    productcategoryUpdate.ParentId = request.ParentId;
                }

                productcategoryUpdate.PathImage      = request.PathImage;
                productcategoryUpdate.SortOrder      = request.SortOrder;
                productcategoryUpdate.SeoAlias       = request.SeoAlias;
                productcategoryUpdate.SeoDescription = request.SeoDescription;
                productcategoryUpdate.SeoKeywords    = request.SeoKeywords;
                productcategoryUpdate.SeoPageTitle   = request.SeoPageTitle;


                _context.ProductCategories.Update(productcategoryUpdate);
            }
            else
            {
                var productcategory = new ProductCategory()
                {
                    Name           = request.Name,
                    Decripstion    = request.Decripstion,
                    ParentId       = request.ParentId,
                    PathImage      = request.PathImage,
                    SortOrder      = request.SortOrder,
                    SeoAlias       = request.SeoAlias,
                    SeoDescription = request.SeoDescription,
                    SeoKeywords    = request.SeoKeywords,
                    SeoPageTitle   = request.SeoPageTitle
                };
                _context.ProductCategories.Add(productcategory);
            }
            return(await _context.SaveChangesAsync());
        }
        public async Task <IActionResult> CreatProductCategory(CreatProductCategory request)
        {
            var creat = await _productCategorySerVice.CreatProductCategoryViewModel(request);

            return(Ok());
        }