public void OnGet(int?id) { catalogParamVm = new CatalogParamVm { Range = 0, PartId = id ?? 0 }; }
public void OnGet() { catalogParamVm = new CatalogParamVm { PartId = 0, Range = 8 }; }
public async Task <IViewComponentResult> InvokeAsync(CatalogParamVm catalogParam) { if (catalogParam.PartId == 0) { if (catalogParam.Range != 0) { var rnd = new Random(); int skipRnd = rnd.Next(1, catalogItems.Count() - catalogParam.Range); return(await Task.FromResult <IViewComponentResult>(View(catalogItems.Skip(Convert.ToInt32(skipRnd)).Take(catalogParam.Range)))); } else { return(await Task.FromResult <IViewComponentResult>(View(catalogItems))); } } else { return(await Task.FromResult <IViewComponentResult>(View(catalogItems.Where(c => c.Id == catalogParam.PartId)))); } }
public void OnGet(int id) { catalogParamVm = new CatalogParamVm { Range = 4 }; PcPart = WebApiHelper.GetApiResult <PcPartItem>(BaseUri + "pcparts/basic/" + id); switch (PcPart.Type) { case "Cpu": Part = WebApiHelper.GetApiResult <Cpu>(BaseUri + "pcparts/PartByPartId/" + id) ?? new Cpu { }; Properties = Part.GetType().GetProperties(); break; case "Gpu": Part = WebApiHelper.GetApiResult <Gpu>(BaseUri + "pcparts/PartByPartId/" + id) ?? new Gpu(); Properties = Part.GetType().GetProperties(); break; case "PcCase": Part = WebApiHelper.GetApiResult <PcCase>(BaseUri + "pcparts/PartByPartId/" + id) ?? new PcCase(); Properties = Part.GetType().GetProperties(); break; case "Memory": Part = WebApiHelper.GetApiResult <Memory>(BaseUri + "pcparts/PartByPartId/" + id) ?? new Memory(); Properties = Part.GetType().GetProperties(); break; case "MotherBoard": Part = WebApiHelper.GetApiResult <MotherBoard>(BaseUri + "pcparts/PartByPartId/" + id) ?? new MotherBoard(); Properties = Part.GetType().GetProperties(); break; default: Properties = null; break; } }