public async Task <IActionResult> Index(string keyword, int?categoryId, int page = 1, int pageSize = 5) { var currentLang = _httpContextAccessor.HttpContext.Session.GetString(SystemConstant.AppSettings.DefaultLanguageId); var request = new GetManageProductPagingRequest() { PageIndex = page, PageSize = pageSize, Keyword = keyword, LanguageId = currentLang, CategoryId = categoryId }; ViewBag.Keyword = keyword; var data = await _productApiClient.GetProductPaging(request); var categories = await _categoryApiClient.GetAll(currentLang); ViewBag.Categories = categories.Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.Name, Selected = categoryId.HasValue && categoryId.Value == x.Id });; if (TempData["success"] != null) { ViewBag.SuccessMsg = TempData["success"]; } return(View(data.ResultObject)); }
public async Task <IActionResult> Index(string name, string keyword, int?categoryId, int pageIndex = 1, int pageSize = 8) { var request = new GetManageProductPagingRequest() { Keyword = keyword, PageIndex = pageIndex, PageSize = pageSize, CategoryId = categoryId }; var data = await _productApiClient.GetPagings(request); ViewBag.Keyword = keyword; var categories = await _categoryApiClient.GetAll(); ViewBag.Categories = categories.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString(), Selected = categoryId.HasValue && categoryId.Value == x.Id }); if (TempData["result"] != null) { ViewBag.SuccessMsg = TempData["result"]; } return(View(data)); }
public async Task <IActionResult> Index(string keyword, int?categoryId, decimal?minPrice, decimal?maxPrice, int pageIndex = 1, int pageSize = 10) { var languageId = HttpContext.Session.GetString(SystemConstants.AppSettings.DefaultLanguageId); var request = new GetManageProductPagingRequest() { KeyWord = keyword, PageIndex = pageIndex, PageSize = pageSize, LanguageId = languageId, CategoryId = categoryId, MinPrice = minPrice, MaxPrice = maxPrice, }; var data = await _productApiClient.GetProductPagings(request); ViewBag.Keyword = keyword; ViewBag.MinPrice = minPrice; ViewBag.MaxPrice = maxPrice; var categories = await _categoryApiClient.GetAll(languageId); ViewBag.Categories = categories.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString(), Selected = categoryId.HasValue && categoryId.Value == x.Id }); if (TempData["result"] != null) { ViewBag.SuccessMsg = TempData["result"]; } return(View(data)); }
// GET: CategoryController public async Task <IActionResult> Index(int?page) { ViewBag.Active = 2; if (page == null) { page = 1; } var pageSize = 6; var pageNumber = page ?? 1; var Token = HttpContext.Session.GetString("Token"); if (_userClient.CheckToken(Token, User.Identity.Name) == null) { return(Redirect("/Administration/Home/Login")); } else { if (Token == null) { Token = await _userClient.CheckToken(Token, User.Identity.Name); } } var list = _categoryApi.GetAll(Token).Result.OrderByDescending(x => x.Id).ToPagedList(pageNumber, pageSize); return(View(list)); }
public async Task <IActionResult> Index(string keyword, int?categoryId, int pageIndex = 1, int pageSize = 5) { var awd = User; var languageId = HttpContext.Session.GetString(SystemConstants.AppSettings.DefaultLanguageId); var request = new GetManageProductPagingRequest() { Keyword = keyword, PageIndex = pageIndex, PageSize = pageSize, LanguageId = languageId, CategoryId = categoryId }; var data = await _productApiClient.GetPagings(request); ViewBag.Keyword = keyword; var categories = await _categoryApiClient.GetAll(languageId); ViewBag.Categories = categories.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString(), Selected = categoryId.HasValue && categoryId.Value == x.Id }); // if (TempData["result"] != null) // { // ViewBag.SuccessMsg = TempData["result"]; // } TempData["TotalProducts"] = data.TotalRecords; return(View(data)); }
public async Task <IActionResult> Index(string keyword, int?categoryId, int pageIndex = 1, int pageSize = 5) { var languageId = HttpContext.Session.GetString(SystemConstants.AppSettings.DefaultLanguageId); //B2. Dựng request var request = new GetManageProductPagingRequest() { Keyword = keyword, PageIndex = pageIndex, PageSize = pageSize, LanguageId = languageId, CategoryId = categoryId }; var data = await _productApiClient.GetPagings(request); //Controller sử dụng Service của Project AdminApp để gửi request, lấy về PagedResult<UserViewModel> tạo View ViewBag.Keyword = keyword; //Chuyển keyword ra view để tái hiện lại trên textbox Search var categories = await _categoryApiClient.GetAll(languageId); ViewBag.Categories = categories.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString(), Selected = categoryId.HasValue && categoryId.Value == x.Id //keep Selected mỗi khi submit }); if (TempData["result"] != null) //Nhận TempData["result"] được redirect từ các method Create, Update, Delete { ViewBag.Msg = TempData["result"]; } if (data != null) { return(View(data)); } return(RedirectToAction("Error", "Home")); }
// biding từ query nếu để class thì thêm [formQuery] public async Task <IActionResult> Index(int?categoryId, string keyword, int pageIndex = 1, int pageSize = 6) { var languageId = HttpContext.Session.GetString(SystemConstants.AppSettings.DefaultLanguageId); var request = new GetManageProductPagingRequest() { KeyWord = keyword, PageIndex = pageIndex, PageSize = pageSize, LanguageId = languageId, CategoryId = categoryId }; var data = await _productApiClient.GetProductPagings(request); ViewBag.Keyword = keyword; var categories = await _categoryApiClient.GetAll(languageId); //chuyền lên cho ViewBag.Categories ViewBag.Categories = categories.ResultObj.Select(x => new SelectListItem() // phải SelctListItem thì thẻ select nó mới hiểu chứ chuyền thẳng nó ko hiểu đâu { Text = x.Name, Value = x.Id.ToString(), // để nó dữ lại giá trị khi đã select Selected = categoryId.HasValue && categoryId.Value == x.Id // vì categoryId là object nên ta phải hasvalue vì nó có cả null }); if (TempData["result"] != null) { ViewBag.SuccessMsg = TempData["result"]; } return(View(data.ResultObj)); }
public async Task <IViewComponentResult> InvokeAsync() { var culture = CultureInfo.CurrentCulture.Name; var items = await _categoryApiClient.GetAll(culture); return(View(items)); }
public async Task <IActionResult> Details() { var languageId = HttpContext.Session.GetString(SystemConstants.AppSettings.DefaultLanguageId); var result = await _categoryApiClient.GetAll(); return(View(result)); }
public async Task <IActionResult> Index() { TempData["BackendUrl"] = _config[Constants.AppSettings.BaseAddress]; ViewBag.Categories = await _categoryApiClient.GetAll(); var products = await _productApiClient.GetAll(); return(View(products)); }
public async Task <IActionResult> Add() { var brands = await _brandApiClient.GetAll(); ViewBag.Brands = brands.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }); var categories = await _categoryApiClient.GetAll(); ViewBag.Categories = categories.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString() }); return(View()); }
public async Task<IActionResult> Index(string keyword, int? categoryId,Status? status, int pageIndex = 1, int pageSize = 5) { var request = new ProductPagingRequest() { Keyword = keyword, PageIndex = pageIndex, PageSize = pageSize, LanguageId = GetLanguageId(), Status = status }; if (categoryId != null) request.CategoryId = (int)categoryId; ViewBag.Keyword = keyword; ViewBag.Status = status; List<CategoryViewModel> categories = await _categoryApiClient.GetAll(GetLanguageId()); ViewBag.Statuss = Enum.GetValues(typeof(Status)).Cast<Status>() .Select(x => new SelectListItem() { Text = x.ToString(), Value = ((int)x).ToString(), Selected = status.HasValue && status.ToString() == x.ToString() }).ToList(); ViewBag.Categories = categories.Select(x => new SelectListItem() { Text = x.Name, Value = x.Id.ToString(), Selected = categoryId.HasValue && categoryId.Value == x.Id }); if (TempData["Result"] != null) { ViewBag.SuccessMsg = TempData["Result"]; } var data = await _productApiClient.GetProductPaging(request); return View(data.ResultObj); }
public async Task <IActionResult> Index(string keyword, int pageIndex = 1, int pageSize = 5) { var languageId = HttpContext.Session.GetString(SystemConstants.AppSettings.DefaultLanguageId); var request = new GetManageProductCategoryPagingRequest() { Keyword = keyword, PageIndex = pageIndex, PageSize = pageSize, LanguageId = languageId }; var data = await _categoryApiClient.GetPagings(request); ViewBag.Keyword = keyword; var categories = await _categoryApiClient.GetAll(languageId); // if (TempData["result"] != null) // { // ViewBag.SuccessMsg = TempData["result"]; // } TempData["TotalCategorys"] = data.TotalRecords; return(View(data)); }
public async Task <IViewComponentResult> InvokeAsync() { var items = await _categoryApiClient.GetAll(CultureInfo.CurrentCulture.Name); return(View("Default", items.ResultObj)); }
public async Task <IViewComponentResult> InvokeAsync() { var categories = await _categoryApiClient.GetAll(CultureInfo.CurrentCulture.Name); return(View(categories)); // Nếu khác Default.cshtml thì trả về View("abc", product) cho abc.cshtml }
public async Task <IActionResult> List() { var data = await _categoryApiClient.GetAll(); return(View(data)); }