public ServiceItemType(IRepositoryItemType iRepositoryProcurement) : base(iRepositoryProcurement) { }
private static void SeedPipe(UnitOfWorkProcurement unit, IRepositoryItem repItem, IRepositoryItemType repItemType, IRepositoryTemplateItem repTemplateItem, IRepositoryTemplateAttribute repTemplateAttribute , IRepositoryAttributeValue repAttributeValue) { //Pipe_catalogue.csv #region Pipe ItemType itemType = new ItemType() { Name = "Pipe" }; repItemType.Insert(itemType); TemplateAttribute spec = new TemplateAttribute() { Name = "Specification", Order = 1 }; TemplateAttribute grade = new TemplateAttribute() { Name = "Grade", Order = 2 }; TemplateAttribute nps = new TemplateAttribute() { Name = "NPS", Order = 3 }; TemplateAttribute thickness = new TemplateAttribute() { Name = "Thickness", Order = 54 }; TemplateAttribute welded = new TemplateAttribute() { Name = "Welded/Seamless", Order = 5 }; TemplateAttribute kg = new TemplateAttribute() { Name = "Kg/m", Order = 6 }; //UNSPSC Code;Specification;Grade;NPS;Thickness;Welded/Seamless;Kg/m List <TemplateAttribute> attributes = new List <TemplateAttribute>() { spec, grade, nps, thickness, welded, kg, new TemplateAttribute() { Name = "Reference standard", Order = 7 }, new TemplateAttribute() { Name = "Rating class", Order = 8 }, new TemplateAttribute() { Name = "Material Specification", Order = 9 }, new TemplateAttribute() { Name = "Endings", Order = 10 }, }; repTemplateAttribute.InsertRange(attributes); TemplateItem pipe = new TemplateItem() { Name = "Pipe", ItemType = itemType, ModelAttributes = attributes }; repTemplateItem.Insert(pipe); IEnumerable <string> lines = System.IO.File.ReadLines(@"C:\Proc\Pipe_catalogue.csv"); int count = 1; foreach (var line in lines) { string[] columnsValues = null; if (count == 1) { columnsValues = line.Split(';'); } else { columnsValues = line.Split(';'); Item item = new Item() { Template = pipe, UNSPSC = columnsValues[0] }; repItem.Insert(item); unit.SaveChanges(); List <AttributeValue> listAttrValues = new List <AttributeValue>() { new AttributeValue() { Item = item, TemplateAttribute = spec, Value = columnsValues[1] }, new AttributeValue() { Item = item, TemplateAttribute = grade, Value = columnsValues[2] }, new AttributeValue() { Item = item, TemplateAttribute = nps, Value = columnsValues[3] }, new AttributeValue() { Item = item, TemplateAttribute = thickness, Value = columnsValues[4] }, new AttributeValue() { Item = item, TemplateAttribute = welded, Value = columnsValues[5] }, new AttributeValue() { Item = item, TemplateAttribute = kg, Value = columnsValues[6] } }; repAttributeValue.InsertRange(listAttrValues); item.AttributeValues = listAttrValues; repItem.Update(item); } count++; if (count >= 700) { break; } } #endregion }