private void SeedInventoryItems(PizzaContext context)
        {
            if (context.InventoryItems.Any())
            {
                return;
            }

            InventoryItem[] inventoryItems = new InventoryItem[]
            {
                new InventoryItem {
                    Name = "Pepperoni", Type = InventoryItemType.Topping, QuantityRemaining = 1000, PricePerUnit = .01M
                },
                new InventoryItem {
                    Name = "Sausage", Type = InventoryItemType.Topping, QuantityRemaining = 1000, PricePerUnit = .01M
                },
                new InventoryItem {
                    Name = "Mozerella", Type = InventoryItemType.Cheese, QuantityRemaining = 1000, PricePerUnit = .01M
                },
                new InventoryItem {
                    Name = "Surge", Type = InventoryItemType.Flavor, QuantityRemaining = 50, PricePerUnit = .50M
                },
            };

            context.InventoryItems.AddRange(inventoryItems);
            context.SaveChanges();
        }
Ejemplo n.º 2
0
        public PokretanjeProcesa()
        {
            _pocetnoKreiranje = new KreiranjePizze();
            if (_pocetnoKreiranje.PotvrdaKreiranja() == false)
            {
                return;
            }

            prikaziPizze();

            if (potvrdaPorudzbine() == false)
            {
                return;
            }

            PizzaContext db = new PizzaContext();

            KreirajPorudzbinu(_pocetnoKreiranje.GotovePizze());

            db.Porudzbine.Add(_porudzbina);
            db.SaveChanges();
            Console.Clear();
            prikaz.Prikaz(_porudzbina.PorudzbinaId);
            Console.WriteLine("\nPritisnite enter za povratak na pocetnu stranu...");
            Console.ReadLine();
        }
