internal string CreateMetadata(MetadataCreateViewModel model, string username)
        {
            SimpleMetadata metadata = null;

            if (model.Type.Equals("service"))
            {
                metadata = SimpleMetadata.CreateService();
            }
            else
            {
                metadata = SimpleMetadata.CreateDataset();
                if (model.Type.Equals("software"))
                {
                    metadata.HierarchyLevel = "software";
                }
                else if (model.Type.Equals("series"))
                {
                    metadata.HierarchyLevel = "series";
                }
            }

            metadata.Title           = model.Title;
            metadata.Abstract        = "...";
            metadata.ContactMetadata = new SimpleContact
            {
                Name         = model.MetadataContactName,
                Email        = model.MetadataContactEmail,
                Organization = model.MetadataContactOrganization,
                Role         = "pointOfContact"
            };

            metadata.ContactPublisher = new SimpleContact
            {
                Name         = model.MetadataContactName,
                Email        = model.MetadataContactEmail,
                Organization = model.MetadataContactOrganization,
                Role         = "publisher"
            };
            metadata.ContactOwner = new SimpleContact
            {
                Name         = model.MetadataContactName,
                Email        = model.MetadataContactEmail,
                Organization = model.MetadataContactOrganization,
                Role         = "owner"
            };

            DateTime now = DateTime.Now;

            metadata.DateCreated   = now;
            metadata.DatePublished = now;
            metadata.DateUpdated   = now;

            SetDefaultValuesOnMetadata(metadata);

            _geoNorge.MetadataInsert(metadata.GetMetadata(), CreateAdditionalHeadersWithUsername(username));

            return(metadata.Uuid);
        }
        public ActionResult Create()
        {
            MetadataCreateViewModel model = new MetadataCreateViewModel
            {
                MetadataContactName = GetSecurityClaim("urn:oid:1.3.6.1.4.1.5923.1.1.1.6"),
                MetadataContactOrganization = GetSecurityClaim("organization"),
                MetadataContactEmail = GetSecurityClaim("urn:oid:1.2.840.113549.1.9.1"),
            };

            return View(model);
        }
 public ActionResult Create(MetadataCreateViewModel model)
 {
     string organization = GetSecurityClaim("organization");
     model.MetadataContactOrganization = organization;
     if (ModelState.IsValid)
     {
         string username = GetUsername();
         string uuid = _metadataService.CreateMetadata(model, username);
         Log.Info(string.Format("Created new metadata: {0} [uuid = {1}] for user: {2} on behalf of {3} ", model.Title, uuid, username, organization));
         return RedirectToAction("Edit", new { uuid = uuid, metadatacreated = true });
     }
     return View(model);
 }
        internal string CreateMetadata(MetadataCreateViewModel model, string username)
        {
            SimpleMetadata metadata = null;
            if (model.Type.Equals("service"))
            {
                metadata = SimpleMetadata.CreateService();
            }
            else
            {
                metadata = SimpleMetadata.CreateDataset();
                if (model.Type.Equals("software"))
                {
                    metadata.HierarchyLevel = "software";
                }
                else if (model.Type.Equals("series"))
                {
                    metadata.HierarchyLevel = "series";
                }
            }

            metadata.Title = model.Title;
            metadata.Abstract = "...";
            metadata.ContactMetadata = new SimpleContact
            {
                Name = model.MetadataContactName,
                Email = model.MetadataContactEmail,
                Organization = model.MetadataContactOrganization,
                Role = "pointOfContact"
            };

            metadata.ContactPublisher = new SimpleContact
            {
                Name = model.MetadataContactName,
                Email = model.MetadataContactEmail,
                Organization = model.MetadataContactOrganization,
                Role = "publisher"
            };
            metadata.ContactOwner = new SimpleContact
            {
                Name = model.MetadataContactName,
                Email = model.MetadataContactEmail,
                Organization = model.MetadataContactOrganization,
                Role = "owner"
            };

            DateTime now = DateTime.Now;
            metadata.DateCreated = now;
            metadata.DatePublished = now;
            metadata.DateUpdated = now;

            SetDefaultValuesOnMetadata(metadata);

            _geoNorge.MetadataInsert(metadata.GetMetadata(), CreateAdditionalHeadersWithUsername(username));

            return metadata.Uuid;
        }
        public ActionResult Create(MetadataCreateViewModel model)
        {
            model.MetadataContactOrganization = GetSecurityClaim("organization");
            if (ModelState.IsValid)
            {
                string uuid = _metadataService.CreateMetadata(model, GetUsername());

                return RedirectToAction("Edit", new { uuid = uuid });
            }
            return View(model);
        }