public async Task OnGet() { if (Id.HasValue) { PrimaryData = await repository.GetPrimaryData(); Product = await repository.GetProduct(Id.Value); } }
public async Task OnGet() { if (FilterData.CategoryId.HasValue) { PrimaryData = await repository.GetPrimaryData(); Products = await repository.GetExtraProducts(FilterData); } }
public async Task OnGet() { if (FilterData.Count.HasValue) { Response.Cookies.Append("products-count", FilterData.Count.ToString(), new CookieOptions { Expires = DateTime.Now.AddMonths(1) }); } else if (Request.Cookies.ContainsKey("products-count")) { FilterData.Count = Convert.ToInt32(Request.Cookies["products-count"]); } if (FilterData.ViewType.HasValue) { Response.Cookies.Append("view-type", FilterData.ViewType.ToString(), new CookieOptions { Expires = DateTime.Now.AddMonths(1) }); } else if (Request.Cookies.ContainsKey("view-type")) { FilterData.ViewType = Enum.Parse <ViewType>(Request.Cookies["view-type"]); } else { FilterData.ViewType = ViewType.ListView; // Default value } if (FilterData.Sort.HasValue) { Response.Cookies.Append("sort", FilterData.Sort.ToString(), new CookieOptions { Expires = DateTime.Now.AddMonths(1) }); } else if (Request.Cookies.ContainsKey("sort")) { FilterData.Sort = Enum.Parse <SortType>(Request.Cookies["sort"]); } if (Request.Cookies.ContainsKey("picture-size")) { if (int.TryParse(Request.Cookies["picture-size"], out int pictureSize)) { PictureSize = pictureSize; } else { Response.Cookies.Delete("picture-size"); } } PrimaryData = await repository.GetPrimaryData(); Data = await repository.GetProducts(FilterData); }
public override void Prepare(ActionsViewModelNavigationParams parameter) { DashCamActions = parameter?.DashCamActions; if (DashCamActions != null) { PrimaryData.AddRange(DashCamActions.Actions); } }
/// <summary> /// Searches the data for any matching actions. /// </summary> /// <param name="search">The search.</param> public void Search(string search) { if (DashCamActions == null) { return; } PrimaryData.SwitchTo(DashCamActions.Actions.Where(a => a.Title.StartsWith(search, StringComparison.CurrentCultureIgnoreCase)) ?? DashCamActions.Actions); IsDataEmpty = CalculateIsDataEmpty(); }
public void LeftJoinTests() { List <PrimaryData> primaryDatas = PrimaryData.CreateTestList(); List <OtherData> otherDatas = OtherData.CreateTestList(); var result1 = primaryDatas.AsQueryable().LeftJoin(otherDatas, l => l.NumberPd, i => i.NumberOd, (l, i) => new { Pdn = l.NumberPd, Pds = l.StringPd, Odn = i?.NumberOd, Ods = i?.StringOd }) .ToList(); TestAsserts.NumberLeftJoin(result1); var result2 = primaryDatas.AsQueryable().LeftJoin(otherDatas, l => new { K1 = (int?)l.NumberPd, K2 = l.StringPd }, i => new { K1 = i.NumberOd, K2 = i.StringOd }, (l, i) => new { Pdn = l.NumberPd, Pds = l.StringPd, Odn = i?.NumberOd, Ods = i?.StringOd }) .ToList(); TestAsserts.NumberStringLeftJoin(result2); }
public void LeftJoinTests() { List<PrimaryData> primaryDatas = PrimaryData.CreateTestList(); List<OtherData> otherDatas = OtherData.CreateTestList(); var result1 = primaryDatas.AsQueryable().LeftJoin(otherDatas.AsQueryable(), "NumberPd", "NumberOd", new List<string>() { "NumberPd AS Pdn", "StringPd AS Pds" }, new List<string>() { "NumberOd AS Odn", "StringOd AS Ods" }) .ToDynamicList(); TestAsserts.NumberLeftJoin(result1); var result2 = primaryDatas.AsQueryable().LeftJoin(otherDatas.AsQueryable(), " new { Int?(NumberPd) AS K1, StringPd AS K2}", " new { NumberOd AS K1, StringOd AS K2}", new List<string>() { "NumberPd AS Pdn", "StringPd AS Pds" }, new List<string>() { "NumberOd AS Odn", "StringOd AS Ods" }) .ToDynamicList(); TestAsserts.NumberStringLeftJoin(result2); }
private async Task <PrimaryData> GetPrimaryDataFromDb() { string connectionString = configuration.GetConnectionString("Default"); var commandText = "GetPrimaryData"; var command = new CommandDefinition(commandText, commandType: CommandType.StoredProcedure); var primaryData = new PrimaryData(); try { IEnumerable <DkbRaj> rajs; IEnumerable <TieLength> tieLengths; IEnumerable <Layout> layouts; IEnumerable <TieType> tieTypes; IEnumerable <SendMethod> sendMethods; IEnumerable <Setting> settings; IEnumerable <Message> messages; IEnumerable <PlanType> planTypes; IEnumerable <Material> materials; IEnumerable <Models.Entities.Attribute> attributes; IEnumerable <ExtraCategory> extraCategories; using (SqlConnection connection = new SqlConnection(connectionString)) { var result = await connection.QueryMultipleAsync(command); var dic = new Dictionary <int, DkbRaj>(); rajs = result.Read <DkbRaj, MaterialRaj, DkbRaj>((r, mr) => { if (!dic.TryGetValue(r.Raj, out DkbRaj dkbRaj)) { dkbRaj = r; dkbRaj.MaterialRajs = new List <MaterialRaj>(); dic.Add(dkbRaj.Raj, dkbRaj); } dkbRaj.MaterialRajs.Add(mr); return(dkbRaj); }).Distinct(); tieLengths = await result.ReadAsync <TieLength>(); layouts = await result.ReadAsync <Layout>(); tieTypes = await result.ReadAsync <TieType>(); sendMethods = await result.ReadAsync <SendMethod>(); settings = await result.ReadAsync <Setting>(); messages = await result.ReadAsync <Message>(); planTypes = await result.ReadAsync <PlanType>(); materials = await result.ReadAsync <Material>(); attributes = await result.ReadAsync <Models.Entities.Attribute>(); extraCategories = await result.ReadAsync <ExtraCategory>(); } primaryData.Rajs = rajs.ToDictionary(a => a.Raj); primaryData.TieLengths = tieLengths.ToDictionary(a => a.Id); primaryData.Layouts = layouts.ToDictionary(a => a.Id, b => b.Name); primaryData.TieTypes = tieTypes.ToDictionary(a => a.Id, b => b.Name); primaryData.SendMethods = sendMethods.ToDictionary(a => a.Id); primaryData.Settings = settings.ToDictionary(a => a.Name, b => b.Value); primaryData.Messages = messages.ToDictionary(a => a.Title, b => b.Context); primaryData.PlanTypes = planTypes.ToDictionary(a => a.Id, b => b.Name); primaryData.Materials = materials.ToDictionary(a => a.Id); primaryData.Attributes = attributes.ToDictionary(a => a.Id); primaryData.ExtraCategories = extraCategories.ToDictionary(a => a.Id); primaryData.Sizes = new List <Size>() { new Size() { Id = 1, Title = "زیر یک متر مربع - ذرع و چهارک", Limits = "0,1" }, new Size() { Id = 2, Title = "یک تا دومتر مربع - ذرع و نیم", Limits = "1,2" }, new Size() { Id = 3, Title = "دو تا چهار متر مربع - قالیچه", Limits = "2,4" }, new Size() { Id = 4, Title = "چهار تا هفت متر مربع", Limits = "4,7" }, new Size() { Id = 5, Title = "هفت تا ده متر مربع", Limits = "7,10" }, new Size() { Id = 6, Title = "بیشتر از ده متر مربع", Limits = "10," } }; } catch (Exception ex) { logger.LogError(ex.GetExceptionMessage()); return(null); } return(primaryData); }