Ejemplo n.º 1
0
        public ActionResult Edit(int id, meal mel, HttpPostedFileBase UploadImage)
        {
            if (UploadImage == null)
            {
                mel.picture = (from x in db.meals where x.Id == mel.Id select x.picture).FirstOrDefault();
            }

            else
            {
                System.IO.File.Delete(Server.MapPath("~/pics/") + (from x in db.meals where x.Id == id select x.picture).FirstOrDefault());
                if (UploadImage.ContentLength > 0)
                {
                    string filename = unique() + Path.GetExtension(UploadImage.FileName);
                    string folder   = Path.Combine(Server.MapPath("~/pics/"), filename);
                    UploadImage.SaveAs(folder);
                    mel.picture = filename;
                }
            }
            db.meals.AddOrUpdate(mel);
            db.SaveChanges();
            ViewBag.category_id = new SelectList(db.categories, "Id", "name");
            meal m = (from x in db.meals where x.Id == id select x).FirstOrDefault();

            ViewBag.message = "تم تحديث بيانات الوجبة";
            return(View(m));
        }
Ejemplo n.º 2
0
        public ActionResult details(int id, int?add)
        {
            bool     added = false;
            int      user  = Convert.ToInt32(Session["id"]);
            meal     m     = (from x in db.meals where x.Id == id select x).FirstOrDefault();
            customer c     = (from x in db.customers where x.Id == user select x).FirstOrDefault();
            favorit  f     = (from x in db.favorits where x.customer.Id == user && x.meal.Id == id select x).FirstOrDefault();

            if (f != null)
            {
                added = true;
            }
            if (f == null && add != null)
            {
                favorit fav = new favorit();
                fav.meal     = m;
                fav.customer = c;
                db.favorits.Add(fav);
                db.SaveChanges();
                added = true;
            }
            else if (f != null && add != null)
            {
                db.favorits.Remove(f);
                db.SaveChanges();
                added = false;
            }
            ViewBag.stat = added;
            return(View(m));
        }
Ejemplo n.º 3
0
        public ActionResult create_offer(int id)
        {
            if (Session["admin"] == null)
            {
                return(RedirectToAction("access_denied", "Home", null));
            }
            meal m = (from x in db.meals where x.Id == id select x).FirstOrDefault();

            return(View(m));
        }
Ejemplo n.º 4
0
        public ActionResult Edit(int id)
        {
            if (Session["admin"] == null)
            {
                return(RedirectToAction("login_signup", "Home", null));
            }
            meal m = (from x in db.meals where x.Id == id select x).FirstOrDefault();

            ViewBag.category_id = new SelectList(db.categories, "Id", "name");
            return(View(m));
        }
Ejemplo n.º 5
0
        public ActionResult create_offer(int id, meal mel)
        {
            ViewBag.message = "تم انشاء العرض";
            meal nm = (from x in db.meals where x.Id == mel.Id select x).FirstOrDefault();

            nm.discount_price = mel.discount_price;
            db.meals.AddOrUpdate(nm);
            db.SaveChanges();
            meal m = (from x in db.meals where x.Id == id select x).FirstOrDefault();

            return(View(m));
        }
Ejemplo n.º 6
0
    //totaal voedingswaarden van ingevoerde maaltijden
    public meal get_total_value()
    {
        meal total_meal = new meal();

        total_meal.name = "total";
        foreach (meal temp in meal_list)
        {
            total_meal.carb = total_meal.carb + temp.carb;
            total_meal.fat  = total_meal.fat + temp.fat;
            total_meal.prot = total_meal.prot + temp.prot;
            total_meal.kcal = total_meal.kcal + temp.kcal;
        }
        return(total_meal);
    }
Ejemplo n.º 7
0
        public ActionResult delete_offer(int?id)
        {
            if (Session["admin"] == null)
            {
                return(RedirectToAction("access_denied", "Home", null));
            }
            if (id != null)
            {
                meal m = (from x in db.meals where x.Id == id select x).FirstOrDefault();
                m.discount_price = m.price;
                db.meals.AddOrUpdate(m);
                db.SaveChanges();
            }
            List <meal> lst = (from x in db.meals where x.price != x.discount_price select x).ToList();

            return(View(lst));
        }
Ejemplo n.º 8
0
        // Overriding Welcome to say coucou au customer
        public void Welcome(Customer customer)
        {
            Console.WriteLine("Welcome " + customer.name + " !");
            meal m = new meal();

            m.energy = 0;
            m.bill   = 0;
            foreach (Dish d in menu)
            {
                if (customer.m_preferences(d))
                {
                    Console.WriteLine("You ordered " + d.name);
                    m.bill   += d.price;
                    m.energy += d.calories;
                }
            }
            Console.WriteLine("You ate " + m.energy + " calories and payed " + m.bill + " euros !");
        }
Ejemplo n.º 9
0
        public ActionResult Create(HttpPostedFileBase UploadImage, FormCollection col)
        {
            string n = "";

            ViewBag.category_id = new SelectList(db.categories, "Id", "name");
            if (UploadImage.ContentLength > 0)
            {
                string filename = unique() + Path.GetExtension(UploadImage.FileName);
                string folder   = Path.Combine(Server.MapPath("~/pics/"), filename);
                UploadImage.SaveAs(folder);
                n = filename;
            }
            else
            {
                return(View());
            }
            string      mealname = col[1].Trim();
            List <meal> l        = (from x in db.meals where x.name == mealname select x).ToList();

            if (l.Count > 0)
            {
                ViewBag.message = "هنالك وجبة بنفس الاسم";
                return(View());
            }
            meal m = new meal();

            m.name           = col[1].Trim();
            m.picture        = n;
            m.price          = Convert.ToInt32(col[2].Trim());
            m.discount_price = m.price;
            m.category_id    = Convert.ToInt32(col[4].Trim());
            m.discription    = col[3].Trim();
            db.meals.Add(m);
            db.SaveChanges();
            ViewBag.message = "تم إضافة الوجبة";
            return(View());
        }
Ejemplo n.º 10
0
 //maaltijd toevoegen per maal struct
 public void add_meal(meal m)
 {
     meal_list.Add(m);
 }