public List <D_ATTRIBUTE_VALUE> GetAttributeValues(int AttributeId) { return(_attributeDAO.GetAttributeValues(AttributeId)); }
private void setAttributes(List <CATEGORY> categoriesList, PRODUCT product, FZExcelProduct exProd) { // TODO when different attributes used, this should be changed to be dynamic! int?sizeAttribute = categoriesList.FirstOrDefault().AttributeID; List <D_ATTRIBUTE_VALUE> attrValueList = _attributeDAO.GetAttributeValues(sizeAttribute.Value); PRODUCT_ATTRIBUTE prodAttr; int availability = 0; int attrValId = 0; // TODO this should be generalized for other attributes // XS size if (int.TryParse(exProd.SizeXS, out availability) && availability != 0) { attrValId = attrValueList.Where(a => a.Value.Equals("XS")).FirstOrDefault().ID; prodAttr = new PRODUCT_ATTRIBUTE() { AttributeValueID = attrValId, ProductID = product.ID, Availability = availability, Quantity = availability, }; AddProductAttribute(prodAttr); } // S size if (int.TryParse(exProd.SizeS, out availability) && availability != 0) { attrValId = attrValueList.Where(a => a.Value.Equals("S")).FirstOrDefault().ID; prodAttr = new PRODUCT_ATTRIBUTE() { AttributeValueID = attrValId, ProductID = product.ID, Availability = availability, Quantity = availability, }; AddProductAttribute(prodAttr); } // M size if (int.TryParse(exProd.SizeM, out availability) && availability != 0) { attrValId = attrValueList.Where(a => a.Value.Equals("M")).FirstOrDefault().ID; prodAttr = new PRODUCT_ATTRIBUTE() { AttributeValueID = attrValId, ProductID = product.ID, Availability = availability, Quantity = availability, }; AddProductAttribute(prodAttr); } // L size if (int.TryParse(exProd.SizeL, out availability) && availability != 0) { attrValId = attrValueList.Where(a => a.Value.Equals("L")).FirstOrDefault().ID; prodAttr = new PRODUCT_ATTRIBUTE() { AttributeValueID = attrValId, ProductID = product.ID, Availability = availability, Quantity = availability, }; AddProductAttribute(prodAttr); } // XL size if (int.TryParse(exProd.SizeXL, out availability) && availability != 0) { attrValId = attrValueList.Where(a => a.Value.Equals("XL")).FirstOrDefault().ID; prodAttr = new PRODUCT_ATTRIBUTE() { AttributeValueID = attrValId, ProductID = product.ID, Availability = availability, Quantity = availability, }; AddProductAttribute(prodAttr); } // XXL size if (int.TryParse(exProd.SizeXXL, out availability) && availability != 0) { attrValId = attrValueList.Where(a => a.Value.Equals("XXL")).FirstOrDefault().ID; prodAttr = new PRODUCT_ATTRIBUTE() { AttributeValueID = attrValId, ProductID = product.ID, Availability = availability, Quantity = availability, }; AddProductAttribute(prodAttr); } }