public static void SeedOffers() { var context = new BmsContex(); var offers = new[] { new Offer { ContragentId = 1, CreatorId = 2, Date = DateTime.Now, InquiryId = 1, Description = "Cost: $1300" }, new Offer { ContragentId = 2, CreatorId = 3, Date = DateTime.Now, InquiryId = 2, Description = "Cost: $2500" }, new Offer { ContragentId = 3, CreatorId = 4, Date = DateTime.Now, InquiryId = 3, Description = "Cost: $3300" }, new Offer { ContragentId = 4, CreatorId = 5, Date = DateTime.Now, InquiryId = 4, Description = "Cost: $1800" }, new Offer { ContragentId = 5, CreatorId = 6, Date = DateTime.Now, InquiryId = 5, Description = "Cost: $3200" } }; context.Offers.AddRange(offers); context.SaveChanges(); }
public static void SeedProjects() { var context = new BmsContex(); var project = new[] { new Project { ContragentId = 1, CreatorId = 2, OfferId = 1, StartDate = DateTime.Today.AddDays(-10), EndDate = DateTime.Today.AddDays(20), DeadLine = DateTime.Today.AddDays(18), InquiryId = 1, Name = "Android App" }, new Project { ContragentId = 2, CreatorId = 3, OfferId = 2, StartDate = DateTime.Today.AddDays(-32), EndDate = DateTime.Today.AddDays(30), DeadLine = DateTime.Today.AddDays(28), InquiryId = 2, Name = "Desktop App" }, new Project { ContragentId = 3, CreatorId = 4, OfferId = 3, StartDate = DateTime.Today.AddDays(-40), EndDate = DateTime.Today.AddDays(40), DeadLine = DateTime.Today.AddDays(38), InquiryId = 3, Name = "Web App" }, new Project { ContragentId = 4, CreatorId = 5, OfferId = 4, StartDate = DateTime.Today.AddDays(-52), EndDate = DateTime.Today.AddDays(50), DeadLine = DateTime.Today.AddDays(48), InquiryId = 4, Name = "Sports WebSite" }, new Project { ContragentId = 5, CreatorId = 6, OfferId = 5, StartDate = DateTime.Today.AddDays(-16), EndDate = DateTime.Today.AddDays(35), DeadLine = DateTime.Today.AddDays(33), InquiryId = 5, Name = "Product Management" } }; context.Projects.AddRange(project); context.SaveChanges(); }
public static void SeedContragents() { var context = new BmsContex(); var contragents = new[] { new Contragent { PersonalVatNumber = "SD12351", PersonalIndentityNumber = "101205", BankDetails = "BGNKJ1453STZ", Telephone = "0879665233", Town = "Haskovo", Address = "Hristo Botev 207", Description = "Food & Sweets", Email = "*****@*****.**", Name = "Kaufland AD", PersonForContact = "Vladimir", }, new Contragent { PersonalVatNumber = "DFA1235", PersonalIndentityNumber = "102233", BankDetails = "UKLDNSF1523SF", Telephone = "0889655294", Town = "Sofia", Address = "Peicho Slaveikov 3", Description = "Monthly Supplies", Email = "*****@*****.**", Name = "WeSupply EOOD", PersonForContact = "Pesho" }, new Contragent { PersonalVatNumber = "DAS1233", PersonalIndentityNumber = "103452", BankDetails = "DESF1523STZ", Telephone = "0879615259", Town = "Veliko Tarnovo", Address = "Raina Knqginq 24", Description = "Cleaning stuff", Email = "*****@*****.**", Name = "Goods EOOD", PersonForContact = "Ivan" }, new Contragent { PersonalVatNumber = "DS12357", PersonalIndentityNumber = "104623", BankDetails = "USASF1523STZ", Telephone = "0879665232", Town = "Yambol", Address = "Biznes Park Sofia", Description = "Internet services", Email = "*****@*****.**", Name = "Market2U OOD", PersonForContact = "Georgi" }, new Contragent { PersonalVatNumber = "DJG1236", PersonalIndentityNumber = "105125", BankDetails = "MEXSF1523STZ", Telephone = "0879665275", Town = "New York", Address = "Tsar Simeon Veliki 137", Description = "Fruits and Water Supply", Email = "*****@*****.**", Name = "Billa AD", PersonForContact = "Vladimir" }, }; context.Contragents.AddRange(contragents); context.SaveChanges(); }
public static void SeedInquiry() { var context = new BmsContex(); var inquiries = new[] { new Inquiry { ContragentId = 1, CreatorId = 2, Date = DateTime.Now, Description = "Create me Web App" }, new Inquiry { ContragentId = 2, CreatorId = 3, Date = DateTime.Now, Description = "Sell that stock" }, new Inquiry { ContragentId = 3, CreatorId = 4, Date = DateTime.Now, Description = "Configure Computer" }, new Inquiry { ContragentId = 4, CreatorId = 5, Date = DateTime.Now, Description = "Reinstall Windows" }, new Inquiry { ContragentId = 5, CreatorId = 6, Date = DateTime.Now, Description = "Android App Inquiry" } }; context.Inquiries.AddRange(inquiries); context.SaveChanges(); }
public static void SeedUsers() { var db = new BmsContex(); var users = new List <User>(); string[] names = new string[] { "viktor", "koko", "gogi", "vankata", "violeta" }; var admin = new User { Username = "******", Type = ClearenceType.Admin, Password = "******" }; users.Add(admin); for (int i = 0; i < 5; i++) { var user = new User { Username = names[i], Type = ClearenceType.User, Password = "******" }; users.Add(user); } db.Users.AddRange(users); db.SaveChanges(); }
public static void Main() { using (var context = new BmsContex()) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); Seed(context); } }
private void HandleSaveCommand(object parameter) { using (var context = new BmsContex()) { var calendarEvent = new CalendarEvent() { Title = this.Title, Description = this.Description, StartTime = this.StartTime, EndTime = this.EndTime, Color = this.Color }; context.CalendarEvents.Add(calendarEvent); context.SaveChanges(); } }
// enter in the admin panel with: // Username: admin // Password: 123 public static void Seed(BmsContex context) { var random = new Random(); //SeedUsers(); var users = new List <User>(); string[] names = new string[] { "viktor", "koko", "gogi", "vankata", "violeta" }; var admin = new User { Username = "******", Type = ClearenceType.Admin, Password = "******" }; users.Add(admin); for (int i = 0; i < 5; i++) { var user = new User { Username = names[i], Type = ClearenceType.User, Password = "******" }; users.Add(user); } context.Users.AddRange(users); //SeedContragents(); var contragents = new[] { new Contragent { PersonalVatNumber = "SD167882351", PersonalIndentityNumber = "101123205", BankDetails = "BGNKJ1453STZ", Telephone = "0879665233", Town = "Haskovo", Address = "Hristo Botev 207", Description = "Food & Sweets", Email = "*****@*****.**", Name = "Kaufland AD", PersonForContact = "Vladimir", }, new Contragent { PersonalVatNumber = "DFA12678935", PersonalIndentityNumber = "102212333", BankDetails = "UKLDNSF1523SF", Telephone = "0889655294", Town = "Sofia", Address = "Peicho Slaveikov 3", Description = "Monthly Supplies", Email = "*****@*****.**", Name = "WeSupply EOOD", PersonForContact = "Pesho" }, new Contragent { PersonalVatNumber = "DAS12678933", PersonalIndentityNumber = "101233452", BankDetails = "DESF1523STZ", Telephone = "0879615259", Town = "Veliko Tarnovo", Address = "Raina Knqginq 24", Description = "Cleaning stuff", Email = "*****@*****.**", Name = "Goods EOOD", PersonForContact = "Ivan" }, new Contragent { PersonalVatNumber = "DS167892357", PersonalIndentityNumber = "101234623", BankDetails = "USASF1523STZ", Telephone = "0879665232", Town = "Yambol", Address = "Biznes Park Sofia", Description = "Internet services", Email = "*****@*****.**", Name = "Market2U OOD", PersonForContact = "Georgi" }, new Contragent { PersonalVatNumber = "DJG12679736", PersonalIndentityNumber = "101235125", BankDetails = "MEXSF1523STZ", Telephone = "0879665275", Town = "New York", Address = "Tsar Simeon Veliki 137", Description = "Fruits and Water Supply", Email = "*****@*****.**", Name = "Billa AD", PersonForContact = "Vladimir" }, }; context.Contragents.AddRange(contragents); //SeedInquiry(); var inquiries = new[] { new Inquiry { Contragent = contragents[0], Creator = users[1], Date = DateTime.Now, Description = "Create me Web App" }, new Inquiry { Contragent = contragents[1], Creator = users[2], Date = DateTime.Now, Description = "Sell that stock" }, new Inquiry { Contragent = contragents[2], Creator = users[3], Date = DateTime.Now, Description = "Configure Computer" }, new Inquiry { Contragent = contragents[3], Creator = users[4], Date = DateTime.Now, Description = "Reinstall Windows" }, new Inquiry { Contragent = contragents[4], Creator = users[5], Date = DateTime.Now, Description = "Android App Inquiry" } }; context.Inquiries.AddRange(inquiries); //SeedOffers(); var offers = new[] { new Offer { Contragent = contragents[0], Creator = users[1], Date = DateTime.Now, InquiryId = 1, Description = "Cost: $1300" }, new Offer { Contragent = contragents[1], Creator = users[2], Date = DateTime.Now, InquiryId = 2, Description = "Cost: $2500" }, new Offer { Contragent = contragents[2], Creator = users[3], Date = DateTime.Now, InquiryId = 3, Description = "Cost: $3300" }, new Offer { Contragent = contragents[3], Creator = users[4], Date = DateTime.Now, InquiryId = 4, Description = "Cost: $1800" }, new Offer { Contragent = contragents[4], Creator = users[5], Date = DateTime.Now, InquiryId = 5, Description = "Cost: $3200" } }; context.Offers.AddRange(offers); //SeedProjects(); var projects = new[] { new Project { Contragent = contragents[0], Creator = users[1], Offer = offers[0], StartDate = DateTime.Today.AddDays(-10), EndDate = DateTime.Today.AddDays(20), DeadLine = DateTime.Today.AddDays(18), Inquiry = inquiries[0], Name = "Android App", ContactPerson = "Nick", ContactPhone = "0883521458" }, new Project { Contragent = contragents[1], Creator = users[2], Offer = offers[1], Inquiry = inquiries[1], StartDate = DateTime.Today.AddDays(-32), EndDate = DateTime.Today.AddDays(30), DeadLine = DateTime.Today.AddDays(28), Name = "Desktop App", ContactPerson = "Denis", ContactPhone = "0789231458" }, new Project { Contragent = contragents[2], Creator = users[3], Offer = offers[2], Inquiry = inquiries[2], StartDate = DateTime.Today.AddDays(-40), EndDate = DateTime.Today.AddDays(40), DeadLine = DateTime.Today.AddDays(38), Name = "Web App", ContactPerson = "Vicky", ContactPhone = "0896231442" }, new Project { Contragent = contragents[3], Creator = users[4], Offer = offers[3], Inquiry = inquiries[3], StartDate = DateTime.Today.AddDays(-52), EndDate = DateTime.Today.AddDays(50), DeadLine = DateTime.Today.AddDays(48), Name = "Sports WebSite", ContactPerson = "Danny", ContactPhone = "0889265328" }, new Project { Contragent = contragents[4], Creator = users[5], Offer = offers[4], Inquiry = inquiries[4], StartDate = DateTime.Today.AddDays(-16), EndDate = DateTime.Today.AddDays(35), DeadLine = DateTime.Today.AddDays(33), Name = "Product Management", ContactPerson = "Kaloyan", ContactPhone = "0882231624" } }; context.Projects.AddRange(projects); //Seed Notes var notes = new List <Note>(); for (int i = 0; i < 50; i++) { var note = new Note { Date = RandomDate(random), Description = RandomDescription(random), Project = projects[random.Next(0, projects.Length)], Type = RandomEnum <NoteType>(random) }; notes.Add(note); } context.Notes.AddRange(notes); //Seed ClientInvoices var clientInvoices = new List <Invoice>(); for (int i = 0; i < 20; i++) { var clientId = random.Next(0, contragents.Length); var supplierId = random.Next(0, contragents.Length); while (clientId == supplierId) { clientId = random.Next(0, contragents.Length); } var clientInvoice = new Invoice { Project = projects[random.Next(0, projects.Length)], Client = contragents[clientId], Supplier = contragents[supplierId], Text = RandomDescription(random), Date = RandomDate(random), Price = (decimal)(random.Next(10, 1000) * 1.24), Town = RandomTown(random), InvoiceNum = RandomInvoice(random), }; clientInvoice.Vat = clientInvoice.Price * 0.20m; clientInvoice.Total = clientInvoice.Price + clientInvoice.Vat; clientInvoices.Add(clientInvoice); } context.Invoices.AddRange(clientInvoices); //Seed SupplierInvoices var supplierInvoices = new List <Invoice>(); for (int i = 0; i < 20; i++) { var clientId = random.Next(0, contragents.Length); var supplierId = random.Next(0, contragents.Length); while (clientId == supplierId) { clientId = random.Next(0, contragents.Length); } var supplierInvoice = new Invoice { Project = projects[random.Next(0, projects.Length)], Client = contragents[clientId], Supplier = contragents[supplierId], Text = RandomDescription(random), Date = RandomDate(random), Price = (decimal)(random.Next(10, 1000) * 1.24), Town = RandomTown(random), InvoiceNum = RandomInvoice(random) }; supplierInvoice.Vat = supplierInvoice.Price * 0.20m; supplierInvoice.Total = supplierInvoice.Price + supplierInvoice.Vat; supplierInvoices.Add(supplierInvoice); } context.Invoices.AddRange(supplierInvoices); //Validate Payments var payments = new List <Payment>(); for (int i = 0; i < 50; i++) { var clientId = random.Next(0, contragents.Length); var supplierId = random.Next(0, contragents.Length); while (clientId == supplierId) { clientId = random.Next(0, contragents.Length); } var payment = new Payment { Project = projects[random.Next(0, projects.Length)], Client = contragents[clientId], Supplier = contragents[supplierId], Date = RandomDate(random), Price = (decimal)(random.Next(13, 1000) * 1.35), }; payment.Vat = payment.Price * 0.20m; payment.Total = payment.Price + payment.Vat; payments.Add(payment); } context.Payments.AddRange(payments); var events = new List <CalendarEvent>(); for (int i = 0; i < 50; i++) { var startDate = RandomDate(random); var endDate = RandomDate(random); while (startDate >= endDate) { startDate = RandomDate(random); } var @event = new CalendarEvent { Color = RandomEnum <Color>(random), Creator = users[random.Next(0, users.Count)], Description = RandomDescription(random), Project = projects[random.Next(0, projects.Length)], StartTime = startDate, EndTime = endDate, Title = RandomTitle(random) }; while (events.Any(e => e.Title == @event.Title)) { @event.Title = RandomTitle(random); } events.Add(@event); } context.CalendarEvents.AddRange(events); context.SaveChanges(); Console.WriteLine("All data inserted successfully"); }
public UserService() { context = new BmsContex(); //this.context = context; }