public async Task <IActionResult> Details(int id)
        {
            var languageId = HttpContext.Session.GetString(SystemConstants.AppSettings.DefaultLanguageId);
            var result     = await _categoryApiClient.GetById(id, languageId);

            return(View(result));
        }
        public async Task <IActionResult> Detail(int id, string culture)
        {
            var product = await _productApiClient.GetById(id, culture);

            return(View(new ProductDetailViewModel()
            {
                Product = product,
                Category = await _categoryApiClient.GetById(culture, id)
            }));
        }
        public async Task <IActionResult> Edit(int id)
        {
            var result = await _categoryApiCilent.GetById(id, GetLanguageId());

            if (result.IsSuccessed)
            {
                var request = new CategoryUpdateRequest()
                {
                    Id             = result.ResultObj.Id,
                    IsShowOnHome   = result.ResultObj.IsShowOnHome,
                    LanguageId     = result.ResultObj.LanguageId,
                    Name           = result.ResultObj.Name,
                    ParentId       = result.ResultObj.ParentId,
                    SeoAlias       = result.ResultObj.SeoAlias,
                    SeoDescription = result.ResultObj.SeoDescription,
                    SeoTitle       = result.ResultObj.SeoTitle,
                    SortOrder      = result.ResultObj.SortOrder,
                    Status         = result.ResultObj.Status
                };
                return(View(request));
            }
            return(RedirectToAction("Error", "Home"));
        }
        public async Task <IActionResult> Edit(int id)
        {
            var result = await _categoryApiClient.GetById(id);

            var Request = new CategoryUpdateRequest()
            {
                Id        = id,
                Name      = result.Name,
                SortOrder = result.SortOrder,
                ParentId  = result.ParentId
            };

            return(View(Request));
        }
Beispiel #5
0
        public async Task <IActionResult> Edit(string id)
        {
            var languageId = HttpContext.Session.GetString(SystemConstants.AppSettings.DefaultLanguageId);

            var category = await _categoryApiClient.GetById(id);

            var editVm = new CategoryUpdateRequest()
            {
                Id   = category.Id,
                Name = category.Name,
            };

            return(View(editVm));
        }
Beispiel #6
0
        public async Task <IActionResult> Category(int id, string culture, int page = 1)
        {
            var products = await _productApiClient.GetPagings(new GetManageProductPagingRequest
            {
                CategoryId = id,
                LanguageId = culture,
                PageIndex  = page,
                PageSize   = 3
            });

            return(View(new ProductCategoryViewModel()
            {
                Category = await _categoryApiClient.GetById(culture, id),
                Products = products
            }));
        }
Beispiel #7
0
        public async Task <IActionResult> Update(int id)
        {
            var result = await _categoryApiClient.GetById(id);

            if (!result.IsSuccess || result.ResultObject == null)
            {
                TempData["error"] = result.Message;
                return(RedirectToAction("Index"));
            }
            var updateRequest = new UpdateCategoryRequest()
            {
                id                = id,
                cate_name         = result.ResultObject.cate_name,
                cate_slug         = result.ResultObject.cate_slug,
                isActive          = result.ResultObject.isActive,
                meta_descriptions = result.ResultObject.meta_descriptions,
                meta_keywords     = result.ResultObject.meta_keywords,
                meta_title        = result.ResultObject.meta_title,
                parent_id         = result.ResultObject.parent_id,
            };

            var cate_tree = await _categoryApiClient.GetAllCategory();

            // Không hiển thị lại loại này trong danh sách
            var thisCate = cate_tree.Find(x => x.id == result.ResultObject.id);

            if (thisCate != null)
            {
                cate_tree.Remove(thisCate);
            }

            // Load danh sách category theo dạng tree
            ViewBag.ListCate = await OrderCateToTree(cate_tree);

            return(View(updateRequest));
        }