public IEnumerable <PurposeDTO> GetPurposesByCharValues(Guid categoryId, IEnumerable <CharValueDTO> filterCharValues) { var characteristicIdList = filterCharValues.Select(f => f.CharacteristicId).Distinct().ToList(); //TO DO var purposes = _purposeRepository.GetWithInclude( x => x.Item.CategoryID == categoryId && x.Item.ItemCharacteristics.Where( ic => characteristicIdList.Contains((Guid)ic.CharacteristicID) && filterCharValues.Any(f => f.Id == (Guid)ic.CharValueID)).Count() >= characteristicIdList.Count, y => y.Item, y => y.Item.Brand, y => y.Item.Category, y => y.Item.ItemCharacteristics); var purposeDTOList = new List <PurposeDTO>(); foreach (var i in purposes) { var purposeDTO = new PurposeDTO(); purposeDTO.PurposeID = i.Id; purposeDTO.CategoryID = categoryId; purposeDTO.Name = i.Item.Name; purposeDTO.Brand = i.Item.Brand.Name; purposeDTO.Curency = GetPurposePriceByPuposeID(purposeDTO.PurposeID).Curency.Name; purposeDTO.Price = (double)GetPurposePriceByPuposeID(purposeDTO.PurposeID).Price; purposeDTO.CategoryName = i.Item.Category.Name; purposeDTOList.Add(purposeDTO); } return(purposeDTOList); }
public static List <PurposeDTO> FindAll() { var purposeDTO = new PurposeDTO(); purposeDTO.Id = "PP0"; purposeDTO.Name = "Không biết"; var result = purposeDAL.FindAll(); result.Add(purposeDTO); return(result); }
public PurposeDTO GetPurposeByID(Guid purposeID) { var purpose = _purposeRepository.GetWithInclude(x => x.Id == purposeID, y => y.Item, y => y.Item.Brand, y => y.Item.Category).FirstOrDefault(); var buff = new PurposeDTO(); buff.PurposeID = purpose.Id; buff.CategoryID = purpose.Item.Category.Id; buff.Name = purpose.Item.Name; buff.Brand = purpose.Item.Brand.Name; buff.Curency = GetPurposePriceByPuposeID(buff.PurposeID).Curency.Name; buff.Price = (double)GetPurposePriceByPuposeID(buff.PurposeID).Price; buff.CategoryName = purpose.Item.Category.Name; buff.Description = purpose.Item.Description; var _temp = GetCharacterististicByItemId(purpose.Item.Id); buff.CharName = new List <string>(); buff.CharValue = new List <string>(); foreach (ItemCharacteristic item in _temp) { var charval = ""; if (item.CharValue.IntVal != null) { charval = item.CharValue.IntVal.ToString(); } if (item.CharValue.FloatVal != null) { charval = item.CharValue.FloatVal.ToString(); } if (item.CharValue.StrVal != null) { charval = item.CharValue.StrVal; } buff.CharName.Add(item.Characteristic.Name); buff.CharValue.Add(charval); } return(buff); }
public IEnumerable <PurposeDTO> GetPurposesByCategoryID(Guid categoryID) { var purposeList = _purposeRepository.GetWithInclude(x => x.Item.CategoryID == categoryID, y => y.Item, y => y.Item.Brand, y => y.Item.Category); var purposesDTOList = new List <PurposeDTO>(); foreach (var i in purposeList) { var buff = new PurposeDTO(); buff.PurposeID = i.Id; buff.CategoryID = categoryID; buff.Name = i.Item.Name; buff.Brand = i.Item.Brand.Name; buff.Curency = GetPurposePriceByPuposeID(buff.PurposeID).Curency.Name; buff.Price = (double)GetPurposePriceByPuposeID(buff.PurposeID).Price; buff.CategoryName = i.Item.Category.Name; purposesDTOList.Add(buff); buff = null; } return(purposesDTOList); }
private void btnCounselling_Click(object sender, EventArgs e) { dgvResult.DataSource = null; var assumptions = new List <string>(); PurposeDTO purpose = (PurposeDTO)cbbPurpose.SelectedItem; BrandDTO brand = (BrandDTO)cbbBrand.SelectedItem; PriceDTO price = (PriceDTO)cbbPrice.SelectedItem; ColorDTO color = (ColorDTO)cbbColor.SelectedItem; ObjectUsingDTO objectUsing = (ObjectUsingDTO)cbbObjectUsing.SelectedItem; GenderDTO gender = (GenderDTO)cbbGender.SelectedItem; if (color.Id.Equals("CL0")) { assumptions.Add(gender.Id.Trim()); } else { assumptions.Add(color.Id.Trim()); } if (brand.Id.Equals("BR0")) { assumptions.Add(purpose.Id.Trim()); } else { assumptions.Add(brand.Id.Trim()); } if (price.Id.Equals("PR0")) { assumptions.Add(objectUsing.Id.Trim()); } else { assumptions.Add(price.Id.Trim()); } if (assumptions.Count < 3) { MessageBox.Show("Bạn cần trả lời thêm câu hỏi để chúng tôi tư vấn!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } /*if (assumptions.Contains("OS1") && assumptions.Contains("BR4")) * { * MessageBox.Show("Bạn cần nhập lại hãng điện thoại hoặc hệ điều hành vì Apple không phải là hệ điều hành Android!", "Lỗi", * MessageBoxButtons.OK, MessageBoxIcon.Error); * return; * }*/ if (assumptions.Contains("OS2") && !assumptions.Contains("BR4")) { MessageBox.Show("Bạn cần nhập lại hãng điện thoại hặc hệ điều hành!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var mobiles = ForwardChainingUtil.Result(assumptions); if (mobiles.Count == 0) { MessageBox.Show("Chúng tôi xin lỗi vì không có loại điện thoại theo mô tả của bạn!", "Thông tin", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } this.dgvResult.Visible = true; pnResult.Visible = true; this.dgvResult.DataSource = mobiles; this.dgvResult.Columns["Id"].Visible = false; }