public async Task <IActionResult> Edit(int productId, string categoryUrl, string languageId)
        {
            var product = await _productServive.GetById(productId, languageId);

            var result = await _languageService.GetAll();

            var categories = await _categoryService.GetAll("vn");

            ViewData["languages"] = result.ResultObject;

            var indexVN = result.ResultObject.FindIndex(x => x.Name == "VIETNAM");

            if (indexVN != 0)
            {
                SwapGeneric <LanguageViewModel> .Swap(result.ResultObject, indexVN, 0);
            }
            ViewData["categories"] = categories.ResultObject;
            var index = categories.ResultObject.FindIndex(x => x.CategoryUrl == categoryUrl);

            //Swap
            if (index != 0)
            {
                SwapGeneric <CategoryViewModel> .Swap(categories.ResultObject, index, 0);
            }
            ViewData["product"] = product.ResultObject;
            return(View("NewProduct"));
        }
Ejemplo n.º 2
0
        public async Task <List <LanguageViewModel> > GetListLanguageAsync()
        {
            var listLanguage = await _languageService.GetAll();

            var indexVN = listLanguage.ResultObject.FindIndex(x => x.Name == "VIETNAM");

            if (indexVN != -1)
            {
                SwapGeneric <LanguageViewModel> .Swap(listLanguage.ResultObject, indexVN, 0);
            }
            return(listLanguage.ResultObject);
        }
Ejemplo n.º 3
0
        public async Task <List <CategoryViewModel> > GetListCategoryAsync(string languageId, string categoryUrl = null)
        {
            var listCategory = await _categoryService.GetAll(languageId);

            if (categoryUrl != null)
            {
                var index = listCategory.ResultObject.FindIndex(x => x.CategoryUrl == categoryUrl);
                if (index != 0)
                {
                    SwapGeneric <CategoryViewModel> .Swap(listCategory.ResultObject, index, 0);
                }
            }
            return(listCategory.ResultObject);
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> EditAsync(int blogId)
        {
            var blog = await _blogService.GetById(blogId);

            var categories = await GetListCategoryAsync(languageDefauleId);

            ViewData["blog"] = blog.ResultObject;
            var index = categories.FindIndex(x => x.Name == blog.ResultObject.CategoryName);

            //Swap
            if (index != 0)
            {
                SwapGeneric <CategoryViewModel> .Swap(categories, index, 0);
            }
            ViewData["categories"] = categories;
            return(View("PostBlog"));
        }
        public async Task <IActionResult> IndexAsync(int productId)
        {
            var paggingRequest = new GetProductPaggingRequest()
            {
                LanguageId = languageDefauleId,
            };
            var products = await _productServive.getAllPagging(paggingRequest);

            var images = await _imageProductServive.GetListImage(productId);

            var productSelected = products.ResultObject.Items.FindIndex(x => x.Id == productId);

            if (productSelected != -1)
            {
                SwapGeneric <ProductViewModel> .Swap(products.ResultObject.Items, productSelected, 0);
            }
            ViewData["categories"] = await GetListCategoryAsync(languageDefauleId);

            ViewData["products"] = products.ResultObject.Items;
            ViewData["images"]   = images.ResultObject;
            return(View());
        }
        public async Task <IActionResult> NewProduct(string categoryUrl)
        {
            var result = await _languageService.GetAll();

            var categories = await _categoryService.GetAll(languageDefauleId);

            ViewData["languages"] = result.ResultObject;

            var indexVN = result.ResultObject.FindIndex(x => x.Name == "VIETNAM");

            if (indexVN != 0)
            {
                SwapGeneric <LanguageViewModel> .Swap(result.ResultObject, indexVN, 0);
            }
            ViewData["categories"] = categories.ResultObject;
            var index = categories.ResultObject.FindIndex(x => x.CategoryUrl == categoryUrl);

            if (index != 0)
            {
                SwapGeneric <CategoryViewModel> .Swap(categories.ResultObject, index, 0);
            }
            return(View());
        }