Exemplo n.º 1
0
        public ActionResult New()
        {
            var model = new SystemEditViewModel
            {
                Mode     = 1,
                SystemId = 0,
                Name     = string.Empty,
            };

            return(View("SystemEdit", model));
        }
Exemplo n.º 2
0
        public IActionResult Edit(int id)
        {
            var systemToEdit = _systemService.Get(id);
            SystemEditViewModel systemEditViewModel = new SystemEditViewModel()
            {
                Id          = systemToEdit.Id,
                Name        = systemToEdit.Name,
                Description = systemToEdit.Description,
            };

            return(View(systemEditViewModel));
        }
Exemplo n.º 3
0
        public ActionResult Edit(int id)
        {
            var system = SysUpdateHelper.GetSystem(id);

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

            var model = new SystemEditViewModel
            {
                Mode     = 2,
                SystemId = id,
                Name     = system.Name,
            };

            return(View("SystemEdit", model));
        }
Exemplo n.º 4
0
        public ActionResult New(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                var model = new SystemEditViewModel
                {
                    Mode     = 1,
                    SystemId = 0,
                    Name     = string.Empty,
                };

                return(View("SystemEdit", model));
            }
            else
            {
                SysUpdateHelper.AddSystem(name, Oper.Id);

                return(RedirectToAction(nameof(SystemList)));
            }
        }
Exemplo n.º 5
0
 public async Task <IActionResult> Edit(SystemEditViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var systemEdited = _systemService.Get(viewModel.Id);
             systemEdited.Name        = viewModel.Name;
             systemEdited.Description = viewModel.Description;
             _systemService.Update(systemEdited);
             return(RedirectToAction("Index"));
         }
         catch
         {
             return(View(viewModel));
         }
     }
     else
     {
         return(View(viewModel));
     }
 }