Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. public CreateTechnicCommand(string name, string email, int age, string productname, int quantity)
  2. {
  3. this.name = name;
  4. this.email = email;
  5. this.age = age;
  6.  
  7. this.productname = productname;
  8. this.quantity = quantity;
  9. }
  10.  
  11. public void Execute()
  12. {
  13. using(Technic context = new Technic())
  14. {
  15. Customer customer = new Customer()
  16. {
  17. Name = this.name,
  18. Email = this.email,
  19. Age = this.age
  20. };
  21. Order order = new Order()
  22. {
  23. ProductName = this.productname,
  24. Quantity = this.quantity,
  25. Customer = customer
  26. };
  27. context.Customers.Add(customer);
  28. context.Orders.Add(order);
  29. context.SaveChanges();
  30. }
  31. Console.WriteLine("Record is Created");
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement