/// <summary> /// map item from presentation layer to business layer /// </summary> /// <param name="itemToMap"></param> /// <returns></returns> private BLLProduct PLProductToBLLProduct(PLProduct itemToMap) { BLLJewType mapJewType = new BLLJewType() { Name = itemToMap.JewType.Name }; List <BLLGemstone> mapGemstones = new List <BLLGemstone>(); //send information about price of each gemstone if (itemToMap.Gemstone != null) { foreach (var gem in itemToMap.Gemstone) { mapGemstones.Add(new BLLGemstone() { Name = gem.Name, Size = gem.Size, Colour = gem.Colour, Price = gem.Price }); } } // no information about product price BLLProduct bllProduct = new BLLProduct() { Name = itemToMap.Name, JewTypeId = itemToMap.JewTypeId, JewType = mapJewType, Gemstone = mapGemstones }; //i dont know: shoul I for each BLLGemstone assign bllProduct as product? return(bllProduct); }/// <summary>
public IEnumerable <BLLProduct> GetByType(BLLJewType type) { JewType searchForType = BLLJewTypeToJewType(type); JewType searchResultJewTypeInDB = _myJewStore.SearchByJewType(searchForType); if (searchResultJewTypeInDB != null) { var searchProductTypeInDB = _myJewStore.GetByType(searchResultJewTypeInDB); if (searchProductTypeInDB != null) { List <BLLProduct> searchProductByType = new List <BLLProduct>(); foreach (var item in searchProductTypeInDB) { searchProductByType.Add(ProductToBLLProduct(item)); } return(searchProductByType); } else { Console.WriteLine("No items of such type"); return(null); } } else { Console.WriteLine("This type diesnt exist in DB"); return(null); } }
private BLLProduct ProductToBLLProduct(Product itemToMap) { BLLJewType mapJewType = new BLLJewType() { Id = itemToMap.JewType.Id, Name = itemToMap.JewType.Name }; List <BLLGemstone> mapGemstones = new List <BLLGemstone>(); if (itemToMap.Gemstone != null) { foreach (var gem in itemToMap.Gemstone) { mapGemstones.Add(new BLLGemstone() { Id = gem.Id, Name = gem.Name, Size = gem.Size, Colour = gem.Colour }); } } BLLProduct bllProduct = new BLLProduct() { Id = itemToMap.Id, Name = itemToMap.Name, Price = itemToMap.Price, JewTypeId = itemToMap.JewTypeId, JewType = mapJewType, Gemstone = mapGemstones }; //i dont know: shoul I for each BLLGemstone assign bllProduct as product? return(bllProduct); }
/// <summary> /// map jewerly type from presentation level to business level /// </summary> /// <param name="itemToMap"></param> /// <returns></returns> private BLLJewType PLJewTypeToBLLJewType(PLJewType itemToMap) { BLLJewType mapJewType = new BLLJewType() { Name = itemToMap.Name }; return(mapJewType); }
private JewType BLLJewTypeToJewType(BLLJewType itemToMap) { JewType mapJewType = new JewType() { Id = itemToMap.Id, Name = itemToMap.Name }; return(mapJewType); }
public IEnumerable <PLProduct> GetByType(PLJewType jewType) { if (jewType == null) { Console.WriteLine("Cant define type"); return(null); } BLLJewType typeToDefine = PLJewTypeToBLLJewType(jewType); var bllProductByType = _jewService.GetByType(typeToDefine); if (bllProductByType != null) { List <PLProduct> plProductByType = new List <PLProduct>(); foreach (var item in bllProductByType) { plProductByType.Add(BLLProductToPLProduct(item)); } return(plProductByType); } return(null); }