Ejemplo n.º 1
0
        public ShellViewModel()
        {
            Dishes.Add(new DishModel {
                DishName = "Lihapullat perunamuusilla", DishDescription = "Mummon reseptillä lihapullat ruskeassa kastikkeessa, perunamuusia ja puolukkahilloa", DishPrice = 5.35
            });
            Dishes.Add(new DishModel {
                DishName = "Kalakukkoa", DishDescription = "Savon perinneherkkua", DishPrice = 4.40
            });
            Dishes.Add(new DishModel {
                DishName = "Chilimakkarapannu", DishDescription = "Mausteista makkaraa ja perunaa", DishPrice = 5.45
            });
            Dishes.Add(new DishModel {
                DishName = "Kesäkeitto", DishDescription = "Kasviksia ja juureksia maitoliemessä", DishPrice = 3.90
            });
            Dishes.Add(new DishModel {
                DishName = "Oopperakellarin silakat", DishDescription = "Paistetut silakat, perunasose", DishPrice = 11.95
            });
            Dishes.Add(new DishModel {
                DishName = "Teriyaki-lohi", DishDescription = "Paistettu lohi, teriyaki-kastike, purjomajoneesi, riisi", DishPrice = 22.45
            });

            Ruokalistat.Add(new MenuModel {
                MenuName = "Aamiaislista"
            });
            Ruokalistat.Add(new MenuModel {
                MenuName = "Lounaslista"
            });
            Ruokalistat.Add(new MenuModel {
                MenuName = "A la carte -lista"
            });
            Ruokalistat.Add(new MenuModel {
                MenuName = "Lastenlista"
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adding a dish to the dish list
        /// </summary>
        /// <param name="name"></param>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <param name="info"></param>
        /// <param name="strPrice"></param>
        ///
        public void AddDish(string name, string id, string type, string info, string strPrice, int index, out bool result)
        {
            result = false;
            if (name == "" || id == "")
            {
                MessageBox.Show("A dish name and ID must be entered");
            }

            else if (!double.TryParse(strPrice, out double price))
            {
                MessageBox.Show("Invalid price");
            }

            else
            {
                Dish dish = new Dish(name, id, type, info, price);

                if (index == -1)
                {
                    Dishes.Add(dish);
                }
                else
                {
                    Dishes[index] = dish;
                }

                result = true;
            }
        }
Ejemplo n.º 3
0
        //méthode pour recevoir les plats sales avec un TcpListener
        public void ReceivePlate()
        {
            TcpListener server = null;

            try
            {
                // TcpListener server = new TcpListener(port);
                server = new TcpListener(localAddr, port);
                // Start listening for client requests.
                server.Start();

                // Enter the listening loop.
                while (true)
                {
                    Console.WriteLine("Le comptoire de vaisselle sale attend... ");

                    // Perform a blocking call to accept requests.
                    TcpClient client = server.AcceptTcpClient();

                    MemoryStream stream1 = new MemoryStream();

                    using (NetworkStream ns = client.GetStream())
                    {
                        BinaryFormatter bf = new BinaryFormatter();
                        stream1 = (MemoryStream)bf.Deserialize(ns);
                    }

                    //Juste afficher mon stream jSON

                    /*stream1.Position = 0;
                     * StreamReader sr = new StreamReader(stream1);
                     * Console.Write("JSON form of Person object: ");
                     * Console.WriteLine(sr.ReadToEnd());*/

                    //créer mon objet à partir de mon Json et afficher id ce la commande pour vérifier
                    DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Dish));
                    stream1.Position = 0;
                    Dish newDish = (Dish)ser.ReadObject(stream1);

                    // Shutdown and end connection
                    client.Close();

                    Dishes.Add(newDish);
                    Console.WriteLine("Des plats sales sont arrivés");
                    Thread.Sleep(1000);
                }
            }
            catch (SocketException e)
            {
                Console.WriteLine("SocketException: {0}", e);
            }
            finally
            {
                // Stop listening for new clients.
                server.Stop();
            }
        }
Ejemplo n.º 4
0
 public Orders(OrderEnt order)
 {
     Id = order.Id;
     foreach (var x in order.Dishes)
     {
         Dishes.Add(new Dish(x));
     }
     TimeOfOrder = order.TimeOfOrder;
 }
Ejemplo n.º 5
0
 public void InsertDish(string insertName, string insertDescription)
 {
     //decimal strintToDecimal = decimal.Parse(insertPrice);
     Dishes.Add(new DishModel {
         DishName = insertName, DishDescription = insertDescription, DishPrice = 0
     });
     //NotifyOfPropertyChange(() => DishName);
     //NotifyOfPropertyChange(() => DishDescription);
 }
        private void OnAddDishCommandExecute()
        {
            var visualizer = this.GetDependencyResolver().Resolve <IUIVisualizerService>();
            var addDishVm  = new AddDishViewModel();

            if (visualizer.ShowDialog(addDishVm) == true)
            {
                Dishes.Add(addDishVm.Dish);
            }
        }
Ejemplo n.º 7
0
        public MainContext(DbContextOptions <MainContext> options) : base(options)
        {
            if (!Dishes.Any())
            {
                Dishes.Add(new Dish()
                {
                    Name = "Plate"
                });
                Dishes.Add(new Dish()
                {
                    Name = "Fork"
                });
                Dishes.Add(new Dish()
                {
                    Name = "Knife"
                });
                SaveChanges();
            }

            if (!Fruits.Any())
            {
                Fruits.Add(new Fruit()
                {
                    Name = "Apple"
                });
                Fruits.Add(new Fruit()
                {
                    Name = "Orange"
                });
                Fruits.Add(new Fruit()
                {
                    Name = "Kiwi"
                });
                SaveChanges();
            }

            if (!Vegetables.Any())
            {
                Vegetables.Add(new Vegetable()
                {
                    Name = "Cucumber"
                });
                Vegetables.Add(new Vegetable()
                {
                    Name = "Tomato"
                });
                Vegetables.Add(new Vegetable()
                {
                    Name = "Carrot"
                });
                SaveChanges();
            }
        }
Ejemplo n.º 8
0
        public void Add(Food foodConsumed, double amount)
        {
            var productExist = Dishes.Keys.FirstOrDefault(f => f.Name.Equals(foodConsumed.Name));

            if (productExist == null)
            {
                Dishes.Add(foodConsumed, amount);
            }
            else
            {
                Dishes[productExist] += amount;
            }
        }
Ejemplo n.º 9
0
        private void LoadData()
        {
            Dishes.Clear();
            var dataService = new DataService();


            Category = dataService.GetCategories().First(c => c.Id == _categoryId);
            var dishes = dataService.GetDishes(_categoryId);

            foreach (var dish in dishes)
            {
                Dishes.Add(dish);
            }
        }
Ejemplo n.º 10
0
        public void Add(Food food, double weight)
        {
            var product = Dishes.SingleOrDefault(f => f.Name.Equals(food.Name));

            if (product == null)
            {
                Dishes.Add(food);
                Eating.Add(food, weight);
                Save();
            }
            else
            {
                Eating.Add(product, weight);
                Save();
            }
        }
Ejemplo n.º 11
0
        public void Update()
        {
            Dishes.Clear();

            using (IDishController controller = factory.CreateDishController())
            {
                DataControllerMessage <IEnumerable <DishDisplayDTO> > controllerMessage = controller.GetAll();
                if (controllerMessage.IsSuccess)
                {
                    foreach (DishDisplayDTO dish in controllerMessage.Data)
                    {
                        Dishes.Add(dish);
                    }
                }
            }
        }
Ejemplo n.º 12
0
 // 装载 DishBeanUtil
 public void CreateDishBeanUtil(DishBean element)
 {
     if (element.DishPrice != null && element.DishPrice.Count > 0)
     {
         foreach (var elem in element.DishPrice)
         {
             DishBeanUtil Dbu = new DishBeanUtil();
             Dbu.CreateDishBeanUtilByDishBean(elem);
             Dbu.DishName        = element.DishName;
             Dbu.Code            = element.Code;
             Dbu.DishUnitName    = element.DishUnit.Name;
             Dbu.PingYing        = element.PingYing;
             Dbu.AidNumber       = element.PingYing;
             Dbu.DishTypeBigName = element.DishTypeBigName;
             Dbu.DishTypeName    = element.DishTypeName;
             Dishes.Add(Dbu);
         }
     }
 }
Ejemplo n.º 13
0
        private void DishesCollection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (Dish item in e.NewItems)
                {
                    Dishes.Add(item);
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (Dish item in e.OldItems)
                {
                    Dishes.Remove(item);
                }
                break;
            }
        }
