public string CreateOffice() { string result = "Office created successfully"; try { // Set a transaction name and get the version manager var transactionName = "someTransactionName"; var versionManager = VersionManager.GetManager(null, transactionName); // Set the culture name for the multilingual fields var cultureName = "en"; Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureName); DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(this.ProviderName, transactionName); DynamicContent officeItem = dynamicModuleManager.CreateDataItem(this.OfficeType); // This is how values for the properties are set officeItem.SetString("Title", "New York", cultureName); officeItem.SetString("Info", LOREM_IPSUM, cultureName); Address address = new Address(); CountryElement addressCountry = Telerik.Sitefinity.Configuration.Config.Get <LocationsConfig>().Countries.Values.First(x => x.Name == "United States"); address.CountryCode = addressCountry.IsoCode; address.StateCode = addressCountry.StatesProvinces.Values.First().Abbreviation; address.City = "New York City"; address.Street = "Baker Street"; address.Zip = "12345"; officeItem.SetValue("Address", address); // Get related item manager LibrariesManager pictureManager = LibrariesManager.GetManager("OpenAccessDataProvider"); var pictureItem = pictureManager.GetImages().FirstOrDefault(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master && i.Title.Contains("New York")); if (pictureItem != null) { // This is how we relate an item officeItem.CreateRelation(pictureItem, "Picture"); } officeItem.SetString("UrlName", "new-york", cultureName); officeItem.SetValue("Owner", SecurityManager.GetCurrentUserId()); officeItem.SetValue("PublicationDate", DateTime.UtcNow); officeItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Draft", new CultureInfo(cultureName)); // Create a version and commit the transaction in order changes to be persisted to data store versionManager.CreateVersion(officeItem, false); TransactionManager.CommitTransaction(transactionName); } catch (Exception ex) { return(ex.Message.ToString()); } return(result); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as Address; if (dest != null) { base.CopyTo(dest); if (UseElement != null) { dest.UseElement = (Code <Hl7.Fhir.Model.Address.AddressUse>)UseElement.DeepCopy(); } if (TypeElement != null) { dest.TypeElement = (Code <Hl7.Fhir.Model.Address.AddressType>)TypeElement.DeepCopy(); } if (TextElement != null) { dest.TextElement = (Hl7.Fhir.Model.FhirString)TextElement.DeepCopy(); } if (LineElement != null) { dest.LineElement = new List <Hl7.Fhir.Model.FhirString>(LineElement.DeepCopy()); } if (CityElement != null) { dest.CityElement = (Hl7.Fhir.Model.FhirString)CityElement.DeepCopy(); } if (DistrictElement != null) { dest.DistrictElement = (Hl7.Fhir.Model.FhirString)DistrictElement.DeepCopy(); } if (StateElement != null) { dest.StateElement = (Hl7.Fhir.Model.FhirString)StateElement.DeepCopy(); } if (PostalCodeElement != null) { dest.PostalCodeElement = (Hl7.Fhir.Model.FhirString)PostalCodeElement.DeepCopy(); } if (CountryElement != null) { dest.CountryElement = (Hl7.Fhir.Model.FhirString)CountryElement.DeepCopy(); } if (Period != null) { dest.Period = (Hl7.Fhir.Model.Period)Period.DeepCopy(); } return(dest); } else { throw new ArgumentException("Can only copy to an object of the same type", "other"); } }
private Address GetAddress() { Address address = new Address(); CountryElement addressCountry = Config.Get <LocationsConfig>().Countries.Values.First(x => x.Name == "United States"); address.CountryCode = addressCountry.IsoCode; address.StateCode = addressCountry.StatesProvinces.Values.First().Abbreviation; address.City = "Some City"; address.Street = "Some Street"; address.Zip = "12345"; return(address); }
/// <summary> /// Sets the country. /// </summary> /// <param name="country">The country.</param> /// <returns></returns> public virtual IAddressesCreateOrUpdatePage <T> SetCountry(string country) { CountryElement.SelectByText(country); WrappedDriver .Wait(TimeSpan.FromSeconds(30)) .TrySequentialWait( out var exc, d => StateProvinceLoadingElement.Displayed, d => !StateProvinceLoadingElement.Displayed); return(this); }
public void CreateFestival() { DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(); Type festivalType = TypeResolutionService.ResolveType(HierarchicalDynamicContentTests.FestivalType); DynamicContent festivalItem = dynamicModuleManager.CreateDataItem(festivalType, HierarchicalDynamicContentTests.FestivalId, dynamicModuleManager.Provider.ApplicationName); festivalItem.SetValue("Name", "Test Name"); festivalItem.SetValue("Description", "Test Description"); festivalItem.SetValue("From", DateTime.Now); festivalItem.SetValue("To", DateTime.Now); LibrariesManager mainPictureManager = LibrariesManager.GetManager(); var mainPictureItem = mainPictureManager.GetImages().FirstOrDefault(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master); if (mainPictureItem != null) { festivalItem.CreateRelation(mainPictureItem, "MainPicture"); } Address address = new Address(); CountryElement addressCountry = Config.Get <LocationsConfig>().Countries.Values.First(x => x.Name == "United States"); address.CountryCode = addressCountry.IsoCode; address.StateCode = addressCountry.StatesProvinces.Values.First().Abbreviation; address.City = "Test City"; address.Street = "Test Street"; address.Zip = "12345"; address.Latitude = 0.00; address.Longitude = 0.00; address.MapZoomLevel = 8; festivalItem.SetValue("Address", address); festivalItem.SetString("UrlName", "TestUrlName"); festivalItem.SetValue("Owner", SecurityManager.GetCurrentUserId()); festivalItem.SetValue("PublicationDate", DateTime.Now); festivalItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Draft"); dynamicModuleManager.SaveChanges(); var actualFestival = dynamicModuleManager.GetDataItem(festivalType, festivalItem.Id); Assert.IsNotNull(actualFestival); Assert.AreEqual(festivalItem.GetValue("Name").ToString(), actualFestival.GetValue("Name").ToString()); Assert.AreEqual(festivalItem.GetValue("Description").ToString(), actualFestival.GetValue("Description").ToString()); Assert.AreEqual(festivalItem.GetValue("From"), actualFestival.GetValue("From")); Assert.AreEqual(festivalItem.GetValue("To"), actualFestival.GetValue("To")); Assert.AreEqual(festivalItem.GetValue("MainPicture"), actualFestival.GetValue("MainPicture")); Assert.AreEqual(festivalItem.GetValue("Address"), actualFestival.GetValue("Address")); Assert.AreEqual(festivalItem.GetValue("UrlName").ToString(), actualFestival.GetValue("UrlName").ToString()); Assert.AreEqual(festivalItem.GetValue("Owner"), actualFestival.GetValue("Owner")); Assert.AreEqual(festivalItem.GetValue("PublicationDate"), actualFestival.GetValue("PublicationDate")); }
public void CreateCity() { DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(); Type cityType = TypeResolutionService.ResolveType(HierarchicalDynamicContentTests.CityType); DynamicContent cityItem = dynamicModuleManager.CreateDataItem(cityType, HierarchicalDynamicContentTests.CityId, dynamicModuleManager.Provider.ApplicationName); cityItem.SetValue("Name", "Test Name"); cityItem.SetValue("History", "Test History"); Address location = new Address(); CountryElement locationCountry = Config.Get <LocationsConfig>().Countries.Values.First(x => x.Name == "United States"); location.CountryCode = locationCountry.IsoCode; location.StateCode = locationCountry.StatesProvinces.Values.First().Abbreviation; location.City = "Test City"; location.Street = "Test Street"; location.Zip = "12345"; location.Latitude = 0.00; location.Longitude = 0.00; location.MapZoomLevel = 8; cityItem.SetValue("Location", location); LibrariesManager mainPictureManager = LibrariesManager.GetManager(); var mainPictureItem = mainPictureManager.GetImages().FirstOrDefault(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master); if (mainPictureItem != null) { cityItem.CreateRelation(mainPictureItem, "MainPicture"); } cityItem.SetString("UrlName", "TestUrlName"); cityItem.SetValue("Owner", SecurityManager.GetCurrentUserId()); cityItem.SetValue("PublicationDate", DateTime.Now); cityItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Draft"); dynamicModuleManager.SaveChanges(); var actualCity = dynamicModuleManager.GetDataItem(cityType, cityItem.Id); Assert.IsNotNull(actualCity); Assert.AreEqual(cityItem.GetValue("Name").ToString(), actualCity.GetValue("Name").ToString()); Assert.AreEqual(cityItem.GetValue("History").ToString(), actualCity.GetValue("History").ToString()); Assert.AreEqual(cityItem.GetValue("Location"), actualCity.GetValue("Location")); Assert.AreEqual(cityItem.GetValue("MainPicture"), actualCity.GetValue("MainPicture")); Assert.AreEqual(cityItem.GetValue("UrlName").ToString(), actualCity.GetValue("UrlName").ToString()); Assert.AreEqual(cityItem.GetValue("Owner"), actualCity.GetValue("Owner")); Assert.AreEqual(cityItem.GetValue("PublicationDate"), actualCity.GetValue("PublicationDate")); }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if (UseElement != null) { result.AddRange(UseElement.Validate()); } if (TextElement != null) { result.AddRange(TextElement.Validate()); } if (LineElement != null) { LineElement.ForEach(elem => result.AddRange(elem.Validate())); } if (CityElement != null) { result.AddRange(CityElement.Validate()); } if (StateElement != null) { result.AddRange(StateElement.Validate()); } if (ZipElement != null) { result.AddRange(ZipElement.Validate()); } if (CountryElement != null) { result.AddRange(CountryElement.Validate()); } if (Period != null) { result.AddRange(Period.Validate()); } return(result); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as NamingSystem; if (dest != null) { base.CopyTo(dest); if (TypeElement != null) { dest.TypeElement = (Code <Hl7.Fhir.Model.NamingSystem.NamingSystemType>)TypeElement.DeepCopy(); } if (NameElement != null) { dest.NameElement = (Hl7.Fhir.Model.FhirString)NameElement.DeepCopy(); } if (DateElement != null) { dest.DateElement = (Hl7.Fhir.Model.FhirDateTime)DateElement.DeepCopy(); } if (StatusElement != null) { dest.StatusElement = (Code <Hl7.Fhir.Model.ConformanceResourceStatus>)StatusElement.DeepCopy(); } if (CountryElement != null) { dest.CountryElement = (Hl7.Fhir.Model.Code)CountryElement.DeepCopy(); } if (Category != null) { dest.Category = (Hl7.Fhir.Model.CodeableConcept)Category.DeepCopy(); } if (ResponsibleElement != null) { dest.ResponsibleElement = (Hl7.Fhir.Model.FhirString)ResponsibleElement.DeepCopy(); } if (DescriptionElement != null) { dest.DescriptionElement = (Hl7.Fhir.Model.FhirString)DescriptionElement.DeepCopy(); } if (UsageElement != null) { dest.UsageElement = (Hl7.Fhir.Model.FhirString)UsageElement.DeepCopy(); } if (UniqueId != null) { dest.UniqueId = new List <Hl7.Fhir.Model.NamingSystem.NamingSystemUniqueIdComponent>(UniqueId.DeepCopy()); } if (PublisherElement != null) { dest.PublisherElement = (Hl7.Fhir.Model.FhirString)PublisherElement.DeepCopy(); } if (Contact != null) { dest.Contact = new List <Hl7.Fhir.Model.NamingSystem.NamingSystemContactComponent>(Contact.DeepCopy()); } if (ReplacedBy != null) { dest.ReplacedBy = (Hl7.Fhir.Model.ResourceReference)ReplacedBy.DeepCopy(); } return(dest); } else { throw new ArgumentException("Can only copy to an object of the same type", "other"); } }
public void CreateAlltypes() { // Set the provider name for the DynamicModuleManager here. All available providers are listed in // Administration -> Settings -> Advanced -> DynamicModules -> Providers var providerName = string.Empty; if (ServerOperations.MultiSite().CheckIsMultisiteMode()) { providerName = "dynamicContentProvider"; } DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName); Type alltypesType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.AllTypesModule.Alltypes"); DynamicContent alltypesItem = dynamicModuleManager.CreateDataItem(alltypesType); //// This is how values for the properties are set alltypesItem.SetValue("Title", "Some Title"); alltypesItem.SetValue("LongText", "Some LongText"); alltypesItem.SetValue("ShortText", "Some ShortText"); //// Set the selected value alltypesItem.SetValue("Choices", new string[] { "1" }); //// Set the selected value alltypesItem.SetValue("ChoicesRadioButtons", "2"); //// Set the selected value alltypesItem.SetValue("ChoicesDropDown", "3"); alltypesItem.SetValue("YesNo", true); alltypesItem.SetValue("DateTime", DateTime.Now); alltypesItem.SetValue("Number", 25); TaxonomyManager taxonomyManager = TaxonomyManager.GetManager(); var category = taxonomyManager.GetTaxa <HierarchicalTaxon>().Where(t => t.Taxonomy.Name == "Categories").FirstOrDefault(); if (category != null) { alltypesItem.Organizer.AddTaxa("Category", category.Id); } var tag = taxonomyManager.GetTaxa <FlatTaxon>().Where(t => t.Taxonomy.Name == "Tags").FirstOrDefault(); if (tag != null) { alltypesItem.Organizer.AddTaxa("Tags", tag.Id); } Address address = new Address(); CountryElement addressCountry = Config.Get <LocationsConfig>().Countries.Values.First(x => x.Name == "United States"); address.CountryCode = addressCountry.IsoCode; address.StateCode = addressCountry.StatesProvinces.Values.First().Abbreviation; address.City = "Some City"; address.Street = "Some Street"; address.Zip = "12345"; alltypesItem.SetValue("Address", address); alltypesItem.SetString("UrlName", "SomeUrlName"); alltypesItem.SetValue("Owner", SecurityManager.GetCurrentUserId()); alltypesItem.SetValue("PublicationDate", DateTime.Now); alltypesItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Published"); dynamicModuleManager.Lifecycle.Publish(alltypesItem); // You need to call SaveChanges() in order for the items to be actually persisted to data store dynamicModuleManager.SaveChanges(); }
public void CreateHotel() { DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(); Type hotelType = TypeResolutionService.ResolveType(HierarchicalDynamicContentTests.HotelType); DynamicContent hotelItem = dynamicModuleManager.CreateDataItem(hotelType, HierarchicalDynamicContentTests.HotelId, dynamicModuleManager.Provider.ApplicationName); hotelItem.SetValue("Name", "Test Name"); hotelItem.SetValue("Overview", "Test Overview"); hotelItem.SetValue("Checkin", "Test Checkin"); hotelItem.SetValue("Checkout", "Test Checkout"); hotelItem.SetValue("FoodAndDrink", new string[] { "Option2" }); hotelItem.SetValue("Activities", new string[] { "Option2" }); hotelItem.SetValue("Rating", 25); TaxonomyManager taxonomyManager = TaxonomyManager.GetManager(); var Tag = taxonomyManager.GetTaxa <FlatTaxon>().Where(t => t.Taxonomy.Name == "Tags").FirstOrDefault(); if (Tag != null) { hotelItem.Organizer.AddTaxa("Tags", Tag.Id); } Address location = new Address(); CountryElement locationCountry = Config.Get <LocationsConfig>().Countries.Values.First(x => x.Name == "United States"); location.CountryCode = locationCountry.IsoCode; location.StateCode = locationCountry.StatesProvinces.Values.First().Abbreviation; location.City = "Test City"; location.Street = "Test Street"; location.Zip = "12345"; location.Latitude = 0.00; location.Longitude = 0.00; location.MapZoomLevel = 8; hotelItem.SetValue("Location", location); LibrariesManager mainPictureManager = LibrariesManager.GetManager(); var mainPictureItem = mainPictureManager.GetImages().FirstOrDefault(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master); if (mainPictureItem != null) { hotelItem.CreateRelation(mainPictureItem, "MainPicture"); } hotelItem.SetString("UrlName", "TestUrlName"); hotelItem.SetValue("Owner", SecurityManager.GetCurrentUserId()); hotelItem.SetValue("PublicationDate", DateTime.Now); hotelItem.SetWorkflowStatus(dynamicModuleManager.Provider.ApplicationName, "Draft"); dynamicModuleManager.SaveChanges(); var actualHotel = dynamicModuleManager.GetDataItem(hotelType, hotelItem.Id); Assert.IsNotNull(actualHotel); Assert.AreEqual(hotelItem.GetValue("Name").ToString(), actualHotel.GetValue("Name").ToString()); Assert.AreEqual(hotelItem.GetValue("Overview").ToString(), actualHotel.GetValue("Overview").ToString()); Assert.AreEqual(hotelItem.GetValue("Checkin").ToString(), actualHotel.GetValue("Checkin").ToString()); Assert.AreEqual(hotelItem.GetValue("Checkout").ToString(), actualHotel.GetValue("Checkout").ToString()); Assert.AreEqual(hotelItem.GetValue("FoodAndDrink").ToString(), actualHotel.GetValue("FoodAndDrink").ToString()); Assert.AreEqual(hotelItem.GetValue("Activities").ToString(), actualHotel.GetValue("Activities").ToString()); Assert.AreEqual(hotelItem.GetValue("Rating"), actualHotel.GetValue("Rating")); Assert.AreEqual(hotelItem.GetValue("MainPicture"), actualHotel.GetValue("MainPicture")); Assert.AreEqual(hotelItem.GetValue("Location"), actualHotel.GetValue("Location")); Assert.AreEqual(hotelItem.GetValue("UrlName").ToString(), actualHotel.GetValue("UrlName").ToString()); Assert.AreEqual(hotelItem.GetValue("Owner"), actualHotel.GetValue("Owner")); Assert.AreEqual(hotelItem.GetValue("PublicationDate"), actualHotel.GetValue("PublicationDate")); }