Example #1
0
        public void AccessEditRegisterWhenUserIsAdminAndRegisterIsNotAlertRegister()
        {
            SetClaims(Role, Admin);
            var registerViewModel = new RegisterV2ViewModel(_register, _filter);

            _accessControlService.EditRegister(registerViewModel).Should().BeTrue();
        }
Example #2
0
        public void AccessAddToRegisterWhenRegisterIsNotDokMunicipal()
        {
            SetClaims(Role, Admin);
            var registerViewModel = new RegisterV2ViewModel(_register, _filter);

            _accessControlService.AddToRegister(registerViewModel).Should().BeTrue();
        }
        public ActionResult DetailsGeodatalovStatusRegistry(string sorting, int?page, string format, FilterParameters filter)
        {
            RemoveSessionsParamsIfCurrentRegisterIsNotTheSameAsReferer();
            var redirectToApiUrl = RedirectToApiIfFormatIsNotNull(format);

            if (!string.IsNullOrWhiteSpace(redirectToApiUrl))
            {
                return(Redirect(redirectToApiUrl));
            }

            var register = _registerService.GetGeodatalovDatasetRegister();

            if (register == null)
            {
                return(HttpNotFound());
            }
            if (register.RedirectToNewPath(HttpContext.Request.Path))
            {
                return(RedirectPermanent(register.GetObjectUrl()));
            }

            register = FilterRegisterItems(register, filter);

            List <StatusReport> geodatalovStatusReports = _statusReportService.GetStatusReportsByRegister(register, 12);
            StatusReport        statusReport            = filter.SelectedReport != null?_statusReportService.GetStatusReportById(filter.SelectedReport) : geodatalovStatusReports.FirstOrDefault();

            var viewModel = new RegisterV2ViewModel(register, filter, null, statusReport, geodatalovStatusReports);

            viewModel.SelectedGeodatalovTab = filter.GeodatalovSelectedTab;
            viewModel.AccessRegister        = _accessControlService.AccessViewModel(viewModel);

            ItemsOrderBy(sorting, viewModel);
            ViewbagsRegisterDetails(sorting, page, filter, viewModel);
            return(View(viewModel));
        }
Example #4
0
        public void NotAccessAddToRegisterWhenRegisterIsDokMunicipalAndMunicipalityIsNull()
        {
            SetClaims(Role, Admin);
            _register.systemId = Guid.Parse(GlobalVariables.DokMunicipalRegistryId);
            var registerViewModel = new RegisterV2ViewModel(_register, _filter);

            _accessControlService.AddToRegister(registerViewModel).Should().BeFalse();
        }
Example #5
0
        public void NotAccessEditRegisterWhenUserIsAdminAndRegisterIsAlertRegister()
        {
            SetClaims(Role, Admin);
            _register.systemId = Guid.Parse("0f428034-0b2d-4fb7-84ea-c547b872b418");
            var registerViewModel = new RegisterV2ViewModel(_register, _filter);

            _accessControlService.EditRegister(registerViewModel).Should().BeFalse();
        }
Example #6
0
 public bool AddToRegister(RegisterV2ViewModel registerViewModel)
 {
     if (registerViewModel.IsDokMunicipal())
     {
         return(registerViewModel.Municipality != null && AccessRegister(registerViewModel));
     }
     return(AccessRegister(registerViewModel));
 }
Example #7
0
        public void AccessEditRegisterItemListWhenMunicipalityIsNotNull()
        {
            SetClaims(Role, Admin);
            var registerViewModel = new RegisterV2ViewModel(_register, _filter);

            registerViewModel.Municipality = _municipality;
            _accessControlService.EditRegisterItemsList(registerViewModel).Should().BeTrue();
        }
Example #8
0
        public AccessViewModel AccessViewModel(RegisterV2ViewModel registerViewModel)
        {
            var accessViewModel = new AccessViewModel();

            accessViewModel.Edit = EditRegister(registerViewModel);
            accessViewModel.Add  = AddToRegister(registerViewModel);
            accessViewModel.EditListOfRegisterItems = EditRegisterItemsList(registerViewModel);
            accessViewModel.Delete = DeleteRegister(registerViewModel);
            return(accessViewModel);
        }
Example #9
0
 private bool DeleteRegister(RegisterV2ViewModel registerViewModel)
 {
     if (IsAdmin() || IsRegisterOwner(registerViewModel.Owner.name, UserName()))
     {
         if (registerViewModel.ParentRegister == null)
         {
             return(registerViewModel.RegisterItems == null && registerViewModel.RegisterItemsV2 == null);
         }
         return(true);
     }
     return(false);
 }
        public ActionResult DetailsInspireStatusRegistry(string sorting, int?page, string format, FilterParameters filter)
        {
            RemoveSessionsParamsIfCurrentRegisterIsNotTheSameAsReferer();
            var redirectToApiUrl = RedirectToApiIfFormatIsNotNull(format);

            if (!string.IsNullOrWhiteSpace(redirectToApiUrl))
            {
                return(Redirect(redirectToApiUrl));
            }

            var register = _registerService.GetInspireStatusRegister();

            if (register == null)
            {
                return(HttpNotFound());
            }

            if (register.RedirectToNewPath(HttpContext.Request.Path))
            {
                return(RedirectPermanent(register.GetObjectUrl()));
            }

            filter.InspireRegisteryType = GetInspireRegistryType(filter.InspireRegisteryType);
            register = FilterRegisterItems(register, filter);

            List <StatusReport> inspireStatusReports = _statusReportService.GetInspireStatusReports(12);
            StatusReport        statusReport         = filter.SelectedReport != null?_statusReportService.GetStatusReportById(filter.SelectedReport) : inspireStatusReports.FirstOrDefault();


            var viewModel = new RegisterV2ViewModel(register, filter, page, statusReport, inspireStatusReports);

            viewModel.AccessRegister = _accessControlService.AccessViewModel(viewModel);
            viewModel.SelectedInspireRegisteryType = filter.InspireRegisteryType;

            if (viewModel.SelectedInspireRegisteryTypeIsInspireReport())
            {
                viewModel.InspireReport = _inspireMonitoringService.GetInspireReportViewModel(register, filter);
            }

            ItemsOrderBy(sorting, viewModel);
            ViewbagsRegisterDetails(sorting, page, filter, viewModel);

            return(View(viewModel));
        }
