コード例 #1
0
 public bool InsertIngreExchange(IngreExchange ingreExchange)
 {
     try
     {
         this.context.IngreExchanges.InsertOnSubmit(ingreExchange);
         context.SubmitChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
コード例 #2
0
 public IngreExchange GetIngreExchangeByRecipeDetailID(int RecipeDetailID)
 {
     try
     {
         IngreExchange exchange = (from ex in context.IngreExchanges
                                   where ex.RecipeDetailID == RecipeDetailID
                                   select ex).SingleOrDefault();
         return(exchange);
     }
     catch
     {
         return(null);
     }
 }
コード例 #3
0
 public IngreExchange GetIngreExchangeByIngreExchangeID(int IngreExchangeID)
 {
     try
     {
         IngreExchange exchange = (from ex in context.IngreExchanges
                                   where ex.IngreExchangeID == IngreExchangeID
                                   select ex).SingleOrDefault();
         return(exchange);
     }
     catch (Exception e)
     {
         return(null);
     }
 }
コード例 #4
0
        public ActionResult DoEditRecipeDetail(int RecipeDetailID, int RecID, int Step, int IngreID, float Amount
                                               , string Unit, string Desc, float AmountIngre, string UnitIngre, int Quantity, int IngreExchangeID)
        {
            info.EditRecipeDetail(RecipeDetailID, Step, IngreID, Amount, Unit, Desc);
            IngreExchange exchange = info.GetIngreExchangeByIngreExchangeID(IngreExchangeID);

            exchange.Amount          = AmountIngre;
            exchange.Unit            = UnitIngre;
            exchange.Quantity        = Quantity;
            exchange.IngreExchangeID = IngreExchangeID;
            info.EditIngreExchange(exchange);
            Recipe rec = info.GetRecipeByRecipeID(RecID);

            return(RedirectToAction("ReadRecipe", "Batender", new { FDID = rec.FDID }));
        }
コード例 #5
0
        public ActionResult DoCreateRecipeDetail(int RecipeID, int Step, int IngreID, double Amount,
                                                 string Unit, string Desc, float AmountIngre, string UnitIngre, int Quantity)
        {
            int  FDID           = info.GetRecipeByRecipeID(RecipeID).FDID;
            bool result         = info.InsertRecipeDetail(RecipeID, Step, IngreID, Amount, Unit, Desc);
            int  RecipeDetailID = info.GetLastRecipeDetailID();

            IngreExchange ingreExchange = new IngreExchange();

            ingreExchange.RecipeDetailID = RecipeDetailID;
            ingreExchange.FDID           = FDID;
            ingreExchange.IngreID        = IngreID;
            ingreExchange.Amount         = Amount;
            ingreExchange.Unit           = UnitIngre;
            ingreExchange.Quantity       = Quantity;
            bool result1 = info.InsertIngreExchange(ingreExchange);

            return(RedirectToAction("ReadRecipe", "Batender", new { FDID = FDID }));
        }
コード例 #6
0
 public bool EditIngreExchange(IngreExchange exchange)
 {
     try
     {
         IngreExchange ex = (from exc in context.IngreExchanges
                             where exc.IngreExchangeID == exchange.IngreExchangeID
                             select exc).SingleOrDefault();
         ex.FDID           = exchange.FDID;
         ex.IngreID        = exchange.IngreID;
         ex.Quantity       = exchange.Quantity;
         ex.RecipeDetailID = exchange.RecipeDetailID;
         ex.Unit           = exchange.Unit;
         this.context.SubmitChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
コード例 #7
0
        public ActionResult UpdateReady(int OrderItemID, int OrderID, int NumOfOrderItem, string view)
        {
            string    status = "Ready";
            bool      result = info.UpdateStatus(OrderItemID, status);
            OrderItem oi     = info.GetOrderItemByOrderItemID(OrderItemID);
            Recipe    recipe = info.GetRecipeByFDID(oi.FDID);

            if (recipe != null)
            {
                IEnumerable <RecipeDetail> details = info.GetAllRecipeDetailByRecipeID(recipe.RecID);
                foreach (RecipeDetail detail in details)
                {
                    IngreExchange exchange       = info.GetIngreExchangeByRecipeDetailID(detail.RecipeDetailID);
                    int           IngreID        = Convert.ToInt32(exchange.IngreID);
                    double        AmountDiscount = (exchange.Amount / 20) * oi.Quantity;
                    Ingredient    ingre          = info.GetIngredientByIngreID(IngreID);
                    ingre.Amount = ingre.Amount - AmountDiscount;
                    info.UpdateIngredient(ingre);
                }
            }
            if (view == "GetListOrderItemNeedPreparetion")
            {
                if (NumOfOrderItem <= 1)
                {
                    bool resultUpdateStatusOrder = info.UpdateOrderStatus(OrderID, status);
                }
                return(RedirectToAction("GetListOrderItemNeedPreparetion", "Batender"));
            }
            else
            {
                if (NumOfOrderItem > 1)
                {
                    return(RedirectToAction("DetailOrder", "Batender", new { OrderID = OrderID }));
                }
                else
                {
                    bool resultUpdateStatusOrder = info.UpdateOrderStatus(OrderID, status);
                    return(RedirectToAction("GetListOrder", "Batender"));
                }
            }
        }
コード例 #8
0
        public ActionResult EditRecipeDetail(int RecipeDetailID)
        {
            RecipeDetail             recipeDetail   = info.GetRecipeDetailByRecipeDetailID(RecipeDetailID);
            List <SelectListItem>    listIngredient = new List <SelectListItem>();
            IEnumerable <Ingredient> ingres         = info.GetAllIngredient();

            foreach (var item in ingres)
            {
                SelectListItem select = new SelectListItem();
                select.Value = item.IngreID.ToString();
                select.Text  = item.Name.ToString();
                listIngredient.Add(select);
            }
            ViewData["listIngreID"] = listIngredient;
            Recipe        rec      = info.GetRecipeByRecipeID(recipeDetail.RecID);
            IngreExchange exchange = info.GetIngreExchangeByRecipeDetailID(recipeDetail.RecipeDetailID);

            ViewData["exchange"] = exchange;
            ViewData["FDID"]     = rec.FDID;
            return(View(recipeDetail));
        }
コード例 #9
0
 public bool InsertIngreExchange(IngreExchange ingreExchange)
 {
     return(this._ingreExchangeDAO.InsertIngreExchange(ingreExchange));
 }
コード例 #10
0
 public bool EditIngreExchange(IngreExchange exchange)
 {
     return(this._ingreExchangeDAO.EditIngreExchange(exchange));
 }