Ejemplo n.º 1
0
        // GET: MenuItemController/Delete/5
        public async Task <IActionResult> Delete(int id, MenuItemVM model)
        {
            var obj = await _repo.FindById(id);

            if (obj == null)
            {
                return(NotFound());
            }

            if (obj.Image != null)
            {
                string uploadsFolder = Path.Combine(_webHostEnvironment.WebRootPath, "images");

                var imagePath = Path.Combine(uploadsFolder, obj.Image);
                if (System.IO.File.Exists(imagePath))
                {
                    System.IO.File.Delete(imagePath);
                }
            }

            var success = await _repo.Delete(obj);

            if (!success)
            {
                return(BadRequest());
            }


            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 2
0
        public ActionResult Edit([Bind(Include = "Id,Name,Description,Price,Image")] MenuItemVM menuItem)
        {
            if (ModelState.IsValid)
            {
                MenuItem res = _menuFacade.Update(new MenuItem
                {
                    Id          = menuItem.Id,
                    Name        = menuItem.Name,
                    Description = menuItem.Description,
                    Price       = menuItem.Price
                });

                //var fileName = Path.GetFileName(menuItem.Image.FileName);
                //var path = Path.Combine(Server.MapPath("~/Images/"), fileName);
                //Stream imgFileStream = menuItem.Image.InputStream;
                //byte[] documentBytes = new byte[imgFileStream.Length];
                //imgFileStream.Read(documentBytes, 0, documentBytes.Length);

                //if (fileName != null && path != null)
                //{
                //    Image img = _imageFacade.UploadMenuItemImage(new Image
                //    {
                //        Name = fileName,
                //        Size = menuItem.Image.ContentLength,
                //        Type = menuItem.Image.ContentType,
                //        FileContent = documentBytes,
                //        CreatedOn = DateTime.Now,
                //        Source = res.Id
                //    });
                //}
                return(RedirectToAction("Details", new { Id = res.Id }));
            }

            return(View(menuItem));
        }
        /// <inheritdoc />
        public BindableMenuTestVM()
        {
            RegisterChildren(() => this);

            MenuItemVM test, more, check;

            Menu.Add(test = new MenuItemVM {
                Caption = "_Test"
            });
            test.Items.Add(new MenuItemVM {
                Caption = "ActionCommand", CommandAction = { MːExecutedCallback = DoCommand }
            });
            test.Items.Add(new MenuItemVM {
                Caption = "Cut", Command = ApplicationCommands.Cut
            });
            test.Items.Add(new MenuItemVM {
                Caption = "-"
            });
            test.Items.Add(more = new MenuItemVM {
                Caption = "More"
            });
            more.Items.Add(check = new MenuItemVM {
                Caption = "Checker", IsCheckable = true
            });
            more.Items.Add(new MenuItemVM {
                Caption = "Dummy"
            });

            // #1 synchronize 2 bool values (functional, not optimized for reuse)
            // Fields[nameof(IsChecked)].ValueChangedEvent.add = (s, e) => check.IsChecked = (bool)e.NewValue;
            // check.Fields[nameof(MenuItemVM.IsChecked)].ValueChangedEvent.add = (s, e) => IsChecked = (bool)e.NewValue;
            // #2 synchronize 2 bool values (experimental)
            FieldBindingOperations.SetBinding(Fields[nameof(IsChecked)], new FieldBinding(check.Fields[nameof(MenuItemVM.IsChecked)]));
        }
Ejemplo n.º 4
0
        private MenuItem CreateMenuItem(MenuItemVM vm, Expression <Func <bool> > hasItemsProperty)
        {
            var menuItem = new MenuItem();

            menuItem.SetBinding(HeaderedItemsControl.HeaderProperty, "Name");
            menuItem.SetBinding(MenuItem.CommandParameterProperty, "CommandParameter");
            menuItem.SetBinding(MenuItem.CommandProperty, "Command");
            menuItem.SetBinding(MenuItem.IsCheckableProperty, "IsCheckable");
            menuItem.SetBinding(MenuItem.IsCheckedProperty, "IsChecked");
            var image = new Image();

            image.Stretch = Stretch.None;
            image.SetBinding(Image.SourceProperty, "Icon");
            menuItem.Icon        = image;
            menuItem.DataContext = vm;

            var visibilityBinding = new Binding("IsEnabled")
            {
                Converter = new BoolToVisibilityConverter(),
                Source    = menuItem
            };

            BindingOperations.SetBinding(menuItem, UIElement.VisibilityProperty, visibilityBinding);

            menuItem.AddPropertyChangedHandler(UIElement.VisibilityProperty, (o, e) =>
            {
                this.RaisePropertyChanged(hasItemsProperty);
            });

            return(menuItem);
        }
Ejemplo n.º 5
0
        public IActionResult OnGet(int?id)
        {
            var categories = _unitOfWork.Category.List();
            var foodTypes  = _unitOfWork.FoodType.List();

            MenuItemObj = new MenuItemVM {
                MenuItem     = new MenuItem(),
                CategoryList = categories.Select(c => new SelectListItem {
                    Value = c.Id.ToString(), Text = c.Name
                }),
                FoodTypeList = foodTypes.Select(f => new SelectListItem {
                    Value = f.Id.ToString(), Text = f.Name
                }),
            };

            if (id != 0)
            {
                MenuItemObj.MenuItem = _unitOfWork.MenuItem.Get(u => u.Id == id, true);
                if (MenuItemObj == null)
                {
                    return(NotFound());
                }
            }

            return(Page());
        }
Ejemplo n.º 6
0
        public IActionResult OnGet(int?id)
        {
            //load dropdown list
            MenuItemObj = new MenuItemVM
            {
                CategoryList = _unitOfWork.Category.GetCategoryListForDropdown(),
                FoodTypeList = _unitOfWork.FoodType.GetFoodTypeListForDropdown(),

                //then initialized the main menu item

                MenuItem = new Models.MenuItem()
            };

            //check if it is empty and initialize menu item
            if (id != null)
            {
                MenuItemObj.MenuItem = _unitOfWork.MenuItem.GetFirstOrDefault(u => u.Id == id);
                if (MenuItemObj.MenuItem == null)
                {
                    return(NotFound());
                }
            }

            return(Page());
        }
Ejemplo n.º 7
0
 public PatchnoteGeneratorModule()
 {
     _newPatchnoteMenuItem = new MenuItemVM(this.L("patchnote_generator", "new_patchnote_menu_item"))
     {
         Icon = BitmapImageEx.LoadAsFrozen("Resources/Images/Patchnote_16.png")
     };
 }
Ejemplo n.º 8
0
        private MenuItemVM CreateMenuItemLink(string fullPath)
        {
            MenuItemVM menuItem = new MenuItemVM();

            menuItem.Name   = this.GetFriendlyName(Path.GetFileNameWithoutExtension(fullPath));
            menuItem.Action = $"UpdateUrl(~?w={menuItem.Name});UpdateSector(content,{GetFullPathUrl(fullPath)},false,false)";
            return(menuItem);
        }
Ejemplo n.º 9
0
        private MenuItemVM CreateMenuItemFunction(string functionName)
        {
            MenuItemVM menuItem = new MenuItemVM();

            menuItem.Name   = functionName;
            menuItem.Action = $"UpdateUrl(~?w={menuItem.Name});UpdateSector(content,~/api/Function/GetContent?name={functionName},,false,false)";
            return(menuItem);
        }
        private void UpdateNewMenuItems()
        {
            _newPatchnoteMenuItem.MenuItems.Clear();

            if (RepositoryManager.Instance.Repositories.Count < 2)
            {
                _newPatchnoteMenuItem.IsEnabled = false;
                return;
            }

            _newPatchnoteMenuItem.IsEnabled = true;

            foreach (var repository in RepositoryManager.Instance.Repositories)
            {
                var repositoryMenuVm = new MenuItemVM(RepositoryHelper.GetRepositoryDisplayName(repository))
                {
                    Icon = repository.GetMarker()
                };

                foreach (var repository2 in RepositoryManager.Instance.Repositories)
                {
                    if (repository == repository2)
                    {
                        continue;
                    }

                    var createPatchnoteMenuVm = new MenuItemVM(this.L("patchnote_generator", "new_patchnote_from_client_menu_item", RepositoryHelper.GetRepositoryDisplayName(repository2)),
                                                               new RelayCommand <IRepository[]>(this.CreatePatchnote),
                                                               new[] { repository2, repository })
                    {
                        Icon = repository2.GetMarker()
                    };

                    repositoryMenuVm.MenuItems.Add(createPatchnoteMenuVm);
                }

                foreach (var repository2 in RepositoryManager.Instance.Repositories)
                {
                    if (repository == repository2)
                    {
                        continue;
                    }

                    var createPatchnoteMenuVm = new MenuItemVM(this.L("patchnote_generator", "new_patchnote_to_client_menu_item", RepositoryHelper.GetRepositoryDisplayName(repository2)),
                                                               new RelayCommand <IRepository[]>(this.CreatePatchnote),
                                                               new[] { repository, repository2 })
                    {
                        Icon = repository2.GetMarker()
                    };

                    repositoryMenuVm.MenuItems.Add(createPatchnoteMenuVm);
                }

                _newPatchnoteMenuItem.MenuItems.Add(repositoryMenuVm);
            }
        }
Ejemplo n.º 11
0
        private async Task <MenuItemVM> CreateMenuItemGroup(string fullPath)
        {
            MenuItemVM menuItem = new MenuItemVM();

            menuItem.IsExpandable = true;
            menuItem.Name         = this.GetFriendlyName(Path.GetFileName(fullPath));
            menuItem.Action       = "ToggleItemField({{item.IsExpanded}});Notify(menuItems)";
            menuItem.Items.AddRange(await this.GetItems(fullPath));
            return(menuItem);
        }
Ejemplo n.º 12
0
        public void Remove(MenuItemVM menuItem, MenuAnchor anchor)
        {
            var menuItems = _menuItems[anchor];

            if (!menuItems.Remove(menuItem))
            {
                this.LogError("failed to remove menu item '{0}' at '{1}'", menuItem.Name, anchor);
            }

            _menuItemPriorities[anchor].Remove(menuItem);
        }
Ejemplo n.º 13
0
        // GET: CategoryController/Details/5


        // GET: CategoryController/Create
        public ActionResult Create()
        {
            var MenuItemObj = new MenuItemVM
            {
                MenuItem     = new MenuItem(),
                CategoryList = _unitOfWork.Category.GetCategoryListForDropDown(),
                FoodTypeList = _unitOfWork.FoodType.GetFoodTypeListForDropDown()
            };

            return(View(MenuItemObj));
        }
Ejemplo n.º 14
0
 public void SetErrorInfos(MainWindowVM mainWindow, List <WriteError> errorInfos)
 {
     this.mainWindow = mainWindow;
     this.errorInfos.Clear();
     foreach (WriteError errorInfoModel in errorInfos)
     {
         MenuItemVM menuItem = errorInfoModel.EDOUnit.FindMenuItem(errorInfoModel.Form);
         Debug.Assert(menuItem != null);
         ErrorInfoVM errorInfo = new ErrorInfoVM(errorInfoModel, menuItem);
         this.errorInfos.Add(errorInfo);
     }
 }
Ejemplo n.º 15
0
        public override string ToString()
        {
            MenuItemVM menuItem = EDOUnit.FindMenuItem(Form);

            StringBuilder buf = new StringBuilder();

            buf.Append(EDOUnit.Title);
            buf.Append("-");
            buf.Append(menuItem.Title);
            buf.Append("-");
            buf.Append(Message);
            return(buf.ToString());
        }
Ejemplo n.º 16
0
        public IActionResult OnGet()
        {
            MenuItemVM = new MenuItemVM
            {
                MenuItem        = new MenuItem(),
                FoodType        = _context.FoodType.ToList(),
                GetCategoryType = _context.CategoryTypes.ToList()
            };

            ViewData["CategoryTypeId"] = new SelectList(_context.CategoryTypes, "Id", "Name");
            ViewData["FoodTypeId"]     = new SelectList(_context.FoodTypes, "Id", "Name");

            return(Page());
        }
Ejemplo n.º 17
0
        public ActionResult Index()
        {
            if (!Convert.ToBoolean(Session["IsLogged"]))
            {
                return(RedirectToAction("Index", "Home"));
            }
            var menuItemViewModel = new MenuItemVM
            {
                MenuItems  = _unitOfWork.MenuItemRepository.GetAll().Where(s => s.IsDelete == false).OrderByDescending(s => s.MenuID),
                ModuleList = new SelectList(_unitOfWork.ModuleRepository.Get(), "ModuleID", "Title"),
            };

            return(View(menuItemViewModel));
        }
Ejemplo n.º 18
0
 private MenuItemVM FindByName(List <MenuItemVM> items, string name)
 {
     foreach (MenuItemVM item in items)
     {
         if (item.Name == name)
         {
             return(item);
         }
         MenuItemVM itemChild = FindByName(item.Items, name);
         if (itemChild != null)
         {
             return(itemChild);
         }
     }
     return(null);
 }
Ejemplo n.º 19
0
 public IActionResult OnGet(int?id)
 {
     MenuItemVM = new()
     {
         CategoryDropdownList = _unitOfWork.Category.GetCategoryListForDropDown(),
         FoodTypeDropdownList = _unitOfWork.FoodType.GetFoodTypeListForDropDown()
     };
     if (id != null)
     {
         MenuItemVM.MenuItem = _unitOfWork.MenuItem.GetFirstOrDefault(m => m.Id == id);
         if (MenuItemVM.MenuItem == null)
         {
             return(NotFound());
         }
     }
     return(Page());
 }
Ejemplo n.º 20
0
        public async Task <List <MenuItemVM> > GetItemsInternal()
        {
            string            path  = Path.Combine(_env.WebRootPath, "app", "menu");
            List <MenuItemVM> items = await this.GetItems(path);

            //Inject Functions
            MenuItemVM itemFunctions = FindByName(items, "Functions");

            itemFunctions.Items.Clear();
            List <string> functionNames = await this._function.GetNames();

            foreach (string functionName in functionNames)
            {
                itemFunctions.Items.Add(CreateMenuItemFunction(functionName));
            }
            return(items);
        }
Ejemplo n.º 21
0
 public IActionResult OnGet(int?id)
 {
     MenuItemObj = new MenuItemVM
     {
         CategoryList = _unitOfWork.Category.GetCategoryListDropDown(),
         FoodTypeList = _unitOfWork.FoodType.GetFoodTypeDropDown(),
         MenuItem     = new Models.MenuItem()
     };
     if (id != null)
     {
         MenuItemObj.MenuItem = _unitOfWork.MenuItem.GetFirstOrDefault(u => u.Id == id.GetValueOrDefault());
         if (MenuItemObj == null)
         {
             return(NotFound());
         }
     }
     return(Page());
 }
Ejemplo n.º 22
0
        private async Task <DrapoDynamic> HandlerCustom(DrapoDynamic dynamic, MenuController menu)
        {
            List <MenuItemVM> items = await menu.GetItemsInternal();

            foreach (Match match in Regex.Matches(dynamic.ContentData, @"\[(?<label>(\w|\s|\-)+)\]\((?<item>(\w|\s|\-)+)\)"))
            {
                string     label    = match.Groups["label"].Value;
                string     item     = match.Groups["item"].Value;
                MenuItemVM menuItem = this.GetItem(items, item);
                if (menuItem == null)
                {
                    continue;
                }
                string content = $"<span class='dContentLink' d-on-click='{menuItem.Action}'>{label}</span>";
                dynamic.ContentData = dynamic.ContentData.Replace(match.Value, content);
            }
            return(await Task.FromResult <DrapoDynamic>(dynamic));
        }
Ejemplo n.º 23
0
        public IActionResult OnGet(int?id)
        {
            MenuItemPbj = new MenuItemVM
            {
                CategoryList = unitOfWork.Category.GetCategoriesForDropDownList(),
                FoodTypeList = unitOfWork.FoodType.GetFoodTypeForDropDownList(),
                MenuItem     = new Models.MenuItem()
            };
            if (id != null)
            {
                MenuItemPbj.MenuItem = unitOfWork.MenuItem.GetFirstOrDefault(i => i.Id == id);
                if (MenuItemPbj == null)
                {
                    return(NotFound());
                }
            }

            return(Page());
        }
Ejemplo n.º 24
0
        public IActionResult OnGet(int?id)
        {
            MenuItem = new MenuItemVM()
            {
                Category = _unitOfWork.Category.GetCategoryListForDropDown(),
                FoodType = _unitOfWork.FoodType.GetFoodTypeListForDropdown(),
                MenuItem = new Models.MenuItem()
            };
            if (id == null)
            {
                return(Page());
            }

            MenuItem.MenuItem = _unitOfWork.MenuItem.GetFirstOrDefault(u => u.Id == id);
            if (MenuItem.MenuItem == null)
            {
                return(NotFound());
            }

            return(Page());
        }
Ejemplo n.º 25
0
        public IActionResult OnGet(int?id)
        {
            menuItemObj = new MenuItemVM
            {
                CategoryList        = _unitOfWork.Category.GetCategoryListForDropdown(),
                FoodTypeList        = _unitOfWork.FoodType.GetFoodTypeListForDropdown(),
                MenuItem            = new Models.MenuItem(),
                InventoryList       = _unitOfWork.Inventory.GetAll(includeProperties: "UnitType").ToList(),
                MenuItemInventories = new List <MenuItemInventoryVM>()
            };

            if (id != null)
            {
                menuItemObj.MenuItem = _unitOfWork.MenuItem.GetFirstOrDefault(x => x.Id == id);
                //SQL LEFT JOIN Duzenle????!!!

                menuItemObj.MenuItemInventories = (from inventory in _unitOfWork.Inventory.GetAll(includeProperties: "UnitType")
                                                   join menuItemInventory in _unitOfWork.MenuItemInventory.GetAll()
                                                   on inventory.Id equals menuItemInventory.InventoryId into fmInventory
                                                   from fullMenuInventory in fmInventory.DefaultIfEmpty()
                                                   where ((fullMenuInventory == null ? 0 : fullMenuInventory.MenuItemId) == id) || ((fullMenuInventory == null ? 0 : fullMenuInventory.Quantity) == 0)
                                                   select new MenuItemInventoryVM()
                {
                    MenuItemInventoryId = fullMenuInventory == null ? 0 : fullMenuInventory.Id,
                    InventoryId = inventory.Id,
                    MenuItemId = fullMenuInventory == null ? 0 : fullMenuInventory.MenuItemId,
                    InventoryName = inventory.Name,
                    UnitTypeName = inventory.UnitType.Name,
                    Quantity = fullMenuInventory == null ? 0 : fullMenuInventory.Quantity
                }).ToList();

                if (menuItemObj.MenuItem == null)
                {
                    return(NotFound());
                }
            }

            return(Page());
        }
Ejemplo n.º 26
0
        public dynamic GetPageList()
        {
            _userActionMappingFactory = new UserActionMappingFactory();
            _uiPageFactory            = new UiPageFactory();
            _moduleFactory            = new ModuleFactory();
            var module = _moduleFactory.GetAll().ToList();
            var page   = _uiPageFactory.GetAll();

            List <MenuItemVM> pageUrlvmList = new List <MenuItemVM>();

            foreach (var item in page)
            {
                MenuItemVM pageUrlvm = new MenuItemVM();
                pageUrlvm.PageId     = item.ID;
                pageUrlvm.ModuleId   = item.ModuleID.GetValueOrDefault();
                pageUrlvm.ModuleName = item.Name;
                pageUrlvm.Select     = false;
                pageUrlvm.Edit       = false;
                pageUrlvm.Create     = false;
                pageUrlvm.Delete     = false;
                pageUrlvm.ShowHide   = true;
                pageUrlvmList.Add(pageUrlvm);
            }
            var menu = (from item in module
                        select new
            {
                ID = item.ID,
                Name = item.Name,
                Select = true,
                Edit = true,
                Create = true,
                Delete = true,
                ShowHide = false,
                children = pageUrlvmList.Where(x => x.ModuleId == item.ID).ToList()
            }).ToList();

            return(menu);
        }
Ejemplo n.º 27
0
        private async Task <List <MenuItemVM> > GetItems(string path)
        {
            List <MenuItemVM>    items         = new List <MenuItemVM>();
            IEnumerable <string> entries       = Directory.EnumerateFileSystemEntries(path);
            List <string>        entriesSorted = this.Sort(entries);

            for (int i = 0; i < entriesSorted.Count; i++)
            {
                string     entry     = entriesSorted[i];
                string     pathEntry = Path.Combine(path, entry);
                MenuItemVM item      = null;
                if (Directory.Exists(pathEntry))
                {
                    item = await CreateMenuItemGroup(entry);
                }
                else
                {
                    item = this.CreateMenuItemLink(pathEntry);
                }
                items.Add(item);
            }
            return(items);
        }
Ejemplo n.º 28
0
        public YamlEditorControllerVM()
        {
            RegisterChildren(() => this);

            MenuItemVM shi, foi, srhi;

            ContextMenu.Items.Add(new MenuItemVM {
                Caption = "-"
            });
            ContextMenu.Items.Add(new MenuItemVM {
                Caption = "Options",
                Items   =
                {
                    (shi        = new MenuItemVM {
                        Caption = "Syntax Highlighting", IsCheckable = true
                    }),
                    (foi        = new MenuItemVM {
                        Caption = "Folding", IsCheckable = true
                    }),
                    (srhi       = new MenuItemVM {
                        Caption = "Search Result Highlighting", IsCheckable = true
                    }),
                }
            });

            shi.Fields[nameof(MenuItemVM.IsChecked)].SetBinding(new FieldBinding(Fields[nameof(DisableSyntaxHighlighting)], BindingMode.TwoWay, InvertBoolConverter.Default));
            foi.Fields[nameof(MenuItemVM.IsChecked)].SetBinding(new FieldBinding(Fields[nameof(DisableFolding)], BindingMode.TwoWay, InvertBoolConverter.Default));
            srhi.Fields[nameof(MenuItemVM.IsChecked)].SetBinding(new FieldBinding(Fields[nameof(DisableSearchResultHighlighting)], BindingMode.TwoWay, InvertBoolConverter.Default));

            Fields[nameof(DisableSyntaxHighlighting)].ValueChangedEvent.add       = (s, e) => { OnDisableSyntaxHighlightingChanged((bool)e.NewValue); };
            Fields[nameof(DisableFolding)].ValueChangedEvent.add                  = (s, e) => { OnDisableFoldingChanged((bool)e.NewValue); };
            Fields[nameof(DisableSearchResultHighlighting)].ValueChangedEvent.add = (s, e) => { OnDisableSearchResultHighlightingChanged((bool)e.NewValue); };

            //DEBUG
            Fields[nameof(DisableSyntaxHighlighting)].ValueChangedEvent.add = (s, e) => Debug.WriteLine($"DisableSyntaxHighlighting: {e.NewValue}");
            shi.Fields[nameof(MenuItemVM.IsChecked)].ValueChangedEvent.add  = (s, e) => Debug.WriteLine($"MenuItemVM.IsChecked: {e.NewValue}");
        }
Ejemplo n.º 29
0
        public void Register(MenuItemVM menuItem, MenuAnchor anchor, int priority = 0)
        {
            var prioritiyLookup = _menuItemPriorities[anchor];
            var menuItems       = _menuItems[anchor];

            var inserted = false;

            for (var i = 0; i < menuItems.Count; ++i)
            {
                if (prioritiyLookup[menuItems[i]] > priority)
                {
                    menuItems.Insert(i, menuItem);
                    inserted = true;
                    break;
                }
            }

            if (!inserted)
            {
                menuItems.Add(menuItem);
            }

            prioritiyLookup[menuItem] = priority;
        }
        // GET: Set Menu Item Base price
        public MenuItemVM MapMenuItemBasePrice(RMenuItemVM model)
        {
            List <decimal?> PriceList  = new List <decimal?>();
            MenuItemVM      menuItemVM = new MenuItemVM {
                MenuItemOriginalPrice = model.MenuItem.BasePrice
            };

            if (model.MenuItem.BasePrice == null)
            {
                if (model.MenuItem.ModifierPriceIDs != null && model.MenuItem.ModifierPriceIDs.Count > 0)
                {
                    foreach (var modifierPrice in model.MenuItem.ModifierPriceIDs)
                    {
                        var pricemodel = Shared.APIs.IRestaurant.GetModifierPrice(model.LocationId, model.MenuId, model.MenuItem.ID, modifierPrice);

                        PriceList.Add(pricemodel.Price);
                    }
                    model.MenuItem.BasePrice = PriceList.Where(f => f > 0).Min();
                }
            }

            menuItemVM.MenuItem = model.MenuItem;
            return(menuItemVM);
        }