Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public async void ButtonAdd (string name, string price, string order)
- {
- await using var dbContext = new BurgerContext();
- await dbContext.Database.EnsureCreatedAsync();
- Order newOrder = new();
- if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(price)
- && !string.IsNullOrEmpty(order))
- {
- await dbContext.Orders.AddAsync(
- order = new Order() { Description = order });
- await dbContext.Burgers.AddAsync(
- new Burger() {Name = name, Price = Convert.ToDouble(price), Order = newOrder});
- await dbContext.SaveChangesAsync();
- MessageBox.Show("Data is saved", "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- MessageBox.Show("Something went wrong", "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement