public Menu Map(CreateOrEditViewModel createOrEdit)
        {
            Menu menu = new Menu();

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

              menu.Code = createOrEdit.Code;
              return menu;
        }
Esempio n. 2
0
        public Menu Map(CreateOrEditViewModel createOrEdit)
        {
            Menu menu = new Menu();

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

            menu.Code = createOrEdit.Code;
            return(menu);
        }
Esempio n. 3
0
        public IActionResult CreateOrEdit(CreateOrEditViewModel createOrEdit)
        {
            if (this.ModelState.IsValid)
              {
            Menu menu = new CreateOrEditViewModelMapper(this).Map(createOrEdit);

            this.CreateOrEditEntityLocalizations(menu);

            if (createOrEdit.Id == null)
              this.Storage.GetRepository<IMenuRepository>().Create(menu);

            else this.Storage.GetRepository<IMenuRepository>().Edit(menu);

            this.Storage.Save();
            new CacheManager(this).CacheMenu(menu);
            return this.RedirectToAction("Index");
              }

              return this.CreateRedirectToSelfResult();
        }