public async Task <MenuItemPageVM> GetMenuItemPageAsync(int id) { var menu = await _db.MenuItems.GetByIdAsync(id); if (menu == null) { throw new Exception("MenuItem not found"); } var retMenu = new MenuItemPageVM(menu, menu.Menu.Location.Currency); return(retMenu); }
public async Task <MenuItemPageVM> CreateMenuItemAsync(CreateMenuItemVM menu) { var fileId = (await _fileService.CreateFileDbAsync(menu.Photo)).Id; var dbMenu = new MenuItem { Title = menu.Title, Info = menu.Info, Note = menu.Note, Price = menu.Price, PriceWithSales = menu.PriceWithSales, IsActive = menu.IsActive, MenuId = menu.MenuId, FileModelId = fileId }; var menuNew = await _db.MenuItems.CreateAsync(dbMenu); var menu2 = _db.Menus.GetAll().FirstOrDefault(m => m.Id == menu.MenuId); var currency = menu2?.Location.Currency; var retMenu = new MenuItemPageVM(menuNew, currency); return(retMenu); }