public ActionResult Create(GeoDataCollection collection, string ownerId) { try { if (!(User.IsInRole(GeonorgeRoles.MetadataAdmin) || User.IsInRole(GeonorgeRoles.MetadataEditor))) { new HttpUnauthorizedResult(); } var org = _dbContext.Organizations.Where(o => o.systemId.ToString() == ownerId).FirstOrDefault(); collection.systemId = Guid.NewGuid(); collection.Organization = org; collection.Owner = ClaimsPrincipal.Current.GetOrganizationName(); collection.SeoName = RegisterUrls.MakeSeoFriendlyString(collection.Title); _dbContext.GeoDataCollections.Add(collection); _dbContext.SaveChanges(); return(Redirect("Edit?id=" + collection.systemId)); } catch { return(View()); } }
public ActionResult Delete(string id, GeoDataCollection collection) { try { var geocollection = _dbContext.GeoDataCollections.Where(g => g.systemId.ToString() == id).FirstOrDefault(); if (!(User.IsInRole(GeonorgeRoles.MetadataAdmin) || (User.IsInRole(GeonorgeRoles.MetadataEditor) && geocollection.Owner == ClaimsPrincipal.Current.GetOrganizationName()))) { new HttpUnauthorizedResult(); } _dbContext.GeoDataCollections.Remove(geocollection); _dbContext.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
private void FixEmptyLabels(ref GeoDataCollection model) { if (string.IsNullOrEmpty(model.LinkInfoPageLabel)) { model.LinkInfoPageLabel = GeodataCollection.LinkInfoPage; } if (string.IsNullOrEmpty(model.ProcessHistoryLabel)) { model.ProcessHistoryLabel = GeodataCollection.ProcessHistory; } if (string.IsNullOrEmpty(model.LinkToRequirementsForDeliveryLabel)) { model.LinkToRequirementsForDeliveryLabel = GeodataCollection.LinkToRequirementsForDelivery; } if (string.IsNullOrEmpty(model.LinkToMapSolutionLabel)) { model.LinkToMapSolutionLabel = GeodataCollection.LinkToMapSolution; } if (string.IsNullOrEmpty(model.LinkLabel)) { model.LinkLabel = GeodataCollection.Link; } if (string.IsNullOrEmpty(model.OtherWebInfoAboutMappingMethodologyLabel)) { model.OtherWebInfoAboutMappingMethodologyLabel = GeodataCollection.OtherWebInfoAboutMappingMethodology; } if (string.IsNullOrEmpty(model.MappingRequirementsLinkLabel)) { model.MappingRequirementsLinkLabel = GeodataCollection.MappingRequirementsLink; } }
public JsonGeoDataDiagramBuilder(string jsonGeoData, IDiagramXmlBuilder diagramXmlBuilder) { _geoData = JsonConvert.DeserializeObject <GeoDataCollection>(jsonGeoData); _diagramXmlBuilder = diagramXmlBuilder; }
public ActionResult Edit(string systemId, string ownerId, string responsibleId, GeoDataCollection collection, HttpPostedFileBase imagefile) { try { var sanitizer = new HtmlSanitizer(); var geodataCollection = _dbContext.GeoDataCollections.Where(g => g.systemId.ToString() == systemId).FirstOrDefault(); if (!(User.IsInRole(GeonorgeRoles.MetadataAdmin) || (User.IsInRole(GeonorgeRoles.MetadataEditor) && geodataCollection.Owner == ClaimsPrincipal.Current.GetOrganizationName()))) { new HttpUnauthorizedResult(); } geodataCollection.Title = sanitizer.Sanitize(collection.Title); geodataCollection.SeoName = RegisterUrls.MakeSeoFriendlyString(sanitizer.Sanitize(collection.Title)); geodataCollection.Link = sanitizer.Sanitize(collection.Link); geodataCollection.LinkLabel = sanitizer.Sanitize(collection.LinkLabel); geodataCollection.Purpose = sanitizer.Sanitize(collection.Purpose); geodataCollection.DatasetTitle = sanitizer.Sanitize(collection.DatasetTitle); geodataCollection.DatasetLink = sanitizer.Sanitize(collection.DatasetLink); geodataCollection.Mapper = sanitizer.Sanitize(collection.Mapper); geodataCollection.DataOwner = sanitizer.Sanitize(collection.DataOwner); geodataCollection.Distributor = sanitizer.Sanitize(collection.Distributor); geodataCollection.Methodology = sanitizer.Sanitize(collection.Methodology); geodataCollection.ProcessHistory = sanitizer.Sanitize(collection.ProcessHistory); geodataCollection.ProcessHistoryLabel = sanitizer.Sanitize(collection.ProcessHistoryLabel); geodataCollection.RegistrationRequirements = sanitizer.Sanitize(collection.RegistrationRequirements); geodataCollection.MappingRequirements = sanitizer.Sanitize(collection.MappingRequirements); geodataCollection.MappingRequirementsLink = sanitizer.Sanitize(collection.MappingRequirementsLink); geodataCollection.MappingRequirementsLinkLabel = sanitizer.Sanitize(collection.MappingRequirementsLinkLabel); geodataCollection.MethodologyDocumentLink = sanitizer.Sanitize(collection.MethodologyDocumentLink); geodataCollection.MethodologyLinkWebPage = sanitizer.Sanitize(collection.MethodologyLinkWebPage); geodataCollection.SupportSchemes = sanitizer.Sanitize(collection.SupportSchemes); geodataCollection.OtherOrganizationsInvolved = sanitizer.Sanitize(collection.OtherOrganizationsInvolved); geodataCollection.LinkToMapSolution = sanitizer.Sanitize(collection.LinkToMapSolution); geodataCollection.LinkToMapSolutionLabel = sanitizer.Sanitize(collection.LinkToMapSolutionLabel); geodataCollection.LinkInfoPage = sanitizer.Sanitize(collection.LinkInfoPage); geodataCollection.LinkInfoPageLabel = sanitizer.Sanitize(collection.LinkInfoPageLabel); geodataCollection.LinkOtherInfo = sanitizer.Sanitize(collection.LinkOtherInfo); geodataCollection.OtherInfo = sanitizer.Sanitize(collection.OtherInfo); geodataCollection.AidAndSubsidies = sanitizer.Sanitize(collection.AidAndSubsidies); geodataCollection.MethodForMappingShort = sanitizer.Sanitize(collection.MethodForMappingShort); geodataCollection.OtherWebInfoAboutMappingMethodology = sanitizer.Sanitize(collection.OtherWebInfoAboutMappingMethodology); geodataCollection.OtherWebInfoAboutMappingMethodologyLabel = sanitizer.Sanitize(collection.OtherWebInfoAboutMappingMethodologyLabel); geodataCollection.LinkToRequirementsForDelivery = sanitizer.Sanitize(collection.LinkToRequirementsForDelivery); geodataCollection.LinkToRequirementsForDeliveryLabel = sanitizer.Sanitize(collection.LinkToRequirementsForDeliveryLabel); geodataCollection.OrganizationInfo = sanitizer.Sanitize(collection.OrganizationInfo); geodataCollection.ContactEmail = sanitizer.Sanitize(collection.ContactEmail); var org = _dbContext.Organizations.Where(o => o.systemId.ToString() == ownerId).FirstOrDefault(); geodataCollection.Organization = org; var responsible = _dbContext.Organizations.Where(o => o.systemId.ToString() == responsibleId).FirstOrDefault(); if (responsible != null) { geodataCollection.Responsible = responsible; } if (imagefile != null && imagefile.ContentLength > 0) { geodataCollection.ThumbnailFileName = SaveImageOptimizedToDisk(imagefile, geodataCollection.SeoName); geodataCollection.ImageFileName = SaveImageToDisk(imagefile, geodataCollection.SeoName); } _dbContext.Entry(geodataCollection).State = EntityState.Modified; _dbContext.SaveChanges(); ViewBag.ownerId = new SelectList(_dbContext.Organizations.ToList().Select(s => new { s.systemId, name = s.NameTranslated() }).OrderBy(s => s.name), "systemId", "name", geodataCollection.Organization.systemId); return(RedirectToAction("Index")); } catch { return(View()); } }