Esempio n. 1
0
        private KitchenModel GetKitchenModel()
        {
            KitchenModel             model  = new KitchenModel();
            List <Models.TableOrder> tables = new List <Models.TableOrder>();

            Models.TableOrder          order;
            List <Services.TableOrder> alltables = new List <Services.TableOrder>();

            Services.Table table;
            try {
                alltables = _orderService.GetKitchenOrders();
                foreach (Services.TableOrder tab in alltables)
                {
                    order           = new Models.TableOrder();
                    table           = _orderService.GetTable(tab.TableId);
                    order.TableName = table.Name;
                    order.Order     = tab;
                    tables.Add(order);
                }
                model.Tables = tables;
                return(model);
            }
            catch (Exception ex) {
                base.Log(ex);
            }
            finally {
            }

            return(null);
        }
        public async Task <IActionResult> PutKitchenModel([FromRoute] int id, [FromBody] KitchenModel KitchenModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != KitchenModel.ID)
            {
                return(BadRequest());
            }

            _context.Entry(KitchenModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!KitchenModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 3
0
        // GET: Kitchen
        public ActionResult Index()
        {
            KitchenModel objKitchenModel = new KitchenModel();

            objKitchenModel.ProductList = new List <ProductItem>();

            objSyncFoodContext = new SyncFoodContext();
            using (IUnitOfWork unitOfWork = new UnitOfWork(objSyncFoodContext))
            {
                Kitchen objKitchen = unitOfWork.Kitchens.GetKitchenByName(DateTime.Now.ToShortDateString());
                int     kitchenId  = objKitchen.Id;

                FoodSync.Core.Model.Domain.User objUser = unitOfWork.Users.SingleOrDefault(u => u.UserName == User.Identity.Name);

                double totalCalloriesInKitchen             = 0.0;
                List <KitchenProduct> lstProductsInKitchen = unitOfWork.Kitchens.GetProductsFromKitchen(kitchenId, objKitchen.Name, objUser.Id);
                foreach (KitchenProduct product in lstProductsInKitchen)
                {
                    ProductItem objPI = new ProductItem();
                    objPI.Id        = product.UserKitchenId;
                    objPI.ProductId = product.ProductId;
                    objPI.Name      = product.ProductName;
                    objKitchenModel.ProductList.Add(objPI);

                    totalCalloriesInKitchen += product.ProductCallories;
                }
                objKitchenModel.TotalCallories         = totalCalloriesInKitchen;
                objKitchenModel.OptimalCalloriesPerDay = objUser.OptimalCalloriesPerDay;
            }
            return(View(objKitchenModel));
        }
Esempio n. 4
0
        public ActionResult DeleteConfirmed(int id)
        {
            KitchenModel kitchenModel = db.Kitchens.Find(id);

            db.Kitchens.Remove(kitchenModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 5
0
        public KitchenController(KitchenModel kitchenModel, KitchenView kitchenView)
        {
            this.kitchenModel = kitchenModel; this.kitchenView = kitchenView;

            kitchenView.MouseMove += new MouseEventHandler(this.Mouse_Move);

            Console.WriteLine("Instanciation du Controller sans problèmes");
        }
Esempio n. 6
0
 public ActionResult Edit([Bind(Include = "Id,Name")] KitchenModel kitchenModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(kitchenModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(kitchenModel));
 }
        public async Task <IActionResult> Index(string date)
        {
            var vm = new KitchenModel();

            vm.BreakfastBookingsModels = await _context.BreakfastBookings.Where(b => b.Date == date).ToListAsync();

            vm.CheckInsModels = await _context.CheckIns.Where(c => c.Date == date).ToListAsync();


            return(View(vm));
        }
Esempio n. 8
0
        public ActionResult Create([Bind(Include = "Id,Name")] KitchenModel kitchenModel)
        {
            if (ModelState.IsValid)
            {
                db.Kitchens.Add(kitchenModel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(kitchenModel));
        }
        public async Task <IActionResult> PostKitchenModel([FromBody] KitchenModel KitchenModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            db.Add(KitchenModel);
            db.Save();
            //_context.DriveThru.Add(KitchenModel);
            //await _context.SaveChangesAsync();

            return(CreatedAtAction("GetKitchenModel", new { id = KitchenModel.ID }, KitchenModel));
        }
Esempio n. 10
0
        public async Task Run(BuilderSettings builderSettings)
        {
            var builder = new BuildSolution(builderSettings);

            var testProject = new KitchenModel();

            string messages = await builder.RunAsync(testProject.Project);

            Console.WriteLine(messages);
            if (!messages.Equals("Success"))
            {
                Console.Read();
            }
        }
Esempio n. 11
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            KitchenModel kitchenModel = db.Kitchens.Find(id);

            if (kitchenModel == null)
            {
                return(HttpNotFound());
            }
            return(View(kitchenModel));
        }
Esempio n. 12
0
        public KitchenView(KitchenModel kitchenModel)
        {
            InitializeComponent();

            this.kitchenModel = kitchenModel;

            GraphicsElement = this.CreateGraphics();

            my_Timer.Tick += new EventHandler(this.Render);

            my_Timer.Interval = 100;

            my_Timer.Start();

            Console.WriteLine("L'instanciation de la View est Réussis");
        }
Esempio n. 13
0
        static void Main(string[] args)
        {
            Console.WriteLine("projet Cuisine");

            KitchenModel kitchenModel = new KitchenModel();

            KitchenView kitchenView = new KitchenView(kitchenModel);

            KitchenController kitchenController = new KitchenController(kitchenModel, kitchenView);

            //Thread th = new Thread(kitchenModel.socket.testCuisine);
            //th.Start();


            Application.Run(kitchenView);


            Console.ReadKey();
        }
        public async Task <IActionResult> KitchenPage(string id)
        {
            DateTime date            = Convert.ToDateTime(id);
            var      breakfastOrders = await _db.BreakfastOrders.Where(m => m.Date.Date == date.Date).ToListAsync();

            if (breakfastOrders == null)
            {
                return(NotFound());
            }

            var totalAdultsForChosenDate   = 0;
            var totalChildrenForChosenDate = 0;
            var totalAdultsCheckedIn       = 0;
            var totalChildrenCheckedIn     = 0;

            foreach (var breakfeastOrder in breakfastOrders)
            {
                totalAdultsForChosenDate   += breakfeastOrder.Adults;
                totalChildrenForChosenDate += breakfeastOrder.Children;
                totalAdultsCheckedIn       += breakfeastOrder.CheckedInAdults;
                totalChildrenCheckedIn     += breakfeastOrder.CheckedInChildren;
            }

            var kitchenModel = new KitchenModel
            {
                TotalAdultsCheckedIn       = totalAdultsCheckedIn,
                TotalAdultsForChosenDate   = totalAdultsForChosenDate,
                TotalChildrenCheckedIn     = totalChildrenCheckedIn,
                TotalChildrenForChosenDate = totalChildrenForChosenDate,
                TotalForChosenDate         = totalChildrenForChosenDate + totalAdultsForChosenDate,
                NotCheckedInAdults         = totalAdultsForChosenDate - totalAdultsCheckedIn,
                NotCheckedInChildren       = totalChildrenForChosenDate - totalChildrenCheckedIn,
                NotCheckedInTotal          = (totalAdultsForChosenDate - totalAdultsCheckedIn) +
                                             (totalChildrenForChosenDate - totalChildrenCheckedIn),
                ChosenDate = date.ToString("yyyy-MM-dd")
            };

            return(View(kitchenModel));
        }
 public KitchenApiController(KitchenModel kitchenModel)
 {
     this._kitchenModel = kitchenModel;
 }
Esempio n. 16
0
 public KitchenController()
 {
     model    = new KitchenModel();
     isActive = true;
 }
        public ActionResult AddToKitchen()
        {
            string productName = String.Empty;

            if (Session[ProductModel.SessionName] != null)
            {
                productName = Session[ProductModel.SessionName].ToString();
            }

            KitchenModel objKitchenModel = new KitchenModel();

            objSyncFoodContext = new SyncFoodContext();
            using (IUnitOfWork unitOfWork = new UnitOfWork(objSyncFoodContext))
            {
                Product objProduct = unitOfWork.Products.GetProductByName(productName);
                FoodSync.Core.Model.Domain.User objUser = unitOfWork.Users.SingleOrDefault(u => u.UserName == User.Identity.Name);
                Kitchen objKitchen = unitOfWork.Kitchens.GetKitchenByName(DateTime.Now.ToShortDateString());

                if (objKitchen == null)
                {
                    objKitchen      = new Kitchen();
                    objKitchen.Name = DateTime.Today.ToShortDateString();
                    unitOfWork.Kitchens.Add(objKitchen);
                    unitOfWork.Complete();
                }

                if (objProduct == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                int kitchenId = objKitchen.Id;
                int userId    = objUser.Id;
                int productId = objProduct.Id;

                bool userKitchenExists = unitOfWork.Kitchens.UserKitchenExists(userId, kitchenId);
                if (userKitchenExists)
                {
                    unitOfWork.Kitchens.AddProductToKitchen(productId, userId, kitchenId, DateTime.Today.ToShortDateString());

                    /*
                     * objKitchenModel.ProductList = new List<ProductItem>();
                     * List<KitchenProduct> lstProductsInKitchen = unitOfWork.Kitchens.GetProductsFromKitchen(kitchenId, objKitchen.Name);
                     * foreach (KitchenProduct product in lstProductsInKitchen)
                     * {
                     *  ProductItem objPI = new ProductItem();
                     *  objPI.Id = product.UserKitchenId;
                     *  objPI.ProductId = product.ProductId;
                     *  objPI.Name = product.ProductName;
                     *  objKitchenModel.ProductList.Add(objPI);
                     * }
                     */
                }
                else
                {
                    unitOfWork.Kitchens.AddProductToKitchen(productId, userId, objKitchen.Id, DateTime.Today.ToShortDateString());

                    /*
                     * objKitchenModel.ProductList = new List<ProductItem>();
                     * List<KitchenProduct> lstProductsInKitchen = unitOfWork.Kitchens.GetProductsFromKitchen(kitchenId, objKitchen.Name);
                     * foreach (KitchenProduct product in lstProductsInKitchen)
                     * {
                     *  ProductItem objPI = new ProductItem();
                     *  objPI.Id = product.UserKitchenId;
                     *  objPI.ProductId = product.ProductId;
                     *  objPI.Name = product.ProductName;
                     *  objKitchenModel.ProductList.Add(objPI);
                     * }
                     */
                }

                if (unitOfWork.DataSet.Exists(objUser.Id, DateTime.Today.ToShortDateString()))
                {
                    unitOfWork.DataSet.UpdateTrainingSet(objUser.Id, DateTime.Today.ToShortDateString(), 1);
                }
                else
                {
                    unitOfWork.DataSet.AddTrainingSet(objUser.Id, (int)DateTime.Now.DayOfWeek, 0, 1, DateTime.Today.ToShortDateString());
                }

                objKitchenModel.Name = objProduct.Name;
            }
            return(RedirectToAction("Index"));
        }