Example #11
0
 private bool AccessRegister(RegisterV2ViewModel registerViewModel)
 {
     if (IsAdmin())
     {
         return(true);
     }
     if (registerViewModel.AccessId == 2)
     {
         if (IsEditor())
         {
             if (registerViewModel.ContainedItemClassIsCodelistValue())
             {
                 return(IsRegisterOwner(registerViewModel.Owner.name, UserName()));
             }
             return(true);
         }
     }
     else if (registerViewModel.AccessId == 4)
     {
         return(UserIsSelectedMunicipality(registerViewModel.MunicipalityCode) || IsDokEditor() || IsDokAdmin());
     }
     return(false);
 }
        public ActionResult Details(string parentRegister, string owner, string registername, string sorting, int?page, string format, FilterParameters filter)
        {
            RemoveSessionsParamsIfCurrentRegisterIsNotTheSameAsReferer();
            var redirectToApiUrl = RedirectToApiIfFormatIsNotNull(format);

            if (!string.IsNullOrWhiteSpace(redirectToApiUrl))
            {
                return(Redirect(redirectToApiUrl));
            }

            var register = _registerService.GetRegister(parentRegister, registername);

            if (register == null)
            {
                return(HttpNotFound());
            }

            if (register.RedirectToNewPath(HttpContext.Request.Path))
            {
                return(RedirectPermanent(register.GetObjectUrl()));
            }

            //List<StatusReport> statusReports = _statusReportService.GetStatusReportsByRegister(register, 12);
            //StatusReport statusReport = filter.SelectedReport != null ? _statusReportService.GetStatusReportById(filter.SelectedReport) : statusReports.FirstOrDefault();

            register = FilterRegisterItems(register, filter);
            var viewModel = new RegisterV2ViewModel(register, filter, null, null, null);

            viewModel.MunicipalityCode = filter.municipality;
            viewModel.Municipality     = _registerItemService.GetMunicipalityOrganizationByNr(viewModel.MunicipalityCode);
            viewModel.AccessRegister   = _accessControlService.AccessViewModel(viewModel);

            ItemsOrderBy(sorting, viewModel);
            ViewBagOrganizationMunizipality(filter.municipality);
            ViewbagsRegisterDetails(sorting, page, filter, viewModel);
            return(View(viewModel));
        }
Example #13
0
 public bool EditRegister(RegisterV2ViewModel registerViewModel)
 {
     return((IsAdmin() || IsRegisterOwner(registerViewModel.Owner.name, UserName())) && !registerViewModel.IsAlertRegister());
 }
Example #14
0
 public bool EditRegisterItemsList(RegisterV2ViewModel registerViewModel)
 {
     return(registerViewModel.Municipality != null && AccessRegister(registerViewModel));
 }
 private void ItemsOrderBy(string sorting, RegisterV2ViewModel viewModel)
 {
     viewModel.RegisterItemsV2 = _registerItemService.OrderBy(viewModel.RegisterItemsV2, sorting);
     viewModel.RegisterItems   = _registerItemService.OrderBy(viewModel.RegisterItems, sorting);
     viewModel.Subregisters    = _registerService.OrderBy(viewModel.Subregisters, sorting);
 }
 private void ViewbagsRegisterDetails(string sorting, int?page, FilterParameters filter, RegisterV2ViewModel register)
 {
     ViewBag.search    = filter.text;
     ViewBag.page      = page;
     ViewBag.SortOrder = sorting ?? "";
     ViewBag.selectedMunicipalityCode = filter.municipality;
     ViewBag.municipality             = _registerItemService.GetMunicipalityList();
     ViewBag.registerId           = register.SystemId;
     ViewBag.register             = register.Name;
     ViewBag.registerSEO          = register.Seoname;
     ViewBag.InspireRegisteryType = filter.InspireRegisteryType;
     ViewBag.text = filter.text;
 }
 public bool EditRegister(RegisterV2ViewModel registerViewModel)
 {
     //return (IsAdmin() || IsRegisterOwner(registerViewModel.Owner.name, UserName())) && !registerViewModel.IsAlertRegister();
     return((HasAccessToRegister(registerViewModel.Register)) && !registerViewModel.IsAlertRegister());
 }
 public bool AllowAddToRegister(RegisterV2ViewModel register)
 {
     return(AllowedRegisters(register.SystemId));
 }