public IEnumerable <MenuItem> GetMenuForItemKind(MenuItemKind kind) { return((from m in restourantContext.MenuItems where m.Kind == kind && m.Active orderby m.DisplayName select m).ToList()); //return restourantContext.MenuItems // .Where(m => m.Kind == kind && m.Active) // .OrderBy(m => m.DisplayName); }
public void AddMenuItem_adds_item_with_correct_contents() { var mockContext = new MockDBContextFactory().Create(); var repository = new RestourantRepository(mockContext); const string itemName = "item name"; const double itemPrice = 19.99; const MenuItemKind itemKind = MenuItemKind.DRINK; repository.AddMenuItemToMenu(itemName, itemPrice, itemKind, EmployeeRole.BARTENDER); var inserted = mockContext.MenuItems.Last(); Assert.AreEqual(itemName, inserted.DisplayName); Assert.AreEqual(itemPrice, inserted.Price); Assert.AreEqual(itemKind, inserted.Kind); }
public MenuItem AddMenuItemToMenu(string name, double price, MenuItemKind kind, EmployeeRole worker) { if (worker != EmployeeRole.BARTENDER && worker != EmployeeRole.COOK) { throw new ArgumentException("Specified employee can't change menu", nameof(worker)); } var menuItem = new MenuItem() { DisplayName = name, Price = price, Kind = kind, Active = true }; restourantContext.MenuItems.Add(menuItem); restourantContext.SaveChanges(); return(menuItem); }
// GET api/<controller>?kind=<kind> public IEnumerable <Menu> Get([EnumDataType(typeof(MenuItemKind))] MenuItemKind kind) { if (!Enum.IsDefined(typeof(MenuItemKind), kind)) { throw new HttpResponseException(HttpStatusCode.BadRequest); } if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } return(repository.GetMenuForItemKind(kind) .Select(m => new Menu() { Id = m.ID, Name = m.DisplayName, Price = m.Price, Kind = m.Kind, IsActive = m.Active })); }
/// <summary> /// Initializes a new instance of the <see cref="ContextMenuItemViewModel"/> class /// </summary> /// <param name="header">The header for this menu item</param> /// <param name="inputGestureText">The Input Gesture text can shows a keyboard combination</param> /// <param name="executeCommandAction">The action that the <see cref="ReactiveCommand{Object}"/> shall execute</param> /// <param name="thing">The <see cref="Thing"/> related to the command</param> /// <param name="canExecute">The state of the command</param> /// <param name="menuItemKind">The <see cref="MenuItemKind"/></param> public ContextMenuItemViewModel(string header, string inputGestureText, Action <Thing> executeCommandAction, Thing thing, bool canExecute, MenuItemKind menuItemKind = MenuItemKind.None) { this.CanExecute = canExecute; this.MenuCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.CanExecute)); ((ReactiveCommand <object>) this.MenuCommand).Subscribe(_ => executeCommandAction(this.RelatedThing)); this.Header = header; this.InputGestureText = inputGestureText; this.RelatedThing = thing; this.MenuItemKind = menuItemKind; this.thingKind = thing.ClassKind; }
/// <summary> /// Initializes a new instance of the <see cref="ContextMenuItemViewModel"/> class /// </summary> /// <param name="header">The header for this menu item</param> /// <param name="inputGestureText">The Input Gesture text can shows a keyboard combination</param> /// <param name="command">The <see cref="ICommand"/> bound to this command</param> /// <param name="menuItemKind">The <see cref="MenuItemKind"/> of this <see cref="ContextMenuItemViewModel"/></param> /// <param name="thingKind">The <see cref="ClassKind"/> this menu-item operates on</param> public ContextMenuItemViewModel(string header, string inputGestureText, ICommand command, MenuItemKind menuItemKind = MenuItemKind.None, ClassKind thingKind = ClassKind.Thing) { this.Header = header; this.InputGestureText = inputGestureText; this.MenuCommand = command; this.MenuItemKind = menuItemKind; this.thingKind = thingKind; this.SubMenu = new List <ContextMenuItemViewModel>(); }
public IEnumerable <OrderItem> GetOpenOrdersForKind(MenuItemKind kind) { return(restourantContext.OrdersWithMenu .Where(order => !order.Delivered && order.Item.Kind == kind) .ToList()); }