private ActionResult EditDataset(Dataset dataset, Dataset originalDataset, CoverageDataset coverage = null) { dataset.register = originalDataset.register; if (!NameIsValid(dataset)) { ModelState.AddModelError("ErrorMessage", HtmlHelperExtensions.ErrorMessageValidationName()); Viewbags(originalDataset); return(View(originalDataset)); } dataset = _datasetService.UpdateDataset(dataset, originalDataset, coverage); _translationService.UpdateTranslations(dataset, originalDataset); _registerItemService.SaveEditedRegisterItem(originalDataset); return(Redirect(originalDataset.GetObjectUrl())); }
public List <CoverageDataset> EditDatasetCoverage(CoverageDataset coverage, Dataset dataset, Dataset originalDataset = null) { if (coverage != null && originalDataset != null) { CoverageDataset originalCoverage = _registerItemService.GetMunicipalityCoverage(dataset, originalDataset.datasetownerId); if (dataset.IsMunicipalDataset()) { if (originalCoverage != null) { originalCoverage.MunicipalityId = dataset.datasetownerId; originalCoverage.CoverageDOKStatusId = dataset.dokStatusId; originalCoverage.ConfirmedDok = coverage.ConfirmedDok; _registerItemService.Save(); } } else { if (originalCoverage == null) { CoverageDataset newCoverage = new CoverageDataset() { CoverageId = Guid.NewGuid(), CoverageDOKStatus = coverage.CoverageDOKStatus, CoverageDOKStatusId = coverage.CoverageDOKStatusId, ConfirmedDok = coverage.ConfirmedDok, DatasetId = dataset.systemId, MunicipalityId = _registerService.GetOrganizationIdByUserName(), Note = coverage.Note, }; _registerItemService.SaveNewCoverage(newCoverage); dataset.Coverage.Add(newCoverage); } else { originalCoverage.ConfirmedDok = coverage.ConfirmedDok; originalCoverage.CoverageDOKStatusId = coverage.CoverageDOKStatusId; originalCoverage.Note = coverage.Note; } } } else if (coverage == null && dataset.IsMunicipalDataset()) { dataset.Coverage.Add(_registerItemService.NewCoverage(dataset)); } return(dataset.Coverage); }
public CoverageDataset NewCoverage(Dataset dataset) { CoverageDataset coverage = new CoverageDataset(); coverage.CoverageId = Guid.NewGuid(); coverage.CoverageDOKStatusId = "Accepted"; coverage.ConfirmedDok = true; coverage.DatasetId = dataset.systemId; dataset.dokStatusDateAccepted = DateTime.Now; coverage.MunicipalityId = dataset.datasetownerId; coverage.Note = dataset.Notes; coverage.Coverage = null; _context.Entry(coverage).State = EntityState.Modified; _context.CoverageDatasets.Add(coverage); return(coverage); }
private CoverageDataset CreateNewCoverage(DokMunicipalEdit item, Dataset originalDataset, string municipalityCode, bool coverageFound) { Organization municipality = _registerItemService.GetMunicipalityOrganizationByNr(municipalityCode); CoverageDataset coverage = new CoverageDataset { CoverageId = Guid.NewGuid(), CoverageDOKStatusId = "Accepted", ConfirmedDok = item.Confirmed, Coverage = coverageFound, dataset = originalDataset, DatasetId = originalDataset.systemId, MunicipalityId = municipality.systemId, Note = item.Note }; return(coverage); }
//[Route("dataset/{parentRegister}/{registerowner}/{registername}/{itemowner}/{itemname}/rediger")] //[Route("dataset/{registername}/{itemowner}/{itemname}/rediger")] public ActionResult Edit(Dataset dataset, CoverageDataset coverage, string registername, string itemname, string metadataUuid, string parentRegister, string registerowner, string itemowner, bool dontUpdateDescription = false) { Dataset originalDataset = (Dataset)_registerItemService.GetRegisterItem(parentRegister, registername, itemname, 1, itemowner); if (originalDataset != null) { if (metadataUuid != null) { Dataset model = GetMetadataFromKartkatalogen(originalDataset, metadataUuid, dontUpdateDescription); Viewbags(model); return(View(model)); } if (originalDataset.IsNationalDataset()) { if (_accessControlService.IsAdmin()) { return(EditDataset(dataset, originalDataset)); } if (_accessControlService.IsMunicipalUser()) { return(EditCoverageDataset(coverage, originalDataset)); } } else if (_accessControlService.Access(originalDataset)) { if (ModelState.IsValid) { return(EditDataset(dataset, originalDataset, coverage)); } } else { throw new HttpException(401, "Access Denied"); } } Viewbags(originalDataset); return(View(originalDataset)); }
public static string GetDokStatusFromCoverage(Dataset item, CodelistValue selectedMunicipality) { if (item.register.IsDokMunicipal()) { return(item.dokStatus.DescriptionTranslated()); } CoverageDataset coverage = Coverage(item, selectedMunicipality); if (coverage != null) { if (coverage.CoverageDOKStatusId != null) { return(coverage.CoverageDOKStatus.description); } else { return("Forslag"); } } else { return("Forslag"); } }
public Dataset UpdateDataset(Dataset inputDataset, Dataset originalDataset = null, CoverageDataset coverage = null) { Dataset dataset = originalDataset ?? new Dataset(); dataset.systemId = inputDataset.GetSystemId(); dataset.modified = dataset.GetDateModified(); dataset.dateSubmitted = dataset.GetDateSubmbitted(); dataset.register = inputDataset.register; dataset.registerId = inputDataset.registerId; dataset.DatasetType = dataset.GetDatasetType(); dataset.statusId = dataset.SetStatusId(); dataset.dokStatusId = inputDataset.GetDokStatus(); dataset.dokStatusDateAccepted = inputDataset.GetDokStatusDateAccepted(); dataset.Kandidatdato = inputDataset.Kandidatdato; dataset.versionNumber = dataset.GetVersionNr(); dataset.versioningId = GetVersioningId(dataset); dataset.datasetownerId = GetDatasetOwnerId(inputDataset.datasetownerId); dataset.datasetowner = (Organization)_registerItemService.GetRegisterItemBySystemId(dataset.datasetownerId); dataset.submitterId = GetSubmitterId(inputDataset.submitterId); dataset.submitter = (Organization)_registerItemService.GetRegisterItemBySystemId(dataset.submitterId); dataset.Notes = inputDataset.GetNotes(); dataset.name = inputDataset.GetName(); dataset.seoname = RegisterUrls.MakeSeoFriendlyString(dataset.name); dataset.description = inputDataset.GetDescription(); dataset.DistributionUrl = inputDataset.GetDistributionUrl(); dataset.MetadataUrl = inputDataset.GetMetadataUrl(); dataset.PresentationRulesUrl = inputDataset.GetPresentationRulesUrl(); dataset.ProductSheetUrl = inputDataset.GetProductSheetUrl(); dataset.ProductSpecificationUrl = inputDataset.GetProductSpecificationUrl(); dataset.UuidService = inputDataset.GetServceUuid(); dataset.WmsUrl = inputDataset.GetWmsUrl(); dataset.DistributionFormat = inputDataset.GetDistributionFormat(); dataset.DistributionArea = inputDataset.GetDistributionArea(); dataset.ThemeGroupId = inputDataset.GetThemeGroupId(); dataset.datasetthumbnail = inputDataset.Getdatasetthumbnail(); dataset.Uuid = inputDataset.Uuid; dataset.SpecificUsage = inputDataset.SpecificUsage; dataset.restricted = inputDataset.restricted; dataset.dokDeliveryMetadataStatusId = _datasetDeliveryService.GetMetadataStatus(inputDataset.Uuid, inputDataset.dokDeliveryMetadataStatusAutoUpdate, inputDataset.dokDeliveryMetadataStatusId); dataset.dokDeliveryMetadataStatusNote = inputDataset.dokDeliveryMetadataStatusNote; dataset.dokDeliveryMetadataStatusAutoUpdate = inputDataset.dokDeliveryMetadataStatusAutoUpdate; dataset.dokDeliveryProductSheetStatusId = _registerService.GetDOKStatus(inputDataset.GetProductSheetUrl(), inputDataset.dokDeliveryProductSheetStatusAutoUpdate, inputDataset.dokDeliveryProductSheetStatusId); dataset.dokDeliveryProductSheetStatusNote = inputDataset.dokDeliveryProductSheetStatusNote; dataset.dokDeliveryProductSheetStatusAutoUpdate = inputDataset.dokDeliveryProductSheetStatusAutoUpdate; dataset.dokDeliveryPresentationRulesStatusId = _registerService.GetDOKStatus(inputDataset.GetPresentationRulesUrl(), inputDataset.dokDeliveryPresentationRulesStatusAutoUpdate, inputDataset.dokDeliveryPresentationRulesStatusId); dataset.dokDeliveryPresentationRulesStatusNote = inputDataset.dokDeliveryPresentationRulesStatusNote; dataset.dokDeliveryPresentationRulesStatusAutoUpdate = inputDataset.dokDeliveryPresentationRulesStatusAutoUpdate; dataset.dokDeliveryProductSpecificationStatusId = _registerService.GetDOKStatus(inputDataset.GetProductSpecificationUrl(), inputDataset.dokDeliveryProductSpecificationStatusAutoUpdate, inputDataset.dokDeliveryProductSpecificationStatusId); dataset.dokDeliveryProductSpecificationStatusNote = inputDataset.dokDeliveryProductSpecificationStatusNote; dataset.dokDeliveryProductSpecificationStatusAutoUpdate = inputDataset.dokDeliveryProductSpecificationStatusAutoUpdate; dataset.dokDeliveryWmsStatusId = _datasetDeliveryService.GetDokDeliveryServiceStatus(inputDataset.Uuid, inputDataset.dokDeliveryWmsStatusAutoUpdate, inputDataset.dokDeliveryWmsStatusId, inputDataset.UuidService); dataset.dokDeliveryWmsStatusNote = inputDataset.dokDeliveryWmsStatusNote; dataset.dokDeliveryWmsStatusAutoUpdate = inputDataset.dokDeliveryWmsStatusAutoUpdate; dataset.dokDeliveryWfsStatusId = _datasetDeliveryService.GetWfsStatus(inputDataset.Uuid, inputDataset.dokDeliveryWfsStatusAutoUpdate, inputDataset.dokDeliveryWfsStatusId); dataset.dokDeliveryWfsStatusNote = inputDataset.dokDeliveryWfsStatusNote; dataset.dokDeliveryWfsStatusAutoUpdate = inputDataset.dokDeliveryWfsStatusAutoUpdate; dataset.dokDeliverySosiRequirementsStatusId = _registerService.GetSosiRequirements(inputDataset.Uuid, inputDataset.GetProductSpecificationUrl(), inputDataset.dokDeliverySosiStatusAutoUpdate, inputDataset.dokDeliverySosiRequirementsStatusId); dataset.dokDeliverySosiRequirementsStatusNote = inputDataset.dokDeliverySosiRequirementsStatusNote; dataset.dokDeliverySosiStatusAutoUpdate = inputDataset.dokDeliverySosiStatusAutoUpdate; dataset.dokDeliveryGmlRequirementsStatusId = _registerService.GetGmlRequirements(inputDataset.Uuid, inputDataset.dokDeliveryGmlRequirementsStatusAutoUpdate, inputDataset.dokDeliveryGmlRequirementsStatusId); dataset.dokDeliveryGmlRequirementsStatusNote = inputDataset.dokDeliveryGmlRequirementsStatusNote; dataset.dokDeliveryGmlRequirementsStatusAutoUpdate = inputDataset.dokDeliveryGmlRequirementsStatusAutoUpdate; dataset.dokDeliveryAtomFeedStatusId = _datasetDeliveryService.GetAtomFeedStatus(inputDataset.Uuid, inputDataset.dokDeliveryAtomFeedStatusAutoUpdate, inputDataset.dokDeliveryAtomFeedStatusId); dataset.dokDeliveryAtomFeedStatusNote = inputDataset.dokDeliveryAtomFeedStatusNote; dataset.dokDeliveryAtomFeedStatusAutoUpdate = inputDataset.dokDeliveryAtomFeedStatusAutoUpdate; dataset.dokDeliveryDistributionStatusNote = inputDataset.dokDeliveryDistributionStatusNote; dataset.dokDeliveryDistributionStatusAutoUpdate = inputDataset.dokDeliveryDistributionStatusAutoUpdate; dataset.dokDeliveryDistributionStatusId = inputDataset.dokDeliveryDistributionStatusId; dataset.dokDeliveryDistributionStatusId = _registerService.GetDeliveryDownloadStatus(inputDataset.Uuid, inputDataset.dokDeliveryDistributionStatusAutoUpdate, dataset.dokDeliveryDistributionStatusId, dataset.dokDeliveryWfsStatusId, dataset.dokDeliveryAtomFeedStatusId); dataset.Coverage = EditDatasetCoverage(coverage, dataset, originalDataset); dataset.RegionalPlan = inputDataset.RegionalPlan; dataset.RegionalPlanNote = inputDataset.RegionalPlanNote; dataset.MunicipalSocialPlan = inputDataset.MunicipalSocialPlan; dataset.MunicipalSocialPlanNote = inputDataset.MunicipalSocialPlanNote; dataset.MunicipalLandUseElementPlan = inputDataset.MunicipalLandUseElementPlan; dataset.MunicipalLandUseElementPlanNote = inputDataset.MunicipalLandUseElementPlanNote; dataset.ZoningPlanArea = inputDataset.ZoningPlanArea; dataset.ZoningPlanAreaNote = inputDataset.ZoningPlanAreaNote; dataset.ZoningPlanDetails = inputDataset.ZoningPlanDetails; dataset.ZoningPlanDetailsNote = inputDataset.ZoningPlanDetailsNote; dataset.BuildingMatter = inputDataset.BuildingMatter; dataset.BuildingMatterNote = inputDataset.BuildingMatterNote; dataset.PartitionOff = inputDataset.PartitionOff; dataset.PartitionOffNote = inputDataset.PartitionOffNote; dataset.EenvironmentalImpactAssessment = inputDataset.EenvironmentalImpactAssessment; dataset.EenvironmentalImpactAssessmentNote = inputDataset.EenvironmentalImpactAssessmentNote; return(dataset); }
private ActionResult EditCoverageDataset(CoverageDataset coverage, Dataset originalDataset) { originalDataset.Coverage = _datasetService.EditDatasetCoverage(coverage, originalDataset); _registerItemService.SaveEditedRegisterItem(originalDataset); return(Redirect(originalDataset.register.GetDokMunicipalityUrl())); }
public ActionResult EditDokMunicipal(List <DokMunicipalEdit> dokMunicipalList, string municipalityCode, string statusDokMunicipal) { if (_accessControlService.AccessEditOrCreateDOKMunicipalBySelectedMunicipality(municipalityCode)) { Organization municipality = _registerItemService.GetMunicipalityOrganizationByNr(municipalityCode); if (municipality != null) { municipality.UpdateDOKMunicipalStatus(statusDokMunicipal); _registerItemService.SaveEditedRegisterItem(municipality); } CoverageService coverage = new CoverageService(_db); coverage.SetCoverage(municipalityCode); foreach (DokMunicipalEdit item in dokMunicipalList) { Dataset originalDataset = (Dataset)_registerItemService.GetRegisterItemBySystemId(item.Id); originalDataset.modified = DateTime.Now; CoverageDataset originalCoverage = originalDataset.GetCoverageByOwner(item.MunicipalityId); if (item.Delete) { if (originalCoverage != null) { _registerItemService.DeleteCoverage(originalCoverage); } _registerItemService.SaveDeleteRegisterItem(originalDataset); } else { var coverageFound = originalCoverage?.Coverage ?? false; try { coverageFound = coverage.GetCoverage(originalDataset.Uuid); } catch (System.Net.WebException) { TempData["failure"] = "Tjenesten som henter dekning feilet"; } if (originalCoverage == null) { var coverageNew = CreateNewCoverage(item, originalDataset, municipalityCode, coverageFound); _db.Database.ExecuteSqlCommand( "INSERT INTO CoverageDatasets (ConfirmedDok, Coverage, Note," + "RegionalPlan, MunicipalSocialPlan, MunicipalLandUseElementPlan, ZoningPlanArea, ZoningPlanDetails, " + "BuildingMatter, PartitionOff, EenvironmentalImpactAssessment, SuitabilityAssessmentText, " + "CoverageId, MunicipalityId, DatasetId, CoverageDOKStatusId ) " + " VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6, @p7, @p8, @p9, @p10, @p11, @p12, @p13, @p14, @p15 " + ")", coverageNew.ConfirmedDok, coverageFound, coverageNew.Note, item.RegionalPlan, item.MunicipalSocialPlan, item.MunicipalLandUseElementPlan, item.ZoningPlanArea, item.ZoningPlanDetails, item.BuildingMatter, item.PartitionOff, item.EnvironmentalImpactAssessment, item.SuitabilityAssessmentText, coverageNew.CoverageId, coverageNew.MunicipalityId, originalDataset.systemId, coverageNew.CoverageDOKStatusId); } else { _db.Database.ExecuteSqlCommand( "UPDATE CoverageDatasets SET ConfirmedDok = @p0 , " + "Coverage = @p1, " + "Note = @p2, " + "RegionalPlan = @p3, " + "MunicipalSocialPlan = @p4, " + "MunicipalLandUseElementPlan = @p5, " + "ZoningPlanArea = @p6, " + "ZoningPlanDetails = @p7, " + "BuildingMatter = @p8, " + "PartitionOff = @p9, " + "EenvironmentalImpactAssessment = @p10, " + "SuitabilityAssessmentText = @p11 " + "WHERE CoverageId = @p12", item.Confirmed, coverageFound, item.Note, item.RegionalPlan, item.MunicipalSocialPlan, item.MunicipalLandUseElementPlan, item.ZoningPlanArea, item.ZoningPlanDetails, item.BuildingMatter, item.PartitionOff, item.EnvironmentalImpactAssessment, item.SuitabilityAssessmentText, originalCoverage.CoverageId); } } } _db.Database.ExecuteSqlCommand("update Registers set modified = GETDATE() where systemid='E807439B-2BFC-4DA5-87C0-B40E7B0CDFB8'"); return(Redirect("/register/det-offentlige-kartgrunnlaget-kommunalt?municipality=" + municipalityCode)); } return(HttpNotFound()); }