}//CheckCustomer

        //-------------------------------------------------------------------------------------------------------//

        /// <summary>
        /// Checks whether product exists.
        /// </summary>
        /// <param name="prodCode">Product Code</param>
        /// <returns>This Product or blank Product.</returns>
        public Product CheckProduct(string prodCode)
        {
            Product product;

            if (ProductMap.ContainsKey(prodCode))
            {
                product = ProductMap[prodCode];
            }
            else
            {
                product = new Product();
            }//else

            return(product);
        }//CheckProduct
Beispiel #2
0
        public async Task <IActionResult> OnPostAsync(int venueId)
        {
            if (!ModelState.IsValid)
            {
                await FetchData(venueId).ConfigureAwait(false);

                return(this.TurboPage());
            }

            if (!await FetchData(venueId).ConfigureAwait(false))
            {
                return(RedirectToPage("/Index"));
            }

            var productIds         = Input.ProductIds.Select(id => int.Parse(id)).ToList();
            var selectedProductIds = productIds
                                     .Where(id => ProductMap.ContainsKey(id))
                                     .Select(id => ProductMap[id])
                                     .Where(product => product.VenueId == venueId)
                                     .Select(product => product.ProductId)
                                     .ToList();

            var result = await menus.CreateFullMenu(new NewMenu
            {
                Products        = selectedProductIds,
                MenuName        = Input.MenuName,
                MenuDescription = Input.MenuDescription,
                VenueId         = venueId
            }).ConfigureAwait(false);

            if (result.IsSuccess)
            {
                return(this.RedirectToPage("/Menu", new
                {
                    menuId = result.Value
                }));
            }

            return(this.Page());
        }