public MenuItem Map(CreateOrEditViewModel createOrEdit)
        {
            MenuItem menuItem = new MenuItem();

              if (createOrEdit.Id != null)
            menuItem = this.handler.Storage.GetRepository<IMenuItemRepository>().WithKey((int)createOrEdit.Id);

              else
              {
            menuItem.MenuId = createOrEdit.MenuId;
            menuItem.MenuItemId = createOrEdit.MenuItemId;
              }

              menuItem.Url = createOrEdit.Url;
              menuItem.Position = createOrEdit.Position;
              return menuItem;
        }
        public MenuItem Map(CreateOrEditViewModel createOrEdit)
        {
            MenuItem menuItem = new MenuItem();

            if (createOrEdit.Id != null)
            {
                menuItem = this.handler.Storage.GetRepository <IMenuItemRepository>().WithKey((int)createOrEdit.Id);
            }

            else
            {
                menuItem.MenuId     = createOrEdit.MenuId;
                menuItem.MenuItemId = createOrEdit.MenuItemId;
            }

            menuItem.Url      = createOrEdit.Url;
            menuItem.Position = createOrEdit.Position;
            return(menuItem);
        }
        public IActionResult CreateOrEdit(CreateOrEditViewModel createOrEdit)
        {
            if (this.ModelState.IsValid)
              {
            MenuItem menuItem = new CreateOrEditViewModelMapper(this).Map(createOrEdit);

            this.CreateOrEditEntityLocalizations(menuItem);

            if (createOrEdit.Id == null)
              this.Storage.GetRepository<IMenuItemRepository>().Create(menuItem);

            else this.Storage.GetRepository<IMenuItemRepository>().Edit(menuItem);

            this.Storage.Save();
            this.CacheMenu(menuItem);
            return this.RedirectToAction("Index", "Menus");
              }

              return this.CreateRedirectToSelfResult();
        }