public static void Main() { ProcurementContext db = new ProcurementContext(); UnitOfWorkProcurement unit = new UnitOfWorkProcurement(db); // InitialSeed(db,unit); IRepositoryItem rep = new RepositoryItem(db, unit); IRepositoryAttributeValue repAV = new RepositoryAttributeValue(db, unit); IRepositoryCustumerOrderItem repositoryCustumerOrderItem = new RepositoryCustumerOrderItem(db, unit); IRepositorySupplierOffer repositorySupplierOffer = new RepositorySupplierOffer(db, unit); var items = rep.Queryable().ToList(); int count = 1; foreach (var item in items) { item.UNSPSC = item.UNSPSC + "-" + count.ToString().PadLeft(4, '0'); rep.Update(item); count++; } unit.SaveChanges(); //Item i = rep.Find(781); //var ass = repositoryCustumerOrderItem.Queryable().Where(o => o.Item.ID == i.ID).ToList(); //foreach (var a in ass) //{ // repositoryCustumerOrderItem.Delete(a); //} //unit.SaveChanges(); //var as2 = repositorySupplierOffer.Queryable().Where(o => o.Item.ID == i.ID).ToList(); //foreach (var a in as2) //{ // repositorySupplierOffer.Delete(a); //} //rep.Delete(i); //count = 0; // SeedTemplateItems(db, unit); //IRepositorySupplierInfo repS = new RepositorySupplierInfo(db, unit); //IRepositoryUser repU = new RepositoryUser(db, unit); //IRepositoryItem repI = new RepositoryItem(db, unit); //User u = new User() //{ // Name = "Custumer 1", // Email = "*****@*****.**", // UserType = Model.Enums.UserType.Supplier, // Password = "******" //}; //repU.Insert(u); //IRepositoryRole repRole = new RepositoryRole(db, unit); //IServiceRole serviceRole = new ServiceRole(repRole); //string roleName = "Supplier"; //serviceRole.AddUserOnRole(roleName, u); //SupplierInfo SupplierInto = new SupplierInfo() //{ // User = u //}; //repS.Insert(SupplierInto); //Item item = repI.Queryable().FirstOrDefault(); //SupplierOffer offer = new SupplierOffer() //{ // Item = item, // Price = 5000.0, // ProvidedDateDelivery = new DateTime(2017, 07, 26), // SupplierInfo = SupplierInto //}; //IRepositorySupplierOffer repOffer = new RepositorySupplierOffer(db, unit); // repOffer.Insert(offer); //var offer = repOffer.Queryable().FirstOrDefault(); unit.SaveChanges(); }
private static void SeedTemplateItems(ProcurementContext db, UnitOfWorkProcurement unit) { //Half couplimg //Cross //45º lateral //Flange //Para quase todos eles vale a seguinte lista de atributos: // Code(UNSPSC) //Description //Reference standard(e.g.ASME B 16.4) //Diameter ou NPS(no caso das reduções são dois diâmetros) //Rating class (e.g. 150 lbs) //Material Specification //Grade //Endings //Thickness IRepositoryItemType repItemType = new RepositoryItemType(db, unit); IRepositoryTemplateItem repTemplateItem = new RepositoryTemplateItem(db, unit); IRepositoryTemplateAttribute repTemplateAttribute = new RepositoryTemplateAttribute(db, unit); IRepositoryItem repItem = new RepositoryItem(db, unit); IRepositoryAttributeValue repAttributeValue = new RepositoryAttributeValue(db, unit); SeedPipe(unit, repItem, repItemType, repTemplateItem, repTemplateAttribute, repAttributeValue); #region Elbow ItemType itemType = new ItemType() { Name = "Elbow" }; repItemType.Insert(itemType); List <TemplateAttribute> attributes = new List <TemplateAttribute>() { new TemplateAttribute() { Name = "Reference standard", Order = 1 }, new TemplateAttribute() { Name = "NPS", Order = 2 }, new TemplateAttribute() { Name = "Rating class", Order = 3 }, new TemplateAttribute() { Name = "Material Specification", Order = 4 }, new TemplateAttribute() { Name = "Grade", Order = 5 }, new TemplateAttribute() { Name = "Endings", Order = 6 }, new TemplateAttribute() { Name = "Thickness", Order = 7 }, }; repTemplateAttribute.InsertRange(attributes); TemplateItem templateItem = new TemplateItem() { Name = "Elbow 90°", ItemType = itemType, ModelAttributes = attributes }; repTemplateItem.Insert(templateItem); attributes = new List <TemplateAttribute>() { new TemplateAttribute() { Name = "Reference standard", Order = 1 }, new TemplateAttribute() { Name = "NPS", Order = 2 }, new TemplateAttribute() { Name = "Rating class", Order = 3 }, new TemplateAttribute() { Name = "Material Specification", Order = 4 }, new TemplateAttribute() { Name = "Grade", Order = 5 }, new TemplateAttribute() { Name = "Endings", Order = 6 }, new TemplateAttribute() { Name = "Thickness", Order = 7 }, }; repTemplateAttribute.InsertRange(attributes); templateItem = new TemplateItem() { Name = "Elbow 90º Long Radius", ItemType = itemType, ModelAttributes = attributes }; repTemplateItem.Insert(templateItem); attributes = new List <TemplateAttribute>() { new TemplateAttribute() { Name = "Reference standard", Order = 1 }, new TemplateAttribute() { Name = "NPS", Order = 2 }, new TemplateAttribute() { Name = "Rating class", Order = 3 }, new TemplateAttribute() { Name = "Material Specification", Order = 4 }, new TemplateAttribute() { Name = "Grade", Order = 5 }, new TemplateAttribute() { Name = "Endings", Order = 6 }, new TemplateAttribute() { Name = "Thickness", Order = 7 }, }; repTemplateAttribute.InsertRange(attributes); templateItem = new TemplateItem() { Name = "Elbow 45º", ItemType = itemType, ModelAttributes = attributes }; repTemplateItem.Insert(templateItem); #endregion #region Tee itemType = new ItemType() { Name = "Tee" }; repItemType.Insert(itemType); attributes = new List <TemplateAttribute>() { new TemplateAttribute() { Name = "Reference standard", Order = 1 }, new TemplateAttribute() { Name = "NPS", Order = 2 }, new TemplateAttribute() { Name = "Rating class", Order = 3 }, new TemplateAttribute() { Name = "Material Specification", Order = 4 }, new TemplateAttribute() { Name = "Grade", Order = 5 }, new TemplateAttribute() { Name = "Endings", Order = 6 }, new TemplateAttribute() { Name = "Thickness", Order = 7 }, }; repTemplateAttribute.InsertRange(attributes); templateItem = new TemplateItem() { Name = "Tee", ItemType = itemType, ModelAttributes = attributes }; repTemplateItem.Insert(templateItem); #endregion #region Reducer itemType = new ItemType() { Name = "Reducer" }; repItemType.Insert(itemType); attributes = new List <TemplateAttribute>() { new TemplateAttribute() { Name = "Reference standard", Order = 1 }, new TemplateAttribute() { Name = "NPS", Order = 2 }, new TemplateAttribute() { Name = "Rating class", Order = 3 }, new TemplateAttribute() { Name = "Material Specification", Order = 4 }, new TemplateAttribute() { Name = "Grade", Order = 5 }, new TemplateAttribute() { Name = "Endings", Order = 6 }, new TemplateAttribute() { Name = "Thickness", Order = 7 }, }; repTemplateAttribute.InsertRange(attributes); templateItem = new TemplateItem() { Name = "Reducer Concentric", ItemType = itemType, ModelAttributes = attributes }; repTemplateItem.Insert(templateItem); attributes = new List <TemplateAttribute>() { new TemplateAttribute() { Name = "Reference standard", Order = 1 }, new TemplateAttribute() { Name = "NPS", Order = 2 }, new TemplateAttribute() { Name = "Rating class", Order = 3 }, new TemplateAttribute() { Name = "Material Specification", Order = 4 }, new TemplateAttribute() { Name = "Grade", Order = 5 }, new TemplateAttribute() { Name = "Endings", Order = 6 }, new TemplateAttribute() { Name = "Thickness", Order = 7 }, }; repTemplateAttribute.InsertRange(attributes); templateItem = new TemplateItem() { Name = "Reducer Eccentric", ItemType = itemType, ModelAttributes = attributes }; repTemplateItem.Insert(templateItem); #endregion #region Flange itemType = new ItemType() { Name = "Flange" }; repItemType.Insert(itemType); attributes = new List <TemplateAttribute>() { new TemplateAttribute() { Name = "Reference standard", Order = 1 }, new TemplateAttribute() { Name = "NPS", Order = 2 }, new TemplateAttribute() { Name = "Rating class", Order = 3 }, new TemplateAttribute() { Name = "Material Specification", Order = 4 }, new TemplateAttribute() { Name = "Grade", Order = 5 }, new TemplateAttribute() { Name = "Endings", Order = 6 }, new TemplateAttribute() { Name = "Thickness", Order = 7 }, }; repTemplateAttribute.InsertRange(attributes); templateItem = new TemplateItem() { Name = "Flange", ItemType = itemType, ModelAttributes = attributes }; repTemplateItem.Insert(templateItem); #endregion }