public IndexModel(CashmoreApp.Data.CashmoreAppContext context) { _context = context; }
public DetailsModel(CashmoreApp.Data.CashmoreAppContext context) { _context = context; }
public EditModel(CashmoreApp.Data.CashmoreAppContext context) { _context = context; }
public CreateModel(CashmoreApp.Data.CashmoreAppContext context) { _context = context; }
public static void Initialize(CashmoreAppContext context) { //context.Database.EnsureCreated(); // Look for any Entities. if (context.Entities.Any()) { return; // DB has been seeded } // Add the Entities var entities = new Entity[] { // Hospital new Entity { EntityName = "Your Hospital", EntityAddress1 = "123 Main Street", EntityAddress2 = "", EntityCity = "Big City", EntityState = "IL", EntityZipcode = "61104", EntityCountry = "USA", EntityPhoneNumber = "8881231234", EntityType = EntityTypes.Hospital }, // Vender1 new Entity { EntityName = "Vendor 1", EntityAddress1 = "12345 1st Street", EntityAddress2 = "", EntityCity = "Big City", EntityState = "IL", EntityZipcode = "61114", EntityCountry = "USA", EntityPhoneNumber = "8888888888", EntityType = EntityTypes.Vendor }, // Vendor2 new Entity { EntityName = "Vendor 2", EntityAddress1 = "432 West Street", EntityAddress2 = "Suite 103", EntityCity = "Medium City", EntityState = "WI", EntityZipcode = "55555", EntityCountry = "USA", EntityPhoneNumber = "7777777777", EntityType = EntityTypes.Vendor }, // Vendor3 new Entity { EntityName = "Vendor 3", EntityAddress1 = "444 4th Street", EntityAddress2 = "Suite 444", EntityCity = "Large City", EntityState = "CA", EntityZipcode = "11111", EntityCountry = "USA", EntityPhoneNumber = "5555555555", EntityType = EntityTypes.Vendor } }; foreach (Entity e in entities) { context.Entities.Add(e); } context.SaveChanges(); //Add Users // Load the entities for easier access when mapping users var hospital = entities.Single(e => e.EntityName == "Your Hospital"); var vendorOne = entities.Single(e => e.EntityName == "Vendor 1"); var vendorTwo = entities.Single(e => e.EntityName == "Vendor 2"); var vendorThree = entities.Single(e => e.EntityName == "Vendor 3"); var users = new User[] { new User { UserFirstName = "Leader 1", UserLastName = "Hospital", UserEmail = "*****@*****.**", UserPassword = "******", UserAccessLevel = Access.FullAccess, EntityID = hospital.EntityID }, new User { UserFirstName = "Leader 2", UserLastName = "Hospital", UserEmail = "*****@*****.**", UserPassword = "******", UserAccessLevel = Access.FullAccess, EntityID = hospital.EntityID }, new User { UserFirstName = "User 1", UserLastName = "Hospital", UserEmail = "*****@*****.**", UserPassword = "******", UserAccessLevel = Access.ReadOnly, EntityID = hospital.EntityID }, new User { UserFirstName = "Leader 1", UserLastName = "Vendor 1", UserEmail = "*****@*****.**", UserPassword = "******", UserAccessLevel = Access.FullAccess, EntityID = vendorOne.EntityID }, new User { UserFirstName = "Leader 1", UserLastName = "Vendor 2", UserEmail = "*****@*****.**", UserPassword = "******", UserAccessLevel = Access.FullAccess, EntityID = vendorTwo.EntityID }, new User { UserFirstName = "Leader 1", UserLastName = "Vendor 3", UserEmail = "*****@*****.**", UserPassword = "******", UserAccessLevel = Access.FullAccess, EntityID = vendorThree.EntityID } }; foreach (User u in users) { context.Users.Add(u); } context.SaveChanges(); // Map Users to Entities // Hospital // var hospital = entities.Single( e => e.EntityName == "Your Hospital"); // var hospitalUsers = users.Where(u => u.UserLastName == "Hospital"); // foreach(User u in hospitalUsers) // { // hospital.EntityUsers.Add(u); // } // context.SaveChanges(); // // Vendor 1 // var vendorOne = entities.Single( e => e.EntityName == "Vendor 1"); // var vendorOneUsers = users.Single(u => u.UserLastName == "Vendor 1"); // vendorOne.EntityUsers.Add(vendorOneUsers); // context.SaveChanges(); // // Vendor 2 // var vendorTwo = entities.Single( e => e.EntityName == "Vendor 2"); // var vendorTwoUsers = users.Single(u => u.UserLastName == "Vendor 2"); // vendorTwo.EntityUsers.Add(vendorTwoUsers); // context.SaveChanges(); // // Vendor 1 // var vendorThree = entities.Single( e => e.EntityName == "Vendor 3"); // var vendorThreeUsers = users.Single(u => u.UserLastName == "Vendor 3"); // vendorThree.EntityUsers.Add(vendorThreeUsers); // context.SaveChanges(); // Add some Contracts var contracts = new Contract[] { // Fully Completed Contract new Contract { ContractProductLine = "Ultrasound U9", ContractPurchaseOrder = "C123782", ContractStatus = "Active", ContractStartDate = DateTime.Parse("2017-03-02"), ContractEndDate = DateTime.Parse("2018-03-01"), ContractValue = 60000m }, // One Signature Contract new Contract { ContractProductLine = "Medical Supplies", ContractPurchaseOrder = "N/A", ContractStatus = "Active", ContractStartDate = DateTime.Parse("2012-11-01"), ContractEndDate = DateTime.Parse("2017-10-30"), ContractValue = 50000000m }, // No Signatures Contract new Contract { ContractProductLine = "MA for Ultrasound 9", ContractPurchaseOrder = "987621", ContractStatus = "Active", ContractStartDate = DateTime.Parse("2018-03-01"), ContractEndDate = DateTime.Parse("2021-02-28"), ContractValue = 30000m } }; foreach (Contract c in contracts) { context.Contracts.Add(c); } context.SaveChanges(); // Add Entities to Contracts var contractOne = contracts.Single(c => c.ContractProductLine == "Ultrasound U9"); var contractTwo = contracts.Single(c => c.ContractProductLine == "Medical Supplies"); var contractThree = contracts.Single(c => c.ContractProductLine == "MA for Ultrasound 9"); var entityContracts = new EntityToContract[] { // Contract 1 new EntityToContract { EntityID = hospital.EntityID, ContractID = contractOne.ContractID }, new EntityToContract { EntityID = vendorOne.EntityID, ContractID = contractOne.ContractID }, // Contract 2 new EntityToContract { EntityID = hospital.EntityID, ContractID = contractTwo.ContractID }, new EntityToContract { EntityID = vendorTwo.EntityID, ContractID = contractTwo.ContractID }, // Contract 3 new EntityToContract { EntityID = hospital.EntityID, ContractID = contractThree.ContractID }, new EntityToContract { EntityID = vendorOne.EntityID, ContractID = contractThree.ContractID } }; foreach (EntityToContract etc in entityContracts) { context.EntityContracts.Add(etc); } context.SaveChanges(); // var contractOne = contracts.Single( c => c.ContractProductLine == "Ultrasound U9"); // contractOne.ContractEntities.Add(hospital); // contractOne.ContractEntities.Add(vendorOne); // var contractTwo = contracts.Single( c => c.ContractProductLine == "Medical Supplies"); // contractTwo.ContractEntities.Add(hospital); // contractTwo.ContractEntities.Add(vendorTwo); // var contractThree = contracts.Single( c => c.ContractProductLine == "MA for Ultrasound 9"); // contractThree.ContractEntities.Add(hospital); // contractThree.ContractEntities.Add(vendorOne); // context.SaveChanges(); // Add Signatures to Contracts // Grab the leaders to map to signatures var hospitalUsers = users.Where(u => u.UserLastName == "Hospital"); var hospitalLeader = hospitalUsers.Single(u => u.UserFirstName == "Leader 1"); var vendorOneUsers = users.Single(u => u.UserLastName == "Vendor 1"); var vendorTwoUsers = users.Single(u => u.UserLastName == "Vendor 2"); var vendorThreeUsers = users.Single(u => u.UserLastName == "Vendor 3"); // Contract One has everything signed var contractOneSignatures = new Signatures[] { new Signatures { ContractID = contractOne.ContractID, ContractType = ContractTypes.CaptialContract, HospitalSignature = hospitalLeader, VendorSignature = vendorOneUsers }, new Signatures { ContractID = contractOne.ContractID, ContractType = ContractTypes.MaintenanceAgreementContract, HospitalSignature = hospitalLeader, VendorSignature = vendorOneUsers }, new Signatures { ContractID = contractOne.ContractID, ContractType = ContractTypes.NetworkAccessContract, HospitalSignature = hospitalLeader, VendorSignature = vendorOneUsers }, new Signatures { ContractID = contractOne.ContractID, ContractType = ContractTypes.BAAContract, HospitalSignature = hospitalLeader, VendorSignature = vendorOneUsers }, new Signatures { ContractID = contractOne.ContractID, ContractType = ContractTypes.SecurityRiderContract, HospitalSignature = hospitalLeader, VendorSignature = vendorOneUsers }, new Signatures { ContractID = contractOne.ContractID, ContractType = ContractTypes.SecurityAssessmentContract, HospitalSignature = hospitalLeader, VendorSignature = vendorOneUsers } }; foreach (Signatures s in contractOneSignatures) { context.Signatures.Add(s); } context.SaveChanges(); // Contract 2 has everything signed from the hospital side var contractTwoSignatures = new Signatures[] { new Signatures { ContractID = contractTwo.ContractID, ContractType = ContractTypes.SupplyContract, HospitalSignature = hospitalLeader }, new Signatures { ContractID = contractTwo.ContractID, ContractType = ContractTypes.MinorEquipmentContract, HospitalSignature = hospitalLeader }, new Signatures { ContractID = contractTwo.ContractID, ContractType = ContractTypes.ProductUsageContract, HospitalSignature = hospitalLeader } }; foreach (Signatures s in contractTwoSignatures) { context.Signatures.Add(s); } context.SaveChanges(); // Contract 3 we will add signatures as a test, so no signatures are needed }