public async Task <BaseComponent> Get(int id, ComponentTypeEnumeration type)
        {
            var query = GetQuery(type);

            LoadPictures(query, null);

            return(await query.FirstOrDefaultAsync(x => x.Id == id));
        }
        private async Task <BaseApiResponse <T> > Get <T>
            (string endpoint, ComponentTypeEnumeration type)
        {
            var dictionary = new Dictionary <string, object>();

            dictionary.Add("type", (int)type);
            return(await ApplicationHttpClient.HttpSendAsync <T>(CombineExtension.UrlCombine(BaseUrl, endpoint),
                                                                 queryParameters : dictionary));
        }
Пример #3
0
        public SearchComponentModal(Assembly assembly,
                                    ComponentTypeEnumeration type,
                                    IEnumerable <Firm> firms,
                                    IEnumerable <Lookup> lookups,
                                    GetUnitVM unitModel)
        {
            InitializeComponent();
            DialogResult = DialogResult.None;
            var searchList = new SearchComponentList(assembly, type, firms, lookups, unitModel);

            Controls.Add(searchList);
        }
Пример #4
0
        private async void GoToSearchPage(ComponentTypeEnumeration type)
        {
            var resultFirms = await APIContext.Options.GetFirms(type);

            var resultLookups = await APIContext.Options.GetLookups(type);

            var resultUnits = await APIContext.Options.GetUnits(type);

            if (resultFirms.Success && resultLookups.Success && resultUnits.Success)
            {
                var searchModal = new SearchComponentModal(Assembly, type, resultFirms.Data, resultLookups.Data, resultUnits.Data);
                var result      = searchModal.ShowDialog(this);
                if (result == DialogResult.OK)
                {
                    RefreshClicked?.Invoke(this, new EventArgs());
                }
            }
        }
        public GetUnitVM Get(ComponentTypeEnumeration type)
        {
            var units = new List <Unit>();

            switch (type)
            {
            case ComponentTypeEnumeration.CPU:
                SetCpuUnits(units);
                break;

            case ComponentTypeEnumeration.RAM:
                SetRamUnits(units);
                break;

            case ComponentTypeEnumeration.GPU:
                SetGpuUnits(units);
                break;

            case ComponentTypeEnumeration.PowerUnit:
                SetPowerUnitUnits(units);
                break;

            case ComponentTypeEnumeration.Motherboard:
                SetMotherboardUnits(units);
                break;

            case ComponentTypeEnumeration.HDD:
                SetHddUnits(units);
                break;

            case ComponentTypeEnumeration.SSD:
                SetSsdUnits(units);
                break;
            }

            return(new GetUnitVM
            {
                Type = type,
                TypeName = type.ToString(),
                Units = units
            });
        }
Пример #6
0
        private async void GoToSearchPage(ComponentTypeEnumeration type)
        {
            using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Loading..."))
            {
                var resultFirms = await APIContext.Options.GetFirms(type);

                var resultLookups = await APIContext.Options.GetLookups(type);

                var resultUnits = await APIContext.Options.GetUnits(type);

                if (resultFirms.Success && resultLookups.Success && resultUnits.Success)
                {
                    var searchPage = new SearchComponentPage(Assembly,
                                                             type,
                                                             resultFirms.Data,
                                                             resultLookups.Data,
                                                             resultUnits.Data);
                    await Navigation.PushModalAsync(searchPage);
                }
            }
        }
