public IEnumerable <PcPart> GetPartsByType(Build build, PcPart.PcType latestType) { var selectedType = latestType == PcPart.PcType.Null ? PcPart.PcType.Case : _pcBuildRepository.GetSelectedType(latestType); var propertyIds = new List <int>(); if (build != null) { switch (selectedType) { case PcPart.PcType.Processor: propertyIds.Add(build.Cpu); break; case PcPart.PcType.RAM: propertyIds.Add(build.RAM); break; case PcPart.PcType.Memory: propertyIds.Add(build.Memory); break; case PcPart.PcType.Power: propertyIds.Add(build.Power); break; } } return(_pcBuildRepository.GetAllByType(selectedType, propertyIds).AsList()); }
public PcPart.PcType GetSelectedType(PcPart.PcType latestType) { List <PcPart.PcType> types = Enum.GetValues(typeof(PcPart.PcType)).Cast <PcPart.PcType>().ToList(); int selectedTypeNumber = types.FindIndex(x => x == latestType) + 1; return(types.ElementAt(selectedTypeNumber)); }
public PcPart.PcType GetSelectedType(PcPart.PcType latestType) { using (IDbConnection db = OpenConnection()) { db.Open(); return(Enum.Parse <PcPart.PcType>(db.QuerySingle <string>("GetCurrentType", new { lastType = latestType.ToString() }, commandType: CommandType.StoredProcedure))); } }
public int GetProgress(PcPart.PcType currentType) { decimal maxProgress = _pcBuildRepository.GetMaxProgress(); decimal currentProgress = _pcBuildRepository.GetCurrentProgress(currentType); decimal answer = currentProgress / maxProgress * 100; return(Convert.ToInt32(answer)); }
public int GetCurrentProgress(PcPart.PcType currentType) { using (IDbConnection db = OpenConnection()) { db.Open(); string query = $"SELECT PriorityID FROM ComponentTypes WHERE _Type = '{currentType}'"; return(db.QuerySingle <int>(query)); } }
public int GetCurrentProgress(PcPart.PcType currentType) { Dictionary <PcPart.PcType, int> progresses = new Dictionary <PcPart.PcType, int> { [PcPart.PcType.Case] = 1, [PcPart.PcType.Motherboard] = 2, [PcPart.PcType.Processor] = 3, [PcPart.PcType.CPU_Cooling] = 4, [PcPart.PcType.RAM] = 5, [PcPart.PcType.RAM] = 6, [PcPart.PcType.Power] = 7 }; progresses.TryGetValue(currentType, out int id); return(id); }
public IEnumerable <PcPart> GetAllByType(PcPart.PcType type, List <int> propertyIds) { if (propertyIds.Count == 0) { return(_pcParts.FindAll(x => x._Type == type)); } List <PcPart> parts = new List <PcPart>(); foreach (int id in propertyIds) { parts.AddRange(_pcParts.FindAll(x => x._Type == type && x.Properties.FindAll(y => y.Id == id).Count != 0)); } return(parts); }
public IEnumerable <PcPart> GetAllByType(PcPart.PcType type, List <int> propertyIds) { using (IDbConnection db = OpenConnection()) { db.Open(); string query; if (propertyIds.Count != 0) { var propertyIdQuery = new List <string>(); for (var i = 0; i < propertyIds.Count; i++) { propertyIdQuery.Add($"pa.propertieId = {propertyIds[i]}"); if (i < propertyIds.Count - 1) { propertyIdQuery.Add("OR"); } } query = $"SELECT p.Id, p._Name, p._Type, p.Information, f._Path FROM Parts p, Part_Prop pa, Files f WHERE p.FileID = f.Id AND pa.PartID = p.Id AND p._Type = '{type}' AND ({string.Join(' ', propertyIdQuery)})"; } else { query = $"SELECT p.Id, p._Name, p._Type, p.Information, f._Path FROM Parts p, Files f WHERE p.FileID = f.Id AND _Type = '{type}'"; } var parts = db.Query <PcPart>(query); foreach (var part in parts) { part.Properties = GetPropertiesForPcPart(part).AsList(); } return(parts); } }
public int GetCurrentProgress(PcPart.PcType currentType) => _pcBuildContext.GetCurrentProgress(currentType);
public PcPart.PcType GetSelectedType(PcPart.PcType latestType) => _pcBuildContext.GetSelectedType(latestType);
public IEnumerable <PcPart> GetAllByType(PcPart.PcType type, List <int> propertyIds) => _pcBuildContext.GetAllByType(type, propertyIds);