Ejemplo n.º 14
0
        /*
         * FullyObservableCollection<DeliveryPerson> deliveryPerson;
         * public FullyObservableCollection<DeliveryPerson> DeliveryPerson
         * {
         *  get
         *  {
         *      return deliveryPerson;
         *  }
         *
         * }
         */

        public bool AddOpenDish(Dish d)
        {
            /*
             * var od = new Dish()
             * {
             *  Barcode = barcode,
             *  Name = Name,
             *  RussianName = Name,
             *  EnglishName = EnglishName,
             *  IsTemporary = true,
             *  PriceForFlight = Price,
             *  IsActive = true
             * };
             */
            bool res = DBProvider.AddDish(d);

            if (res)
            {
                Dishes.Add(d);
                //NotifyPropertyChanged("GetOpenDishes");
            }
            return(res);
        }
Ejemplo n.º 15
0
        public void AddDish()
        {
            if (!AskToSaveChanges())
            {
                return;
            }

            // Create a unique name by appending an integer
            string name;
            int    number = Dishes.Count + 1;

            while (true)
            {
                name = $"New dish {number}";
                if (IsDishNameInUse(name, null))
                {
                    number++;
                }
                else
                {
                    break;
                }
            }

            string descr = "";
            double price = 0.00;
            Dish   dish  = new Dish(name, descr, price);

            DataAccess da = new DataAccess();
            int        id = da.InsertDish(dish);

            dish.Id = id; // GetMaxIdFromDB(da); // get the Id of the Dish we just added to the database
            Dishes.Add(dish);

            SelectedDish         = dish;
            SelectedDishModified = false;
        }
