public ActionResult Create(RegisterDTO registerDTO) { //You can use Db Transactions to add data using (var dbContextTransaction = _registerDbContext.Database.BeginTransaction()) { try { //Assuming this class as Database Entity refering to Register table in Database Register register = new Register(); register.FirstName = registerDTO.FirstName; register.LastName = registerDTO.LastName; register.UserName = registerDTO.UserName; register.Password = registerDTO.Password; _registerDbContext.Register.Add(register); _registerDbContext.SaveChanges(); //Assuming this class as Database Entity refering to UserLogin table in Database UserLogin userLogin = new UserLogin(); userLogin.UserName = registerDTO.UserName; userLogin.Password = registerDTO.Password; _registerDbContext.UserLogin.Add(userLogin); _registerDbContext.SaveChanges(); dbContextTransaction.Commit(); return(View()); } catch (Exception ex) { dbContextTransaction.Rollback(); } } }
public ActionResult DeleteConfirmed(string registername, string itemname, string itemowner, string parentregister) { var queryResults = from o in _db.CodelistValues where o.seoname == itemname && o.register.seoname == registername && o.register.parentRegister.seoname == parentregister select o.systemId; Guid systId = queryResults.FirstOrDefault(); CodelistValue codelistValue = _db.CodelistValues.Find(systId); string parent = null; if (codelistValue.register.parentRegisterId != null) { parent = codelistValue.register.parentRegister.path; } _registerItemService.RemoveBroaderAndNarrower(codelistValue); codelistValue.broaderItemId = null; codelistValue.narrowerItems.Clear(); _db.Entry(codelistValue).State = EntityState.Modified; _db.SaveChanges(); _db.RegisterItems.Remove(codelistValue); _db.SaveChanges(); if (parent != null) { return(Redirect("/" + parent)); } return(Redirect("/register/" + registername)); }
public bool Add(T entity) { DataSet.Add(entity); var rowsAffected = _dbContext.SaveChanges(); return(rowsAffected > 0); }
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 Document UpdateDocument(Document originalDocument, Document document, HttpPostedFileBase documentfile, HttpPostedFileBase thumbnail, bool retired, bool sosi) { originalDocument.Update(document); originalDocument = ApprovalProcess(originalDocument, document, retired, sosi); _dbContext.SaveChanges(); return(originalDocument); }
public Synchronize StartSynchronizationJob(Models.Register register, string itemType) { var synchronizationJob = new Synchronize(); synchronizationJob.Active = true; synchronizationJob.ItemType = itemType; register.Synchronizes.Add(synchronizationJob); _dbContext.SaveChanges(); return(synchronizationJob); }
public ActionResult Import(HttpPostedFileBase csvfile) { string filename = "import_" + Path.GetFileName(csvfile.FileName); var path = Path.Combine(Server.MapPath(Constants.DataDirectory + Organization.DataDirectory), filename); csvfile.SaveAs(path); var lines = System.IO.File.ReadAllLines(path).Select(a => a.Split(';')).Skip(1); foreach (var org in lines) { //orgnr, navn, beskrivelse, logo Organization organization = new Organization(); organization.systemId = Guid.NewGuid(); organization.number = org[0]; organization.name = org[1]; organization.description = org[2]; if (organization.name == null) { organization.name = "ikke angitt"; } string currentUserOrganizationName = CurrentUserOrganizationName(); var queryResultsOrganization = from o in _dbContext.Organizations where o.name == currentUserOrganizationName select o.systemId; Guid orgId = queryResultsOrganization.FirstOrDefault(); Organization submitterOrganisasjon = _dbContext.Organizations.Find(orgId); organization.submitterId = orgId; organization.submitter = submitterOrganisasjon; var queryResultsRegister = from o in _dbContext.Registers where o.name == "Organisasjoner" select o.systemId; Guid regId = queryResultsRegister.FirstOrDefault(); organization.modified = DateTime.Now; organization.dateSubmitted = DateTime.Now; organization.registerId = regId; organization.statusId = "Submitted"; organization.seoname = RegisterUrls.MakeSeoFriendlyString(organization.name); organization.logoFilename = org[3]; organization.largeLogo = org[3]; _dbContext.RegisterItems.Add(organization); _dbContext.SaveChanges(); } return(Redirect("/register/organisasjoner")); }
public Guid NewVersioningGroup(Models.RegisterItem registerItem) { Models.Version versjoneringsGruppe = new Models.Version(); versjoneringsGruppe.systemId = Guid.NewGuid(); versjoneringsGruppe.currentVersion = registerItem.systemId; versjoneringsGruppe.containedItemClass = registerItem.register.containedItemClass; versjoneringsGruppe.lastVersionNumber = registerItem.versionNumber; _dbContext.Entry(versjoneringsGruppe).State = EntityState.Modified; _dbContext.Versions.Add(versjoneringsGruppe); _dbContext.SaveChanges(); return(versjoneringsGruppe.systemId); }
private string AddTheme(string theme) { var queryResultsRegisterItem = from o in _dbContext.DOKThemes where o.value == theme select o.value; if (queryResultsRegisterItem.ToList().Count == 0) { _dbContext.DOKThemes.Add(new DOKTheme { description = theme, value = theme }); _dbContext.SaveChanges(); } return(theme); }
public void SaveInspireMonitoring(Models.Register inspireStatusRegister) { InspireMonitoring monitoring = new InspireMonitoring(inspireStatusRegister.RegisterItems); _dbContext.InspireMonitorings.Add(monitoring); _dbContext.SaveChanges(); }
public Guid CreateDatasetDelivery(string deliveryStatusId, string note, bool autoupdate = true) { var datasetDelivery = new DatasetDelivery(deliveryStatusId, note, autoupdate); _dbContext.DatasetDeliveries.Add(datasetDelivery); _dbContext.SaveChanges(); return(datasetDelivery.DatasetDeliveryId); }
public IActionResult Create(Register v) { if (ModelState.IsValid) { _db.Registers.Add(v); _db.SaveChanges(); return(RedirectToAction("Create")); } return(View()); }
//[Route("navnerom/{parentRegister}/{registerowner}/{registername}/ny")] //[Route("navnerom/{registername}/ny")] public ActionResult Create(NameSpace nameSpace, string systemId) { nameSpace.register = GetRegister(systemId); string parentRegisterOwner = null; if (nameSpace.register.parentRegisterId != null) { parentRegisterOwner = nameSpace.register.parentRegister.owner.seoname; } if (_registerItemService.ItemNameIsValid(nameSpace)) { if (ModelState.IsValid) { nameSpace.systemId = Guid.NewGuid(); if (nameSpace.name == null) { nameSpace.name = "ikke angitt"; } nameSpace.systemId = Guid.NewGuid(); nameSpace.modified = DateTime.Now; nameSpace.dateSubmitted = DateTime.Now; nameSpace.registerId = nameSpace.register.systemId; nameSpace.statusId = "Submitted"; nameSpace.seoname = Helpers.RegisterUrls.MakeSeoFriendlyString(nameSpace.name); nameSpace.versionNumber = 1; nameSpace.versioningId = _registerItemService.NewVersioningGroup(nameSpace); Organization organization = GetSubmitter(); nameSpace.submitterId = organization.systemId; _db.RegisterItems.Add(nameSpace); _db.SaveChanges(); return(Redirect(nameSpace.GetObjectUrl())); } } return(View(nameSpace)); }
public void CreateStatusReport(Models.Register register, bool latestSavedDataReport = false) { if (latestSavedDataReport) { var mareanoRegistryId = Guid.Parse(GlobalVariables.MareanoRegistryId); var currentReport = _dbContext.StatusReports.Where(s => s.Register.systemId == mareanoRegistryId && s.LatestSavedDataReport).FirstOrDefault(); if (currentReport != null) { _dbContext.Database.ExecuteSqlCommand("DELETE FROM RegisterItemStatusReports Where StatusReport_Id ='" + currentReport.Id + "'; DELETE FROM StatusReports WHERE Id = '" + currentReport.Id + "'"); } } var statusReport = new StatusReport(latestSavedDataReport); statusReport.Register = register; foreach (var item in register.items) { if (item is Dataset dataset) { var datasetStatuses = new DatasetStatusHistory(dataset); statusReport.StatusRegisterItems.Add(datasetStatuses); } } foreach (var item in register.RegisterItems) { if (item is InspireDataset inspireDataset) { var inspireDatasetStatuses = new InspireDatasetStatusReport(inspireDataset); statusReport.StatusRegisterItems.Add(inspireDatasetStatuses); } if (item is InspireDataService inspireDataService) { var inspireDataserviceStatuses = new InspireDataserviceStatusReport(inspireDataService); statusReport.StatusRegisterItems.Add(inspireDataserviceStatuses); } if (item is GeodatalovDataset geodatalovDataset) { var geodatalovDatasetStatuses = new GeodatalovDatasetStatusReport(geodatalovDataset); statusReport.StatusRegisterItems.Add(geodatalovDatasetStatuses); } if (item is MareanoDataset mareanoDataset) { var mareanoDatasetStatuses = new MareanoDatasetStatusReport(mareanoDataset); statusReport.StatusRegisterItems.Add(mareanoDatasetStatuses); } } _dbContext.StatusReports.Add(statusReport); _dbContext.SaveChanges(); }
//[Route("dokument/{parentregister}/{parentregisterowner}/{registername}/{itemowner}/{documentname}/slett")] //[Route("dokument/{registername}/{organization}/{documentname}/slett")] public ActionResult DeleteConfirmed(string registername, string documentname, int versionNumber, string parentregister, string parentregisterowner) { Document document = (Document)_registerItemService.GetRegisterItem(parentregister, registername, documentname, versionNumber); string registerUrl = document.register.GetObjectUrl(); if (DocumentIsCurrentVersion(document)) { Models.Version versjonsgruppe = document.versioning; var versionsOfDocument = _registerItemService.GetAllVersionsOfItembyVersioningId(versjonsgruppe.systemId); if (versionsOfDocument.Count() > 1) { GetNewCurrentVersion(document); db.RegisterItems.Remove(document); } else { db.RegisterItems.Remove(document); db.SaveChanges(); db.Versions.Remove(versjonsgruppe); } } else { db.RegisterItems.Remove(document); } db.SaveChanges(); return(Redirect(registerUrl)); }
//[Route("ny")] public ActionResult Create(Models.Register register) { if (IsAdmin()) { if (_registerService.RegisterNameIsValid(register)) { ModelState.AddModelError("ErrorMessage", Registers.ErrorMessageValidationName); } if (ModelState.IsValid) { register.systemId = Guid.NewGuid(); if (register.name == null) { register.name = "ikke angitt"; } register.systemId = Guid.NewGuid(); register.modified = DateTime.Now; register.dateSubmitted = DateTime.Now; register.statusId = "Submitted"; register.seoname = RegisterUrls.MakeSeoFriendlyString(register.name); register.containedItemClass = register.containedItemClass; _db.Registers.Add(register); _db.SaveChanges(); Organization submitterOrganisasjon = _registerService.GetOrganizationByUserName(); register.ownerId = submitterOrganisasjon.systemId; register.managerId = submitterOrganisasjon.systemId; _db.Entry(register).State = EntityState.Modified; _db.SaveChanges(); return(Redirect("/")); } ViewBag.containedItemClass = new SelectList(_db.ContainedItemClass.OrderBy(s => s.description), "value", "description", string.Empty); return(View()); } return(HttpNotFound()); }
public HttpResponseMessage Registration(EmailPassword login) { ModelsDB.Register emailPassword = new ModelsDB.Register(); var logins = DB.Register.Where(p => p.Email == login.Email); if (logins != null) { emailPassword.Email = login.Email; emailPassword.Password = login.Password; DB.Register.Add(emailPassword); DB.SaveChanges(); return(new HttpResponseMessage(HttpStatusCode.OK)); } return(new HttpResponseMessage(HttpStatusCode.BadRequest)); }
public MareanoDataset NewMareanoDataset(MareanoDatasetViewModel MareanoViewModel, string parentregister, string registername) { var MareanoDataset = new MareanoDataset(); MareanoDataset.SystemId = Guid.NewGuid(); MareanoDataset.Name = MareanoViewModel.Name; MareanoDataset.Seoname = RegisterUrls.MakeSeoFriendlyString(MareanoDataset.Name); MareanoDataset.Description = MareanoViewModel.Description; MareanoDataset.SubmitterId = _registerService.GetOrganizationIdByUserName(); MareanoDataset.OwnerId = MareanoViewModel.OwnerId; MareanoDataset.DateSubmitted = DateTime.Now; MareanoDataset.Modified = DateTime.Now; MareanoDataset.RegisterId = _registerService.GetRegisterId(parentregister, registername); MareanoDataset.VersioningId = _registerItemService.NewVersioningGroup(MareanoDataset); MareanoDataset.VersionNumber = 1; MareanoDataset.StatusId = "Submitted"; MareanoDataset.Uuid = MareanoViewModel.Uuid; MareanoDataset.Notes = MareanoViewModel.Notes; MareanoDataset.SpecificUsage = MareanoViewModel.SpecificUsage; MareanoDataset.ProductSheetUrl = MareanoViewModel.ProductSheetUrl; MareanoDataset.PresentationRulesUrl = MareanoViewModel.PresentationRulesUrl; MareanoDataset.ProductSpecificationUrl = MareanoViewModel.ProductSpecificationUrl; MareanoDataset.MetadataUrl = MareanoViewModel.MetadataUrl; MareanoDataset.DistributionFormat = MareanoViewModel.DistributionFormat; MareanoDataset.DistributionUrl = MareanoViewModel.DistributionUrl; MareanoDataset.DistributionArea = MareanoViewModel.DistributionArea; MareanoDataset.WmsUrl = MareanoViewModel.WmsUrl; MareanoDataset.ThemeGroupId = MareanoViewModel.ThemeGroupId; MareanoDataset.DatasetThumbnail = MareanoViewModel.DatasetThumbnail; MareanoDataset.DokStatusId = "Proposal"; MareanoDataset.UuidService = MareanoViewModel.UuidService; GetDeliveryStatuses(MareanoViewModel, MareanoDataset); MareanoDataset.MetadataStatusId = _datasetDeliveryService.CreateDatasetDelivery(MareanoViewModel.MetadataStatusId, MareanoViewModel.MetadataNote); MareanoDataset.ProductSpesificationStatusId = _datasetDeliveryService.CreateDatasetDelivery(MareanoViewModel.WmsStatusId, MareanoViewModel.WmsNote); MareanoDataset.SosiDataStatusId = _datasetDeliveryService.CreateDatasetDelivery(MareanoViewModel.WmsStatusId, MareanoViewModel.WmsNote); MareanoDataset.GmlDataStatusId = _datasetDeliveryService.CreateDatasetDelivery(MareanoViewModel.WmsStatusId, MareanoViewModel.WmsNote); MareanoDataset.WmsStatusId = _datasetDeliveryService.CreateDatasetDelivery(MareanoViewModel.WmsStatusId, MareanoViewModel.WmsNote); MareanoDataset.WfsStatusId = _datasetDeliveryService.CreateDatasetDelivery(MareanoViewModel.WfsStatusId, MareanoViewModel.WfsNote); MareanoDataset.AtomFeedStatusId = _datasetDeliveryService.CreateDatasetDelivery(MareanoViewModel.AtomFeedStatusId, MareanoViewModel.AtomFeedNote); MareanoDataset.CommonStatusId = _datasetDeliveryService.CreateDatasetDelivery(MareanoViewModel.WmsStatusId, MareanoViewModel.WmsNote); MareanoDataset.Grade = GetGrade(MareanoDataset); _dbContext.MareanoDatasets.Add(MareanoDataset); _dbContext.SaveChanges(); return(MareanoDataset); }
public GeodatalovDataset NewGeodatalovDataset(GeodatalovDatasetViewModel geodatalovViewModel, string parentregister, string registername) { var geodatalovDataset = new GeodatalovDataset(); geodatalovDataset.SystemId = Guid.NewGuid(); geodatalovDataset.Name = geodatalovViewModel.Name; geodatalovDataset.Seoname = RegisterUrls.MakeSeoFriendlyString(geodatalovDataset.Name); geodatalovDataset.Description = geodatalovViewModel.Description; geodatalovDataset.SubmitterId = _registerService.GetOrganizationIdByUserName(); geodatalovDataset.OwnerId = geodatalovViewModel.OwnerId; geodatalovDataset.DateSubmitted = DateTime.Now; geodatalovDataset.Modified = DateTime.Now; geodatalovDataset.RegisterId = _registerService.GetRegisterId(parentregister, registername); geodatalovDataset.VersioningId = _registerItemService.NewVersioningGroup(geodatalovDataset); geodatalovDataset.VersionNumber = 1; geodatalovDataset.StatusId = "Submitted"; geodatalovDataset.Uuid = geodatalovViewModel.Uuid; geodatalovDataset.Notes = geodatalovViewModel.Notes; geodatalovDataset.SpecificUsage = geodatalovViewModel.SpecificUsage; geodatalovDataset.ProductSheetUrl = geodatalovViewModel.ProductSheetUrl; geodatalovDataset.PresentationRulesUrl = geodatalovViewModel.PresentationRulesUrl; geodatalovDataset.ProductSpecificationUrl = geodatalovViewModel.ProductSpecificationUrl; geodatalovDataset.MetadataUrl = geodatalovViewModel.MetadataUrl; geodatalovDataset.DistributionFormat = geodatalovViewModel.DistributionFormat; geodatalovDataset.DistributionUrl = geodatalovViewModel.DistributionUrl; geodatalovDataset.DistributionArea = geodatalovViewModel.DistributionArea; geodatalovDataset.WmsUrl = geodatalovViewModel.WmsUrl; geodatalovDataset.ThemeGroupId = geodatalovViewModel.ThemeGroupId; geodatalovDataset.DatasetThumbnail = geodatalovViewModel.DatasetThumbnail; geodatalovDataset.DokStatusId = "Proposal"; geodatalovDataset.UuidService = geodatalovViewModel.UuidService; GetDeliveryStatuses(geodatalovViewModel, geodatalovDataset); geodatalovDataset.InspireTheme = geodatalovViewModel.InspireTheme; geodatalovDataset.Dok = geodatalovViewModel.Dok; geodatalovDataset.NationalDataset = geodatalovViewModel.NationalDataset; geodatalovDataset.Plan = geodatalovViewModel.Plan; geodatalovDataset.Geodatalov = geodatalovViewModel.Geodatalov; geodatalovDataset.MetadataStatusId = _datasetDeliveryService.CreateDatasetDelivery(geodatalovViewModel.MetadataStatusId, geodatalovViewModel.MetadataNote); geodatalovDataset.ProductSpesificationStatusId = _datasetDeliveryService.CreateDatasetDelivery(geodatalovViewModel.WmsStatusId, geodatalovViewModel.WmsNote); geodatalovDataset.SosiDataStatusId = _datasetDeliveryService.CreateDatasetDelivery(geodatalovViewModel.WmsStatusId, geodatalovViewModel.WmsNote); geodatalovDataset.GmlDataStatusId = _datasetDeliveryService.CreateDatasetDelivery(geodatalovViewModel.WmsStatusId, geodatalovViewModel.WmsNote); geodatalovDataset.WmsStatusId = _datasetDeliveryService.CreateDatasetDelivery(geodatalovViewModel.WmsStatusId, geodatalovViewModel.WmsNote); geodatalovDataset.WfsStatusId = _datasetDeliveryService.CreateDatasetDelivery(geodatalovViewModel.WfsStatusId, geodatalovViewModel.WfsNote); geodatalovDataset.AtomFeedStatusId = _datasetDeliveryService.CreateDatasetDelivery(geodatalovViewModel.AtomFeedStatusId, geodatalovViewModel.AtomFeedNote); geodatalovDataset.CommonStatusId = _datasetDeliveryService.CreateDatasetDelivery(geodatalovViewModel.WmsStatusId, geodatalovViewModel.WmsNote); _dbContext.GeodatalovDatasets.Add(geodatalovDataset); _dbContext.SaveChanges(); return(geodatalovDataset); }
public IHttpActionResult PutServiceAlert(string id, AlertUpdate alert) { var originalAlert = _dbContext.Alerts.Where(a => a.systemId.ToString() == id).FirstOrDefault(); if (originalAlert == null) { return(NotFound()); } originalAlert.Summary = alert.Summary; originalAlert.DateResolved = alert.DateResolved; originalAlert.register.modified = System.DateTime.Now; _dbContext.Entry(originalAlert).State = EntityState.Modified; _dbContext.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); }
public bool AddtoTestRegister(TestRegister test) { try { using (regDb = new RegisterDbContext()) { regDb.TestRegisters.Add(test); int status = regDb.SaveChanges(); if (status > 0) { Success = true; } else { } } return(Success); } catch (Exception e) { throw e; } }
public void CreateStatusReport(Models.Register register) { var statusReport = new StatusReport(); statusReport.Register = register; foreach (var item in register.items) { if (item is Dataset dataset) { var datasetStatuses = new DatasetStatusHistory(dataset); statusReport.StatusRegisterItems.Add(datasetStatuses); } } foreach (var item in register.RegisterItems) { if (item is InspireDataset inspireDataset) { var inspireDatasetStatuses = new InspireDatasetStatusReport(inspireDataset); statusReport.StatusRegisterItems.Add(inspireDatasetStatuses); } if (item is InspireDataService inspireDataService) { var inspireDataserviceStatuses = new InspireDataserviceStatusReport(inspireDataService); statusReport.StatusRegisterItems.Add(inspireDataserviceStatuses); } if (item is GeodatalovDataset geodatalovDataset) { var geodatalovDatasetStatuses = new GeodatalovDatasetStatusReport(geodatalovDataset); statusReport.StatusRegisterItems.Add(geodatalovDatasetStatuses); } } _dbContext.StatusReports.Add(statusReport); _dbContext.SaveChanges(); }
//[Route("epsg/{parentRegister}/{registerowner}/{registername}/{itemowner}/{epsgname}/rediger")] //[Route("epsg/{registername}/{organization}/{epsgname}/rediger")] //public ActionResult Edit(EPSG ePSG, string name, string id) public ActionResult Edit(EPSG ePSG, string epsgname, string parentRegister, string registername) { var queryResultsOrganisasjon = from o in db.EPSGs where o.seoname == epsgname && o.register.seoname == registername && o.register.parentRegister.seoname == parentRegister select o.systemId; Guid systId = queryResultsOrganisasjon.FirstOrDefault(); EPSG epsg = db.EPSGs.Find(systId); var queryResultsRegister = from o in db.Registers where o.seoname == registername && o.parentRegister.seoname == parentRegister select o.systemId; Guid regId = queryResultsRegister.FirstOrDefault(); Models.Register register = db.Registers.Find(regId); ValidationName(ePSG, register); if (ModelState.IsValid) { EPSG originalEPSG = db.EPSGs.Find(systId); if (ePSG.name != null) { originalEPSG.name = ePSG.name; } originalEPSG.seoname = Helpers.RegisterUrls.MakeSeoFriendlyString(originalEPSG.name); if (ePSG.description != null) { originalEPSG.description = ePSG.description; } if (ePSG.submitterId != null) { originalEPSG.submitterId = ePSG.submitterId; } if (ePSG.statusId != null) { originalEPSG.statusId = ePSG.statusId; } if (ePSG.epsgcode != null) { originalEPSG.epsgcode = ePSG.epsgcode; } if (ePSG.verticalReferenceSystem != null) { originalEPSG.verticalReferenceSystem = ePSG.verticalReferenceSystem; } if (ePSG.horizontalReferenceSystem != null) { originalEPSG.horizontalReferenceSystem = ePSG.horizontalReferenceSystem; } if (ePSG.dimensionId != null) { originalEPSG.dimensionId = ePSG.dimensionId; } if (ePSG.sosiReferencesystem != null) { originalEPSG.sosiReferencesystem = ePSG.sosiReferencesystem; } if (ePSG.externalReference != null) { originalEPSG.externalReference = ePSG.externalReference; } if (ePSG.inspireRequirementId != null) { originalEPSG.inspireRequirementId = ePSG.inspireRequirementId; } if (ePSG.inspireRequirementDescription != null) { originalEPSG.inspireRequirementDescription = ePSG.inspireRequirementDescription; } if (ePSG.nationalRequirementId != null) { originalEPSG.nationalRequirementId = ePSG.nationalRequirementId; } if (ePSG.nationalRequirementDescription != null) { originalEPSG.nationalRequirementDescription = ePSG.nationalRequirementDescription; } if (ePSG.nationalSeasRequirementId != null) { originalEPSG.nationalSeasRequirementId = ePSG.nationalSeasRequirementId; } if (ePSG.nationalSeasRequirementDescription != null) { originalEPSG.nationalSeasRequirementDescription = ePSG.nationalSeasRequirementDescription; } if (ePSG.statusId != null) { if (ePSG.statusId == "Valid" && originalEPSG.statusId != "Valid") { originalEPSG.dateAccepted = DateTime.Now; } if (originalEPSG.statusId == "Valid" && ePSG.statusId != "Valid") { originalEPSG.dateAccepted = null; } originalEPSG.statusId = ePSG.statusId; } _translationService.UpdateTranslations(ePSG, originalEPSG); originalEPSG.modified = DateTime.Now; db.Entry(originalEPSG).State = EntityState.Modified; db.SaveChanges(); Viewbags(ePSG); if (!String.IsNullOrWhiteSpace(parentRegister)) { return(Redirect("/subregister/" + originalEPSG.register.parentRegister.seoname + "/" + originalEPSG.register.parentRegister.owner.seoname + "/" + registername + "/" + "/" + originalEPSG.submitter.seoname + "/" + originalEPSG.seoname)); } else { return(Redirect("/register/" + registername + "/" + originalEPSG.submitter.seoname + "/" + originalEPSG.seoname)); } } Viewbags(ePSG); return(View(epsg)); }
public InspireDataset NewInspireDataset(InspireDatasetViewModel inspireDatasetViewModel, string parentregister, string registername) { var inspireDataset = new InspireDataset(); inspireDataset.SystemId = Guid.NewGuid(); inspireDataset.Name = inspireDatasetViewModel.Name; inspireDataset.Seoname = RegisterUrls.MakeSeoFriendlyString(inspireDataset.Name); inspireDataset.Description = inspireDatasetViewModel.Description; inspireDataset.SubmitterId = _registerService.GetOrganizationIdByUserName(); inspireDataset.OwnerId = inspireDatasetViewModel.OwnerId; inspireDataset.DateSubmitted = DateTime.Now; inspireDataset.Modified = DateTime.Now; inspireDataset.RegisterId = _registerService.GetRegisterId(parentregister, registername); inspireDataset.VersioningId = _registerItemService.NewVersioningGroup(inspireDataset); inspireDataset.VersionNumber = 1; inspireDataset.StatusId = "Submitted"; inspireDataset.Uuid = inspireDatasetViewModel.Uuid; inspireDataset.Notes = inspireDatasetViewModel.Notes; inspireDataset.SpecificUsage = inspireDatasetViewModel.SpecificUsage; inspireDataset.ProductSheetUrl = inspireDatasetViewModel.ProductSheetUrl; inspireDataset.PresentationRulesUrl = inspireDatasetViewModel.PresentationRulesUrl; inspireDataset.ProductSpecificationUrl = inspireDatasetViewModel.ProductSpecificationUrl; inspireDataset.MetadataUrl = inspireDatasetViewModel.MetadataUrl; inspireDataset.DistributionFormat = inspireDatasetViewModel.DistributionFormat; inspireDataset.DistributionUrl = inspireDatasetViewModel.DistributionUrl; inspireDataset.DistributionArea = inspireDatasetViewModel.DistributionArea; inspireDataset.WmsUrl = inspireDatasetViewModel.WmsUrl; inspireDataset.ThemeGroupId = inspireDatasetViewModel.ThemeGroupId; inspireDataset.DatasetThumbnail = inspireDatasetViewModel.DatasetThumbnail; inspireDataset.DokStatusId = "Proposal"; inspireDataset.UuidService = inspireDatasetViewModel.UuidService; GetDeliveryStatuses(inspireDatasetViewModel, inspireDataset); inspireDataset.InspireThemes = inspireDatasetViewModel.InspireThemes; inspireDataset.InspireDeliveryMetadataId = _datasetDeliveryService.CreateDatasetDelivery(inspireDatasetViewModel.MetadataStatusId, inspireDatasetViewModel.MetadataNote); inspireDataset.InspireDeliveryMetadataServiceId = _datasetDeliveryService.CreateDatasetDelivery(inspireDatasetViewModel.MetadataServiceStatusId, inspireDatasetViewModel.MetadataServiceNote); inspireDataset.InspireDeliveryDistributionId = _datasetDeliveryService.CreateDatasetDelivery(inspireDatasetViewModel.DistributionStatusId, inspireDatasetViewModel.DistributionNote); inspireDataset.InspireDeliveryWmsId = _datasetDeliveryService.CreateDatasetDelivery(inspireDatasetViewModel.WmsStatusId, inspireDatasetViewModel.WmsNote); inspireDataset.InspireDeliveryWfsId = _datasetDeliveryService.CreateDatasetDelivery(inspireDatasetViewModel.WfsStatusId, inspireDatasetViewModel.WfsNote); inspireDataset.InspireDeliveryAtomFeedId = _datasetDeliveryService.CreateDatasetDelivery(inspireDatasetViewModel.AtomFeedStatusId, inspireDatasetViewModel.AtomFeedNote); inspireDataset.InspireDeliveryWfsOrAtomId = _datasetDeliveryService.CreateDatasetDelivery(inspireDatasetViewModel.WfsOrAtomStatusId, inspireDatasetViewModel.WfsOrAtomNote); inspireDataset.InspireDeliveryHarmonizedDataId = _datasetDeliveryService.CreateDatasetDelivery(inspireDatasetViewModel.HarmonizedDataStatusId, inspireDatasetViewModel.HarmonizedDataNote); inspireDataset.InspireDeliverySpatialDataServiceId = _datasetDeliveryService.CreateDatasetDelivery(inspireDatasetViewModel.SpatialDataServiceStatusId, inspireDatasetViewModel.SpatialDataServiceNote); _dbContext.InspireDatasets.Add(inspireDataset); _dbContext.SaveChanges(); return(inspireDataset); }
public void SaveChanges() { _dbContext.SaveChanges(); }
//[Route("subregister/{registername}/{registerOwner}/{subregister}/rediger")] public ActionResult Edit(Models.Register register, string registername, string subregister) { var originalRegister = _registerService.GetRegister(registername, subregister); if (_accessControlService.Access(originalRegister)) { ValidationName(register, registername); if (ModelState.IsValid) { if (register.name != null) { originalRegister.name = register.name; } originalRegister.seoname = Helpers.RegisterUrls.MakeSeoFriendlyString(originalRegister.name); if (register.description != null) { originalRegister.description = register.description; } if (register.ownerId != null) { originalRegister.ownerId = register.ownerId; } if (register.managerId != null) { originalRegister.managerId = register.managerId; } if (register.targetNamespace != null) { originalRegister.targetNamespace = register.targetNamespace; } originalRegister.accessId = register.accessId; originalRegister.parentRegisterId = register.parentRegisterId; originalRegister.modified = DateTime.Now; if (register.statusId != null) { originalRegister.statusId = register.statusId; if (originalRegister.statusId != "Valid" && register.statusId == "Valid") { originalRegister.dateAccepted = DateTime.Now; } if (originalRegister.statusId == "Valid" && register.statusId != "Valid") { originalRegister.dateAccepted = null; } } originalRegister.MakeAllItemsValid = register.MakeAllItemsValid; if (originalRegister.MakeAllItemsValid) { _registerItemService.MakeAllRegisterItemsValid(originalRegister); } _translationService.UpdateTranslations(register, originalRegister); _db.Entry(originalRegister).State = EntityState.Modified; _db.SaveChanges(); Viewbags(register); return(Redirect(originalRegister.GetObjectUrl())); } } else { throw new HttpException(401, "Access Denied"); } Viewbags(register); return(View(originalRegister)); }
//[Route("subregister/{registername}/{registerOwner}/{subregister}/rediger")] public ActionResult Edit(Models.Register register, string registername, DateTime?itemsValidFrom, DateTime?itemsValidTo) { var originalRegister = _registerService.GetRegisterBySystemId(register.systemId); if (_accessControlService.HasAccessTo(originalRegister)) { ValidationName(register, originalRegister); if (ModelState.IsValid) { if (register.name != null) { originalRegister.name = register.name; } originalRegister.seoname = Helpers.RegisterUrls.MakeSeoFriendlyString(originalRegister.name, register.TransliterNorwegian); var pathOld = originalRegister.path; var transliterNorwegianOld = originalRegister.TransliterNorwegian; originalRegister.path = RegisterUrls.GetNewPath(originalRegister.path, originalRegister.seoname); if (register.description != null) { originalRegister.description = register.description; } if (register.ownerId != null) { originalRegister.ownerId = register.ownerId; } if (register.managerId != null) { originalRegister.managerId = register.managerId; } if (register.targetNamespace != null) { originalRegister.targetNamespace = register.targetNamespace; } originalRegister.accessId = register.accessId; originalRegister.parentRegisterId = register.parentRegisterId; originalRegister.modified = DateTime.Now; if (register.statusId != null) { originalRegister.statusId = register.statusId; if (originalRegister.statusId != "Valid" && register.statusId == "Valid") { originalRegister.dateAccepted = DateTime.Now; } if (originalRegister.statusId == "Valid" && register.statusId != "Valid") { originalRegister.dateAccepted = null; } } originalRegister.MakeAllItemsValid = register.MakeAllItemsValid; if (originalRegister.MakeAllItemsValid) { _registerItemService.MakeAllRegisterItemsValid(originalRegister, itemsValidFrom, itemsValidTo); } originalRegister.MakeAllItemsRetired = register.MakeAllItemsRetired; if (originalRegister.MakeAllItemsRetired) { _registerItemService.MakeAllRegisterItemsRetired(originalRegister); } originalRegister.MakeAllItemsDraft = register.MakeAllItemsDraft; if (originalRegister.MakeAllItemsDraft) { _registerItemService.MakeAllRegisterItemsDraft(originalRegister); } originalRegister.TransliterNorwegian = register.TransliterNorwegian; _translationService.UpdateTranslations(register, originalRegister); _db.Entry(originalRegister).State = EntityState.Modified; _db.SaveChanges(); if (pathOld != originalRegister.path || transliterNorwegianOld != originalRegister.TransliterNorwegian) { new SynchronizationService(_db).UpdatePaths(originalRegister.systemId.ToString(), originalRegister.TransliterNorwegian); } Viewbags(register); return(Redirect(originalRegister.GetObjectUrl())); } } else { throw new HttpException(401, "Access Denied"); } Viewbags(register); return(View(originalRegister)); }