Exemplo n.º 1
0
 public ActionResult Save(StructureViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         if (viewModel.Id == Guid.Empty)
         {
             var model = new Structure();
             model.Id   = Guid.NewGuid();
             model.Name = viewModel.Name;
             _structureService.Create(model);
         }
         else
         {
             var model = _structureService.GetById(viewModel.Id);
             model.Name = viewModel.Name;
             _structureService.Update(model);
         }
         return(RedirectToAction("Index"));
     }
     return(View("Create", viewModel));
 }