Пример #7
0
        public SearchComponentPage(Assembly assembly,
                                   ComponentTypeEnumeration type,
                                   IEnumerable <Firm> firms,
                                   IEnumerable <Lookup> lookups,
                                   GetUnitVM unitModel)
        {
            InitializeComponent();
            Assembly = assembly;

            ComponentTypeEnumeration = type;

            Search.Text     = $"Search {type.GetDescription()}";
            Search.Clicked += Search_Clicked;

            foreach (var unit in unitModel.Units)
            {
                switch (unit.UnitType)
                {
                case UnitType.CheckboxGroup:
                    var checkboxGroupOption = new CheckboxGroupOption(unit);
                    UnitList.Children.Add(checkboxGroupOption);
                    break;

                case UnitType.RadiobuttonGroup:
                    var radioButtonOption = new RadiobuttonGroupOption(unit);
                    UnitList.Children.Add(radioButtonOption);
                    break;

                case UnitType.Range:
                    var rangeOption = new RangeOption(unit);
                    UnitList.Children.Add(rangeOption);
                    break;

                case UnitType.Text:
                    foreach (var option in unit.Options)
                    {
                        var textInput = new TextOption(unit, option);
                        UnitList.Children.Add(textInput);
                    }
                    break;

                default:
                    break;
                }
            }

            var firmUnit = new Unit
            {
                Name     = "Firms",
                Key      = "firms",
                UnitType = UnitType.CheckboxGroup,
                Options  = firms.Select(x => new Option
                {
                    Key   = "firms",
                    Text  = $"{x.Name} ({x.Country})",
                    Value = x.Id
                })
            };
            var firmsOption = new CheckboxGroupOption(firmUnit);

            UnitList.Children.Add(firmsOption);

            foreach (var lookup in lookups)
            {
                var lookupUnit = new Unit
                {
                    Name     = lookup.Name,
                    Key      = lookup.Key,
                    UnitType = UnitType.CheckboxGroup,
                    Options  = lookup.LookupValues.Select(x => new Option
                    {
                        Key   = lookup.Key,
                        Text  = x.DisplayText,
                        Value = x.Id
                    })
                };
                var lookupOption = new CheckboxGroupOption(lookupUnit);
                UnitList.Children.Add(lookupOption);
            }
        }
 /// <summary>
 /// Method of getting units
 /// </summary>
 /// <param name="type">Component type</param>
 /// <returns>Returns units for search</returns>
 public async Task <BaseApiResponse <GetUnitVM> > GetUnits(ComponentTypeEnumeration type)
 => await Get <GetUnitVM>("unit", type);
 /// <summary>
 /// Method of getting firms
 /// </summary>
 /// <param name="type">Component type</param>
 /// <returns>Returns firms for search</returns>
 public async Task <BaseApiResponse <IEnumerable <Firm> > > GetFirms(ComponentTypeEnumeration type)
 => await Get <IEnumerable <Firm> >("firm", type);
 /// <summary>
 /// Method of getting lookups
 /// </summary>
 /// <param name="type">Component type</param>
 /// <returns>Returns lookups for search</returns>
 public async Task <BaseApiResponse <IEnumerable <Lookup> > > GetLookups(ComponentTypeEnumeration type)
 => await Get <IEnumerable <Lookup> >("lookup", type);
        protected IQueryable <BaseComponent> GetQuery(ComponentTypeEnumeration type)
        {
            var query = (IQueryable <BaseComponent>)null;

            switch (type)
            {
            case ComponentTypeEnumeration.CPU:
                query = AppContext.ComponentCPUs.Include(x => x.Firm)
                        .Include(x => x.Socket)
                        .ThenInclude(x => x.Lookup)
                        .Include(x => x.ProcessorFamily)
                        .ThenInclude(x => x.Lookup)
                        .Include(x => x.RAMType)
                        .ThenInclude(x => x.Lookup)
                        .Include(x => x.Process)
                        .ThenInclude(x => x.Lookup)
                        .AsQueryable();
                break;

            case ComponentTypeEnumeration.RAM:
                query = AppContext.ComponentRAMs.Include(x => x.Firm)
                        .Include(x => x.RAMType)
                        .ThenInclude(x => x.Lookup)
                        .Include(x => x.Timings)
                        .ThenInclude(x => x.Lookup)
                        .AsQueryable();
                break;

            case ComponentTypeEnumeration.GPU:
                query = AppContext.ComponentGPUs.Include(x => x.Firm)
                        .Include(x => x.Resolution)
                        .ThenInclude(x => x.Lookup)
                        .Include(x => x.GPUType)
                        .ThenInclude(x => x.Lookup)
                        .Include(x => x.GPUInterface)
                        .ThenInclude(x => x.Lookup)
                        .Include(x => x.PowerSupply)
                        .ThenInclude(x => x.Lookup)
                        .AsQueryable();
                break;

            case ComponentTypeEnumeration.PowerUnit:
                query = AppContext.ComponentPowerUnits.Include(x => x.Firm)
                        .Include(x => x.PowerSupports)
                        .ThenInclude(x => x.PowerConnection)
                        .ThenInclude(x => x.Lookup)
                        .AsQueryable();
                break;

            case ComponentTypeEnumeration.Motherboard:
                query = AppContext.ComponentMotherboards.Include(x => x.Firm)
                        .Include(x => x.Socket)
                        .ThenInclude(x => x.Lookup)
                        .Include(x => x.Chipset)
                        .ThenInclude(x => x.Lookup)
                        .Include(x => x.SizeFormFactor)
                        .ThenInclude(x => x.Lookup)
                        .Include(x => x.RAMType)
                        .ThenInclude(x => x.Lookup)
                        .Include(x => x.MotherboardInterfaces)
                        .ThenInclude(x => x.Interface)
                        .ThenInclude(x => x.Lookup)
                        .AsQueryable();
                break;

            case ComponentTypeEnumeration.HDD:
                query = AppContext.ComponentHDDs.Include(x => x.Firm)
                        .Include(x => x.ReadOnlyMemoryFormFactor)
                        .ThenInclude(x => x.Lookup)
                        .Include(x => x.Interface)
                        .ThenInclude(x => x.Lookup)
                        .AsQueryable();
                break;

            case ComponentTypeEnumeration.SSD:
                query = AppContext.ComponentSSDs.Include(x => x.Firm)
                        .Include(x => x.ReadOnlyMemoryFormFactor)
                        .ThenInclude(x => x.Lookup)
                        .Include(x => x.TypeOfCellMemory)
                        .ThenInclude(x => x.Lookup)
                        .Include(x => x.Interface)
                        .ThenInclude(x => x.Lookup)
                        .AsQueryable();
                break;

            case ComponentTypeEnumeration.CoolingSystem:
                break;

            case ComponentTypeEnumeration.Case:
                break;

            default:
                break;
            }
            return(query);
        }