Esempio n. 1
0
        //Method that simulates a button press on one of the restaurantViews
        private void restaurant_Click(object sender, MouseEventArgs e)
        {
            RestaurantView tempView = (RestaurantView)sender;

            foreach (Restaurant r in list)
            {
                //the restaurantObject that is selected
                if (r.objectId == tempView.ObjectId)
                {
                    selected = r;
                    tempView.Selected(true);
                }
            }
            //the rest has to be 'deselected'
            foreach (RestaurantView r in flpRestaurants.Controls)
            {
                if (r == tempView)
                {
                    r.Selected(true);
                }
                else
                {
                    r.Selected(false);
                }
            }
        }
Esempio n. 2
0
        //Method which generates the RestaurantViews
        private void PopulateList()
        {
            Boolean toggle = false;

            foreach (Restaurant r in list)
            {
                RestaurantView tempView = new RestaurantView();
                tempView.RestaurantName = r.Name;
                tempView.LocationString = r.LocationString;
                tempView.ObjectId       = r.objectId;
                if (r.Active == false)
                {
                    tempView.Active = false;
                }
                //Toggle is used to change the color of the 'selected restaurantView'
                if (toggle == true)
                {
                    toggle = false;
                    tempView.BackgroundColor = System.Drawing.Color.FromArgb(209, 196, 233);
                }
                else
                {
                    toggle = true;
                    tempView.BackgroundColor = System.Drawing.Color.FromArgb(179, 229, 252);
                }
                flpRestaurants.Controls.Add(tempView);
                tempView.MouseClick += new MouseEventHandler(restaurant_Click);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Dom
 /// </summary>
 /// <returns></returns>
 public ActionResult Create()
 {
     using (var DB = new RestaurantsEntities())
     {
         RestaurantView restoView = new RestaurantView();
         ViewBag.Cuisines    = DB.Cuisines.ToList();
         ViewBag.PriceRanges = DB.PriceRanges.ToList();
         return(View(restoView));
     }
 }
Esempio n. 4
0
 private Restaurant ToRestaurant(RestaurantView view, string pic)
 {
     return(new Restaurant
     {
         IdRestaurant = view.IdRestaurant,
         Name = view.Name,
         Type = view.Type,
         Remarks = view.Remarks,
         Phone = view.Phone,
         ImagePathMenu = pic,
         Address = view.Address,
         Latitude = view.Latitude,
         Longitude = view.Longitude
     });
 }
        public RestaurantView GetRestaurantWithOrderItems(Guid id)
        {
            RestaurantView restaurantWithOrderItems = new RestaurantView();
            var            repo = new RestaurantsOrderItemsRepository();

            if (id != Guid.Empty)
            {
                Restaurants restaurant = GetRestaurant(id);
                List <RestaurantsOrderItems> orderItems = repo.GetRestaurantsOrderItems(id);
                restaurantWithOrderItems.Restaurant = restaurant;
                restaurantWithOrderItems.OrderItems = orderItems;
            }


            return(restaurantWithOrderItems);
        }
Esempio n. 6
0
        protected void Find_Click(object sender, EventArgs e)
        {
            RestaurantView.EmptyDataText = "No data available.";
            string         searchText     = [email protected];
            string         BaseURI        = ConfigurationManager.AppSettings["BaseURL"];
            FindRestaurant findRestaurant = new FindRestaurant(BaseURI);

            try
            {
                List <Restaurant> restaurants = findRestaurant.WithOutCode(searchText);
                RestaurantView.DataSource = restaurants;
                RestaurantView.DataBind();
            }
            catch (Exception)
            {
                RestaurantView.EmptyDataText = "Something got a bit wrong Please try again later";
                RestaurantView.DataBind();
            }
        }
Esempio n. 7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string directory        = AppDomain.CurrentDomain.BaseDirectory + "\\LaMarcel\\";
            string selectedFileName = AppDomain.CurrentDomain.BaseDirectory + "\\LaMarcel\\LaMarcel.json";
            string restaurant       = selectedFileName.Split('\\')[selectedFileName.Split('\\').Length - 1].Split('.')[0];
            string path             = selectedFileName;

            #region restaurant_pozitii
            JObject o1 = JObject.Parse(File.ReadAllText(path));

            // read JSON directly from a file
            using (StreamReader file = File.OpenText(path))
                using (JsonTextReader reader = new JsonTextReader(file))
                {
                    JObject restaurant_pozition_json = (JObject)JToken.ReadFrom(reader);
                    int     width  = Convert.ToInt32(restaurant_pozition_json[restaurant]["Dimensiuni"].ToString().Split(':')[1]);
                    int     height = Convert.ToInt32(restaurant_pozition_json[restaurant]["Dimensiuni"].ToString().Split(':')[0]);
                    pnlRestaurant = new RestaurantView(height, width, this.Size, restaurant);
                    this.Controls.Add(pnlRestaurant);
                    var tables = restaurant_pozition_json[restaurant]["Mese"];
                    int i      = 1;
                    foreach (var table in tables)
                    {
                        pnlRestaurant.AddTable(new Table(new TableModel(table, pnlRestaurant.GetXRatio(), pnlRestaurant.GetYRatio(), i++, lstItems)));
                    }
                }
            #endregion
            #region meniu_restaurant
            using (StreamReader file = File.OpenText(directory + "Menu.json"))
                using (JsonTextReader reader = new JsonTextReader(file))
                {
                    JObject menu_json = (JObject)JToken.ReadFrom(reader);
                    this.Menu = new Clase.Meniu(directory);
                    foreach (var item in menu_json)
                    {
                        Item MenuItem = new Item(item.Value);
                        Menu.AddItem(MenuItem);
                    }
                }
            #endregion
            btnCloseReciept.Show();
            btnAddItems.Show();
        }
Esempio n. 8
0
        public ActionResult Create(RestaurantView restaurantView)
        {
            restaurantView.UpLoadLogo(Request);
            using (var DB = new RestaurantsEntities())
            {
                ViewBag.Cuisines    = DB.Cuisines.ToList();
                ViewBag.PriceRanges = DB.PriceRanges.ToList();
                if (ModelState.IsValid)
                {
                    Restaurant resto = new Restaurant();
                    resto = restaurantView.ToRestaurant();

                    DB.Restaurants.Add(resto);
                    DB.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                return(View(restaurantView));
            }
        }
        public List <RestaurantView> GetRestaurantsWithItems()
        {
            List <RestaurantView> restaurantsWithOrderItems = new List <RestaurantView>();

            List <Restaurants> retaurant = GetRestaurants();

            var repo = new RestaurantsOrderItemsRepository();

            foreach (var res in retaurant)
            {
                List <RestaurantsOrderItems> orderItems = new List <RestaurantsOrderItems>();
                orderItems = repo.GetRestaurantsOrderItems(res.ID);
                RestaurantView view = new RestaurantView(res, orderItems);
                restaurantsWithOrderItems.Add(view);
            }


            return(restaurantsWithOrderItems);
        }
Esempio n. 10
0
        public async Task <ActionResult> Create(RestaurantView view)
        {
            if (ModelState.IsValid)
            {
                var pic    = string.Empty;
                var folder = "~/Content/Restaurants";

                if (view.ImageFileMenu != null)
                {
                    pic = FileHelper.UploadPhoto(view.ImageFileMenu, folder);
                    pic = $"{folder}/{pic}";
                }
                var restaurant = this.ToRestaurant(view, pic);
                db.Restaurants.Add(restaurant);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(view));
        }
Esempio n. 11
0
        public async Task <ActionResult> Edit(RestaurantView view)
        {
            if (ModelState.IsValid)
            {
                var pic    = view.ImagePathMenu;
                var folder = "~/Content/Restaurants";

                if (view.ImageFileMenu != null)
                {
                    pic = FileHelper.UploadPhoto(view.ImageFileMenu, folder);
                    pic = $"{folder}/{pic}";
                }

                var restaurant = this.ToRestaurant(view, pic);
                db.Entry(restaurant).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(view));
        }
Esempio n. 12
0
 //This method will effectively close the form after the user made a selection. If the checkbox is selected, it will apply it as the default option
 private void btnChangeLoad_Click(object sender, EventArgs e)
 {
     if (selected != null)
     {
         RestaurantView tempView = null;
         foreach (RestaurantView r in flpRestaurants.Controls)
         {
             if (r.ObjectId == selected.objectId)
             {
                 tempView = r;
             }
         }
         //Changes the default settings
         if (cbxDefault.Checked)
         {
             Properties.Settings.Default.defaultRestaurant = flpRestaurants.Controls.IndexOf(tempView);
             Properties.Settings.Default.Save();
         }
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
 }
Esempio n. 13
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog openFileDialog1 = new OpenFileDialog();

                openFileDialog1.InitialDirectory = "c:\\";
                openFileDialog1.Filter           = "JSON files (*.json)|*.json";
                openFileDialog1.FilterIndex      = 0;
                openFileDialog1.RestoreDirectory = true;
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    if (pnlRestaurant != null)
                    {
                        pnlRestaurant.Hide();
                        pnlRestaurant = null;
                    }
                    string directory        = Resources.Util.GetDirectoryOfFile(openFileDialog1.FileName);
                    string selectedFileName = openFileDialog1.FileName;
                    string restaurant       = selectedFileName.Split('\\')[selectedFileName.Split('\\').Length - 1].Split('.')[0];
                    string path             = selectedFileName;
                    #region restaurant_pozitii
                    JObject o1 = JObject.Parse(File.ReadAllText(path));

                    // read JSON directly from a file
                    using (StreamReader file = File.OpenText(path))
                        using (JsonTextReader reader = new JsonTextReader(file))
                        {
                            JObject restaurant_pozition_json = (JObject)JToken.ReadFrom(reader);
                            int     width  = Convert.ToInt32(restaurant_pozition_json[restaurant]["Dimensiuni"].ToString().Split(':')[1]);
                            int     height = Convert.ToInt32(restaurant_pozition_json[restaurant]["Dimensiuni"].ToString().Split(':')[0]);
                            pnlRestaurant = new RestaurantView(height, width, this.Size, restaurant);
                            this.Controls.Add(pnlRestaurant);
                            var tables = restaurant_pozition_json[restaurant]["Mese"];
                            int i      = 1;
                            foreach (var table in tables)
                            {
                                pnlRestaurant.AddTable(new Table(new TableModel(table, pnlRestaurant.GetXRatio(), pnlRestaurant.GetYRatio(), i++, lstItems)));
                            }
                        }
                    #endregion
                    #region meniu_restaurant
                    using (StreamReader file = File.OpenText(directory + "Menu.json"))
                        using (JsonTextReader reader = new JsonTextReader(file))
                        {
                            JObject menu_json = (JObject)JToken.ReadFrom(reader);
                            this.Menu = new Clase.Meniu(directory);
                            foreach (var item in menu_json)
                            {
                                Item MenuItem = new Item(item.Value);
                                Menu.AddItem(MenuItem);
                            }
                        }
                    #endregion
                    btnCloseReciept.Show();
                    btnAddItems.Show();
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }