Exemple #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;
             structureRepository.Create(model);
         }
         else
         {
             var model = structureRepository.Get(viewModel.Id);
             model.Name = viewModel.Name;
             structureRepository.Update(model);
         }
         return(RedirectToAction("Index"));
     }
     return(View("Create", viewModel));
 }
        public IActionResult Put(int id, Structure structure)
        {
            var currentUserProfile = GetCurrentUserProfile();
            var upr = _reportRepository.GetUserProfileReportById(structure.ReportId, currentUserProfile.Id);

            if (upr != null)
            {
                if (id != structure.Id)
                {
                    return(BadRequest());
                }

                _structureRepository.Update(structure);

                return(Ok());
            }
            else
            {
                return(Unauthorized());
            }
        }