Ejemplo n.º 16
0
 public void AddDish(Dish dish)
 {
     Dishes.Add(dish);
     TotalCost += dish.Price;
 }
Ejemplo n.º 17
0
 public void Add(Dish dish)
 {
     Dishes.Add(dish);
     Count++;
 }
        //made it a task to not hinder loading which is long enough as it is
        public async Task Initialize()
        {
            var test = Database.GetPendingMigrations();

            if (Database.GetPendingMigrations().Any())
            {
                await Database.MigrateAsync();
            }

            //init roles
            if (Roles.ToList().Count < 3)
            {
                Roles.Add(new Microsoft.AspNetCore.Identity.IdentityRole("Admin")
                {
                    Id = "Admin", NormalizedName = "ADMIN"
                });
                Roles.Add(new Microsoft.AspNetCore.Identity.IdentityRole("Manager")
                {
                    Id = "Manager", NormalizedName = "MANAGER"
                });
                Roles.Add(new Microsoft.AspNetCore.Identity.IdentityRole("User")
                {
                    Id = "User", NormalizedName = "USER"
                });
            }
            //init user roles
            if (UserRoles.ToList().Count < 3)
            {
                if (Users.Any(u => u.Email == "*****@*****.**"))
                {
                    var adminUser = Users.First(u => u.Email == "*****@*****.**");
                    if (!UserRoles.Any(ur => ur.UserId == adminUser.Id))
                    {
                        var adminRole = Roles.First(r => r.Name == "Admin");
                        UserRoles.Add(new Microsoft.AspNetCore.Identity.IdentityUserRole <string> {
                            UserId = adminUser.Id, RoleId = adminRole.Id
                        });
                    }
                }
                if (Users.Any(u => u.Email == "*****@*****.**"))
                {
                    var managerUser = Users.First(u => u.Email == "*****@*****.**");
                    if (!UserRoles.Any(ur => ur.UserId == managerUser.Id))
                    {
                        var managerRole = Roles.First(r => r.Name == "Manager");
                        UserRoles.Add(new Microsoft.AspNetCore.Identity.IdentityUserRole <string> {
                            UserId = managerUser.Id, RoleId = managerRole.Id
                        });
                    }
                }
                if (Users.Any(u => u.Email == "*****@*****.**"))
                {
                    var userUser = Users.First(u => u.Email == "*****@*****.**");
                    if (!UserRoles.Any(ur => ur.UserId == userUser.Id))
                    {
                        var userRole = Roles.First(r => r.Name == "User");
                        UserRoles.Add(new Microsoft.AspNetCore.Identity.IdentityUserRole <string> {
                            UserId = userUser.Id, RoleId = userRole.Id
                        });
                    }
                }
            }
            //init some restaurants
            if (Restaurants.ToList().Count < 3)
            {
                Restaurants.Add(new Restaurant("Pizzeria Italiano", "Szlak 34 Kraków"));
                Restaurants.Add(new Restaurant("Hong bao", "Chinatown 120 Chicago"));
                Restaurants.Add(new Restaurant("Wiejskie smaczki", "Wiejska 3 Warszawa"));
            }
            //init some managers
            if (RestaurantManagers.ToList().Count < 3)
            {
                RestaurantManagers.Add(new RestaurantManager(0, "Maciek", "Kowalski", 45));
                RestaurantManagers.Add(new RestaurantManager(0, "Przemek", "Nowak", 35));
                RestaurantManagers.Add(new RestaurantManager(0, "Zdzisław", "Jankowksi", 55));
            }
            //init some cuisine types
            if (CuisineTypes.ToList().Count < 3)
            {
                CuisineTypes.Add(new CuisineType(0, "Chinesse", "China"));
                CuisineTypes.Add(new CuisineType(0, "Fusion", null));
                CuisineTypes.Add(new CuisineType(0, "Italian", "Italy"));
            }
            //init some dishes
            if (Dishes.ToList().Count < 3)
            {
                Dishes.Add(new Dish(0, "Lasagne", MealType.Meat));
                Dishes.Add(new Dish(0, "Fish and chips", MealType.Fish));
                Dishes.Add(new Dish(0, "Fried vegetables", MealType.Vegan));
            }
            //init some discount type
            if (DiscountTypes.ToList().Count < 1)
            {
                DiscountTypes.Add(new DiscountType(0, "Early birds", 8, 16)
                {
                    Amount = 0.2m
                });
            }
            //can we init users from here?
            SaveChanges();
        }
Ejemplo n.º 19
0
 public void AddDish(Dish dish)
 {
     _dishRepository.AddDish(dish);
     Dishes.Add(dish);
     SortDishes();
 }
Ejemplo n.º 20
0
 public void AddDish(Dish dish)
 {
     Dishes.Add(dish);
 }