public JsonResult Add(MenuSchedule mo) { MenuItem menuitem = _menuItemService.GetMenuItemById(mo.MenuItemId); bool status = false; if (Session["cart"] == null) { List <Cart> li = new List <Cart> { new Cart(db.MenuItems.Find(mo.MenuItemId), mo) }; Session["cart"] = li; Session["count"] = mo.Quantity; Session["Amount"] = mo.Quantity * menuitem.CompanyPrice; status = true; } else { List <Cart> li = (List <Cart>)Session["cart"]; int check = isExistingCheck(mo.MenuItemId); var qantityse = Convert.ToInt32(Session["count"]) + mo.Quantity; if (check == 0 && qantityse <= 5) { li[check].Quantity += mo.Quantity; status = true; Session["count"] = li[check].Quantity; Session["Amount"] = qantityse * menuitem.CompanyPrice; } else { status = false; } Session["cart"] = li; } return(Json(new { totalquantity = Session["count"], status = status })); }
private async Task <SkillResponse> GetMenuResponse(Intent intent, Session session) { // Retrieve date from the intent slot var dateSlot = intent.Slots[DateKey]; // Create response string output; DateTime date; var endSession = false; if (dateSlot != null && DateTime.TryParse(dateSlot.Value, out date)) { // Retrieve and return the menu response if (_menuSchedule == null) { _menuSchedule = await LoadMenuSchedule(); } var menu = _menuSchedule.GetMenuForDate(date); if (menu != null) { output = _menuSchedule.GetMenuForDate(date).ToString(date); endSession = true; } else { output = $"Sorry, no menu is available for {date.ToStringWithSuffix("d MMMM")}. Please try another date or say quit to exit"; } } else { // Render an error since we don't know what the date requested is output = "I'm not sure which date you require, please try again or say quit to exit."; } // Return response, passing flag for whether to end the conversation return(BuildSkillResponse(intent.Name, output, endSession)); }
public Cart(MenuItem menuItem, MenuSchedule mo) { MenuItem = menuItem; Quantity = mo.Quantity; MenuSheduleId = mo.Id; }