Ejemplo n.º 3
0
        private void SeedEmployees(PizzaContext context)
        {
            if (context.Employees.Any())
            {
                return;
            }

            Employee[] employees = new Employee[]
            {
                new Employee {
                    FirstName = "Donell", LastName = "Banks", PhoneNumber = "205-555-5557", Role = Roles.Manager, Salary = 97000m
                },
                new Employee {
                    FirstName = "Jax", LastName = "Cassidy", PhoneNumber = "124-555-7849", Role = Roles.AssistantManager, Salary = 60000m
                },
                new Employee {
                    FirstName = "Dilara", LastName = "Gardiner", PhoneNumber = "896-555-9565", Role = Roles.Driver, Salary = 30000m
                },
                new Employee {
                    FirstName = "Hammad", LastName = "Goff", PhoneNumber = "322-555-5463", Role = Roles.Insider, Salary = 26000m
                },
                new Employee {
                    FirstName = "Ayah", LastName = "Hodges", PhoneNumber = "895-555-7894", Role = Roles.Cashier, Salary = 24000m
                }
            };

            context.Employees.AddRange(employees);
            context.SaveChanges();
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create(string nome, string data_Nascimento, string telefone, string cpf, string logradouro, int numero, string complemento, string bairro, string cep)
        {
            Endereco endereco = new Endereco();

            endereco.Logradouro  = logradouro;
            endereco.Numero      = numero;
            endereco.Complemento = complemento;
            endereco.Bairro      = bairro;
            endereco.CEP         = cep;
            endereco.IdCidade    = Convert.ToInt32(Request.Form["IdCidade"]);

            Cliente cliente = new Cliente();

            cliente.Nome            = nome;
            cliente.Data_Nascimento = data_Nascimento;
            cliente.Telefone        = telefone;
            cliente.CPF             = cpf;
            using (var repo = new PizzaContext())
            {
                repo.Add(cliente);
                repo.Add(endereco);
                repo.SaveChanges();
            }
            Cliente_Has_Endereco clienteE = new Cliente_Has_Endereco();

            clienteE.CPF        = cpf;
            clienteE.IdEndereco = endereco.IdEndereco;
            using (var repo = new PizzaContext())
            {
                repo.Add(clienteE);
                repo.SaveChanges();
            }
            return(View(RetornaCidades()));
        }
Ejemplo n.º 5
0
        public void GetStatus_ReturnsStatus()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <PizzaContext>()
                          .UseInMemoryDatabase(databaseName: "PizzaDataBase")
                          .Options;

            //Mocked DB entry
            using (var context = new PizzaContext(options))
            {
                context.Orders.Add(new Order
                {
                    OrderId     = 1,
                    OrderStatus = "Pending"
                });
                context.SaveChanges();
            }
            using (var context = new PizzaContext(options))
            {
                OrdersController controller = new(context);
                var result       = controller.GetStatus(1).Result.Value;
                var actualResult = result.ToString();

                Assert.Equal("Pending", actualResult);
            }
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            using (var db = new PizzaContext())
            {
                // Obtener nombre de la pizza
                Console.Write("Nombre pizza: ");
                var name = Console.ReadLine();
                Console.Write("Precio: ");
                var price = decimal.Parse(Console.ReadLine());

                // Asignarlo a una pizza
                var pizza = new Pizza {
                    Nombre = name, Precio = price
                };

                db.Pizzas.Add(pizza);
                db.SaveChanges();

                // Mostrar pizzas
                var query = from b in db.Pizzas
                            orderby b.Nombre
                            select b;

                Console.WriteLine("Todas las pizzas: ");
                foreach (var item in query)
                {
                    Console.WriteLine(item.Nombre);
                }

                Console.WriteLine("Exit");
                Console.ReadLine();
            }
        }
        public bool ProceedOrder(Guid guid, List <OrderedPizza> pizzas)
        {
            if (SessionManager.Instance.ValidateUser(guid))
            {
                bool orderProceedSucceeded = false;
                using (PizzaContext ctx = new PizzaContext(PizzaContext.ConnectionString))
                {
                    string userName = SessionManager.Instance.GetUserNameByGuid(guid);

                    User user = (from u in ctx.Users
                                 where u.UserName == userName
                                 select u).FirstOrDefault();

                    ctx.Orders.Add(new Order
                    {
                        Pizzas = pizzas,
                        Status = Order.StatusCreated,
                        User   = user
                    });
                    orderProceedSucceeded = true;
                    ctx.SaveChanges();
                }
                return(orderProceedSucceeded);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 8
0
 public ShowBasket()
 {
     db         = new PizzaContext();
     AllProduct = new ObservableCollection <Product>();
     ProductID  = new List <int>();
     Sum        = 0;
 }
Ejemplo n.º 9
0
 public AccountController(UserManager <User> userManager, SignInManager <User> signInManager, RoleManager <IdentityRole> roleManager, PizzaContext context)
 {
     this.userManager   = userManager;
     this.signInManager = signInManager;
     this.roleManager   = roleManager;
     db = context;
 }
Ejemplo n.º 10
0
 public List <Ingredient> GetAll()
 {
     using (var db = new PizzaContext())
     {
         return(db.Ingredients.ToList());
     }
 }
Ejemplo n.º 11
0
        private void SeedCustomers(PizzaContext context)
        {
            if (context.Customers.Any())
            {
                return;
            }

            Customer[] customers = new Customer[]
            {
                new Customer {
                    FirstName = "John", LastName = "Fleet", PhoneNumber = "215-555-5527", StreetAddress = "9570 Broken Dawn Dr", City = "Huntsville", State = "Va", Zip = 35809
                },
                new Customer {
                    FirstName = "Jamie", LastName = "Beggar", PhoneNumber = "123-555-7349", StreetAddress = "9890 Half Circle Av", City = "Chicago", State = "Il", Zip = 46809
                },
                new Customer {
                    FirstName = "Karen", LastName = "Bassk", PhoneNumber = "846-555-9465", StreetAddress = "6470 Twisted Square Rd", City = "New York City", State = "NY", Zip = 65879
                },
                new Customer {
                    FirstName = "Dave", LastName = "Gnome", PhoneNumber = "352-555-5453", StreetAddress = "9552 Upside Monkey Av", City = "St. Louis", State = "Mo", Zip = 89189
                },
                new Customer {
                    FirstName = "Sammy", LastName = "Aboleth", PhoneNumber = "896-555-7694", StreetAddress = "1594 Delta Prime Cr", City = "San Diego", State = "Ca", Zip = 70026
                }
            };

            context.Customers.AddRange(customers);
            context.SaveChanges();
        }
Ejemplo n.º 12
0
 public ActionResult Read()
 {
     using (var repo = new PizzaContext())
     {
         var data = repo.Produtos.ToList();
         return(View(data));
     }
 }
Ejemplo n.º 13
0
        public PizzaManager()
        {
            var builder = new DbContextOptionsBuilder();

            builder.UseInMemoryDatabase("Pizza_Db");

            _context = new PizzaContext(builder.Options);
        }
 public List <Pizza> GetAll()
 {
     using (var db = new PizzaContext())
     {
         return(db.Pizzas
                .Include(nameof(Pizza.Ingredients))
                .ToList());
     }
 }
Ejemplo n.º 15
0
 public void Remove(int ingredientId)
 {
     using (var db = new PizzaContext())
     {
         var ingredient = db.Ingredients.Find(ingredientId);
         db.Ingredients.Remove(ingredient ?? throw new InvalidOperationException());
         db.SaveChanges();
     }
 }
Ejemplo n.º 16
0
 static void Main(string[] args)
 {
     using (var db = new PizzaContext())
     {
         db.Database.EnsureCreated();
         db.SaveChanges();
         Pokreni pokreni = new Pokreni();
     }
 }
Ejemplo n.º 17
0
        public PizzaContext Provide()
        {
            var connection = Effort.DbConnectionFactory.CreatePersistent(_databaseName);
            var context    = new PizzaContext(connection, true);

            context.Database.CreateIfNotExists();

            return(context);
        }
 public void Remove(int pizzaId)
 {
     using (var db = new PizzaContext())
     {
         var pizza = db.Pizzas.Find(pizzaId);
         db.Pizzas.Remove(pizza ?? throw new InvalidOperationException());
         db.SaveChanges();
     }
 }
Ejemplo n.º 19
0
 public Option <Ingredient> Get(int id)
 {
     using (var db = new PizzaContext())
     {
         return(db.Ingredients
                .AsNoTracking()
                .FirstOrDefault(x => x.IngredientId == id)
                .AsOption <Ingredient>());
     }
 }
 public List <Pizza> GetAllByIngredient(int ingredientId)
 {
     using (var db = new PizzaContext())
     {
         return(db.Pizzas
                .Include(nameof(Pizza.Ingredients))
                .AsNoTracking()
                .Where(p => p.Ingredients.Any(i => i.IngredientId == ingredientId))
                .ToList());
     }
 }
Ejemplo n.º 21
0
 public void Add(string name)
 {
     using (var db = new PizzaContext())
     {
         db.Ingredients.Add(new Ingredient
         {
             Name = name
         });
         db.SaveChanges();
     }
 }
Ejemplo n.º 22
0
        public ProdutosParaPedido RetornaCidades()
        {
            ProdutosParaPedido listaCidade = new ProdutosParaPedido();

            using (var repo = new PizzaContext())
            {
                var cidade = repo.Cidade.ToList();
                listaCidade.ListaCidade = cidade;
            }
            return(listaCidade);
        }
Ejemplo n.º 23
0
        public void GetOrder()
        {
            var options = new DbContextOptionsBuilder <PizzaContext>()
                          .UseSqlServer("Server=localhost;Database=PizzaOrderingSystem;Trusted_Connection=True;MultipleActiveResultSets=true")
                          .Options;
            var context = new PizzaContext(options);
            OrdersController ordersController = new OrdersController(context);
            var order            = ordersController.GetOrder(4).Result.Value;
            int actualCustomerId = 11;

            Assert.Equal(actualCustomerId, order.CustomerId);
        }
 public Option <Pizza> Get(int id)
 {
     using (var db = new PizzaContext())
     {
         return(db.Pizzas
                .Include(nameof(Pizza.Ingredients))
                .Include("Ingredients.Ingredient")
                .AsNoTracking()
                .FirstOrDefault(x => x.PizzaId == id)
                .AsOption <Pizza>());
     }
 }
Ejemplo n.º 25
0
        public async Task OneTimeSetup()
        {
            var environmentBuilder = new DockerEnvironmentBuilder();

            _dockerEnvironment = PrepareDockerEnvironment(environmentBuilder);
            await _dockerEnvironment.Up();

            var connectionString = _dockerEnvironment.GetContainer <MssqlContainer>("testDb").GetConnectionString();

            DbContext = new PizzaContext(connectionString);
            await DbContext.Database.EnsureCreatedAsync();
        }
Ejemplo n.º 26
0
        // GET: pedidoes/Create
        public ActionResult Create()
        {
            ProdutosParaPedido lista = new ProdutosParaPedido();

            using (var repo = new PizzaContext())
            {
                var clientes = repo.Cliente.ToList();
                var produtos = repo.Produtos.ToList();
                lista.ListaCliente = clientes;
                lista.ListaProduto = produtos;
                return(View(lista));
            }
        }
Ejemplo n.º 27
0
        private LoginScreen loginScreen; //Окно с авторизацией

        public MainViewModel()
        {
            db     = new PizzaContext();
            basket = new ShowBasket();

            menu   = new Katalog(basket);
            build  = new Konstruktor(basket);
            kor    = new Korzina(basket);
            report = new Page_Report();
            order  = new Page_Order();

            SourcePage = menu;      //Текущая страница
        }
Ejemplo n.º 28
0
        public void Rename(int ingredientId, string ingredientName)
        {
            using (var db = new PizzaContext())
            {
                var ingredient = db.Ingredients.Find(ingredientId);
                if (ingredient != null)
                {
                    ingredient.Name = ingredientName;
                }

                db.SaveChanges();
            }
        }
Ejemplo n.º 29
0
        private int sous_id = 0;                //Выбранный соус

        public BuildingPizza(ShowBasket sb)
        {
            db                 = new PizzaContext();
            basket             = sb;
            Images             = new ObservableCollection <ImageViewModel>();
            IngredientID       = new List <int>();
            ing                = db.Ingredient.ToList().Select(i => new IngredientViewModel(i)).ToList();
            AllIngredient      = new List <IngredientViewModel>();
            selectedingredient = ing.Where(i => i.IngredientID == 1).SingleOrDefault();
            sum                = selectedingredient.Price;
            massa              = selectedingredient.Massa;
            IngredientID.Add(selectedingredient.IngredientID);
        }
Ejemplo n.º 30
0
        public ReportViewModel()
        {
            product    = new Page_Product(this);    //Страница продуктов
            ing        = new Page_Ing(this);        //Страница ингредиентов
            otchet     = new Page_Otchet(this);     //Страница с отчётом
            SourcePage = otchet;                    //Текущая страница

            db          = new PizzaContext();
            report      = new ReportModel();        //Отчёт
            Products    = new ObservableCollection <Product>(db.Product);
            Ingredients = new ObservableCollection <Ingredient>(db.Ingredient);
            Kategori    = db.Kategori.ToList();     //Заполнение комбобокса в ингредиентах
            Data        = new List <Result>();      //Результат отчёта
        }