public async Task <ActionResult> CreateGroup(GroupViewModel groupViewModel) { if (ModelState.IsValid) { var newGroup = new ApplicationGroup() { GroupName = groupViewModel.GroupName, GroupDescription = groupViewModel.GroupDescription }; var result = await GroupManager.CreateAsync(newGroup); if (result.Succeeded) { return(RedirectToAction("GroupList")); } else { foreach (var error in result.Errors) { ModelState.AddModelError("", error); } } } return(View(groupViewModel)); }
public async Task <ActionResult> AddGroup(AddGroupViewModel model) { if (ModelState.IsValid) { Group group = new Group(); // Getting the group propoties group.Name = model.Name; group.Description = model.Description; group.Category = model.Category; // Checking if there was a image uploaded if (model.Image != null) { await GroupManager.CreateAsync(group, Bitmap.FromStream(model.Image.InputStream)); } else { await GroupManager.CreateAsync(group); } } else { return(View(model)); } // Than go to the groups view return(RedirectToAction("Groups")); }
public async Task <bool> CreateAsync() { GroupStore <IdentityGroup> store = new GroupStore <IdentityGroup>(); var gm = new GroupManager <IdentityGroup>(store); var newGroup = new IdentityGroup("testgroup"); await gm.CreateAsync(newGroup); return(true); }
public void CreateAsync_GroupIsNull_ReturnZero() { //Arrange using (var a = new GroupManager()) { //Act var result = a.CreateAsync(null); //Assert Assert.That(result, Is.EqualTo(0)); } }
public async Task SeedAsync(DataSeedContext context) { if (await _contactRepository.GetCountAsync() > 0) { return; } //Add group to db if (await _groupRepository.GetCountAsync() <= 0) { var group03 = await _groupRepository.InsertAsync( await _groupManager.CreateAsync( "Group03", "This is group 3" ) ); var group04 = await _groupRepository.InsertAsync( await _groupManager.CreateAsync( "Group04", "This is group 4" ) ); var group01 = await _groupRepository.InsertAsync( await _groupManager.CreateAsync( "Group01", "This is group 1" ) ); var group02 = await _groupRepository.InsertAsync( await _groupManager.CreateAsync( "Group02", "This is group 2" ) ); var group05 = await _groupRepository.InsertAsync( await _groupManager.CreateAsync( "Group05", "This is group 5" ) ); //Add contact to db if (await _contactRepository.GetCountAsync() <= 0) { /*List<ContactGroup> groups1 = new List<ContactGroup>(); * groups1.Add(new ContactGroup() * { * * }); * groups1.Add(group02); * List<Group> groups2 = new List<Group>(); * groups2.Add(group03); * groups2.Add(group02); * List<Group> groups3 = new List<Group>(); * groups3.Add(group04); * List<Group> groups4 = new List<Group>(); * groups3.Add(group05); * groups3.Add(group01);*/ await _contactRepository.InsertAsync( new Contact { //Contact//Groups = groups1, Email = "*****@*****.**", FirstName = "Pham", LastName = "Thinh", DateOfBirth = new DateTime(1999, 5, 21), PhoneNumber = "0905901869", Type = ContactType.Group01 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { ////Groups = groups2, Email = "*****@*****.**", FirstName = "Bich", LastName = "Tram", DateOfBirth = new DateTime(2004, 8, 9), PhoneNumber = "0932443774", Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { ////Groups = groups3, Email = "*****@*****.**", FirstName = "Pham", LastName = "Thinh", DateOfBirth = new DateTime(1999, 5, 21), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { ////Groups = groups4, Email = "*****@*****.**", FirstName = "Hoàng", LastName = "Hiệp", DateOfBirth = new DateTime(1999, 4, 30), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { ////Groups = groups3, Email = "*****@*****.**", FirstName = "Công", LastName = "Văn", DateOfBirth = new DateTime(1999, 4, 27), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { ////Groups = groups1, Email = "*****@*****.**", FirstName = "Tran Công", LastName = "Văn", DateOfBirth = new DateTime(1999, 4, 27), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { ////Groups = groups4, Email = "*****@*****.**", FirstName = "Pham", LastName = "Hưng", DateOfBirth = new DateTime(1998, 1, 27), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { // //Groups = groups2, Email = "*****@*****.**", FirstName = "Vũ", LastName = "Minh", DateOfBirth = new DateTime(1999, 2, 27), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { //Groups = groups1, Email = "*****@*****.**", FirstName = "Minh", LastName = "Hào", DateOfBirth = new DateTime(1999, 3, 20), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { //Groups = groups3, Email = "*****@*****.**", FirstName = "Trí", LastName = "Lâm", DateOfBirth = new DateTime(1999, 5, 30), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { //Groups = groups3, Email = "*****@*****.**", FirstName = "Nhật", LastName = "Anh", DateOfBirth = new DateTime(1999, 5, 30), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { //Groups = groups4, Email = "*****@*****.**", FirstName = "Nguyễn", LastName = "Minh", DateOfBirth = new DateTime(1999, 5, 30), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { //Groups = groups1, Email = "*****@*****.**", FirstName = "Trung", LastName = "Nam", DateOfBirth = new DateTime(1999, 5, 30), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { //Groups = groups2, Email = "*****@*****.**", FirstName = "Việt", LastName = "Long", DateOfBirth = new DateTime(1999, 1, 30), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { //Groups = groups4, Email = "*****@*****.**", FirstName = "Hoàng", LastName = "Hiệp", DateOfBirth = new DateTime(1999, 1, 30), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { //Groups = groups3, Email = "*****@*****.**", FirstName = "Công", LastName = "Huy", DateOfBirth = new DateTime(1999, 1, 25), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { //Groups = groups3, Email = "*****@*****.**", FirstName = "Manh", LastName = "Cường", DateOfBirth = new DateTime(1999, 1, 20), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { //Groups = groups1, Email = "*****@*****.**", FirstName = "Đức", LastName = "Huy", DateOfBirth = new DateTime(1999, 7, 20), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { //Groups = groups3, Email = "*****@*****.**", FirstName = "Anh", LastName = "Khoa", DateOfBirth = new DateTime(1999, 7, 20), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { //Groups = groups3, Email = "*****@*****.**", FirstName = "Thế", LastName = "Duy", DateOfBirth = new DateTime(1999, 7, 20), Type = ContactType.Group02 }, autoSave : true ); await _contactRepository.InsertAsync( new Contact { //Groups = groups2, Email = "*****@*****.**", FirstName = "Bích", LastName = "Trâm", DateOfBirth = new DateTime(2004, 7, 8), Type = ContactType.Group02 }, autoSave : true ); } ; } if (await _campaignRepository.GetCountAsync() <= 0) { await _campaignRepository.InsertAsync( await _campaignManager.CreateAsync( "Campaign01", "This is Campaign 1", new DateTime(2021, 5, 11), "abcxyz", "Title01" ) , autoSave : true ); await _campaignRepository.InsertAsync( await _campaignManager.CreateAsync( "Campaign02", "This is Campaign 2", new DateTime(2021, 05, 10), "abcxyz123", "Title02" ) , autoSave : true ); } if (await _emailRepository.GetCountAsync() <= 0) { var email = await _emailManager.CreateAsync( "*****@*****.**", "thuqua1997", 0 ); await _emailRepository.InsertAsync( email, autoSave : true ); await _emailRepository.InsertAsync( await _emailManager.CreateAsync( "*****@*****.**", "Abc123#!", 0 ), autoSave : true ); await _emailRepository.InsertAsync( await _emailManager.CreateAsync( "*****@*****.**", "Sdc@2021", 0 ), autoSave : true ); } }
public void GenerateSeedData() { #region ENTITIES List <EntityStruct> entities = new List <EntityStruct>(); entities.Add(new EntityStruct("SingleResource", typeof(SingleResource), typeof(BExIS.Rbm.Services.Resource.SingleResourceStore))); entities.Add(new EntityStruct("ResourceStructure", typeof(ResourceStructure), typeof(BExIS.Rbm.Services.ResourceStructure.ResourceStructureStore))); entities.Add(new EntityStruct("ResourceStructureAttribute", typeof(ResourceStructureAttribute), typeof(BExIS.Rbm.Services.ResourceStructure.ResourceStructureAttributeStore))); entities.Add(new EntityStruct("Activity", typeof(Activity), typeof(BExIS.Rbm.Services.Booking.ActivityStore))); entities.Add(new EntityStruct("BookingEvent", typeof(BookingEvent), typeof(BExIS.Rbm.Services.Booking.BookingEventStore))); entities.Add(new EntityStruct("Notification", typeof(Notification), typeof(BExIS.Rbm.Services.Booking.NotificationStore))); entities.Add(new EntityStruct("Schedule", typeof(Schedule), typeof(BExIS.Rbm.Services.Booking.ScheduleStore))); Dictionary <string, Type> rbmEntities = new Dictionary <string, Type>(); rbmEntities.Add("SingleResource", typeof(SingleResource)); rbmEntities.Add("ResourceStructure", typeof(ResourceStructure)); rbmEntities.Add("ResourceStructureAttribute", typeof(ResourceStructureAttribute)); rbmEntities.Add("Activity", typeof(Activity)); rbmEntities.Add("BookingEvent", typeof(BookingEvent)); rbmEntities.Add("Notification", typeof(Notification)); rbmEntities.Add("Schedule", typeof(Schedule)); using (var entityManager = new EntityManager()) { foreach (var et in entities) { Entity entity = entityManager.Entities.Where(e => e.Name.ToUpperInvariant() == et.Name.ToUpperInvariant()).FirstOrDefault(); if (entity == null) { entity = new Entity(); entity.Name = et.Name; entity.EntityType = et.Type; entity.EntityStoreType = et.StoreType; //entity.UseMetadata = true; entity.Securable = true; entityManager.Create(entity); } } } try { ResourceStructureAttribute rsa = new ResourceStructureAttribute(); using (var rsaManager = new ResourceStructureAttributeManager()) rsa = rsaManager.CreateResourceStructureAttribute("Exploratory", "Biodiversity Exploratories funded by DFG Priority Programme 1374. They serve as open research platform for all biodiversity and ecosystem research groups of Germany."); var dcManager = new DataContainerManager(); string[] keys = { "Hainich-Dün", "Schorfheide-Chorin", "Schwäbische Alb" }; List <DomainItem> domainItems = CreateDomainItems(keys); DomainConstraint dc = new DomainConstraint(ConstraintProviderSource.Internal, "", "en-US", "a simple domain validation constraint", false, null, null, null, domainItems); dcManager.AddConstraint(dc, rsa); ResourceStructureAttribute rsa2 = new ResourceStructureAttribute(); using (var rsaManager2 = new ResourceStructureAttributeManager()) rsa2 = rsaManager2.CreateResourceStructureAttribute("Type", "Type of resource."); var dcManager2 = new DataContainerManager(); string[] keys2 = { "Area", "Equipment", "Sleeping place" }; List <DomainItem> domainItems2 = CreateDomainItems(keys2); DomainConstraint dc2 = new DomainConstraint(ConstraintProviderSource.Internal, "", "en-US", "a simple domain validation constraint", false, null, null, null, domainItems2); dcManager2.AddConstraint(dc2, rsa2); ResourceStructureAttribute rsa3 = new ResourceStructureAttribute(); using (var rsaManager3 = new ResourceStructureAttributeManager()) rsa3 = rsaManager3.CreateResourceStructureAttribute("Information File", "Important information as file"); ResourceStructureManager rsManager = new ResourceStructureManager();; ResourceStructure rs = rsManager.Create("Explo resources", "Resources related to exploratories.", null, null); using (var rsaManager = new ResourceStructureAttributeManager()) rsaManager.CreateResourceAttributeUsage(rsa, rs, true, false); using (var rsaManager = new ResourceStructureAttributeManager()) rsaManager.CreateResourceAttributeUsage(rsa2, rs, true, false); using (var rsaManager = new ResourceStructureAttributeManager()) rsaManager.CreateResourceAttributeUsage(rsa3, rs, true, true); ActivityManager aManager = new ActivityManager(); aManager.CreateActivity("Adding of material (litter, dead wood, chemicals ....)", "", false); aManager.CreateActivity("Adding of organisms (seeds and others)", "", false); aManager.CreateActivity("Conference", "", false); aManager.CreateActivity("Contact stakeholder", "", false); aManager.CreateActivity("Dismantling of experiments", "", false); aManager.CreateActivity("Installation of equipment remaining for some time", "", false); aManager.CreateActivity("Measuring and marking of subplots/experiments/study organisms", "", false); aManager.CreateActivity("Observation/capture of organisms without removal", "", false); aManager.CreateActivity("Plot maintenance", "", false); aManager.CreateActivity("Removal of org. material without killing", "", false); aManager.CreateActivity("Removal of organisms", "", false); aManager.CreateActivity("Removal of soil samples", "", false); aManager.CreateActivity("Visit without activity", "", false); ResourceManager rManager = new ResourceManager();; List <newResourceStructure> rs_new = new List <newResourceStructure>(); rs_new.Add(new newResourceStructure() { name = "Forest - all EPs (SCH)", color = "#ec5959", description = "Visit of all forest EPs in Schorfheide-Chorin", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - all MIPs (SCH)", color = "#ec5959", description = "Visit of all forest MIPs in Schorfheide-Chorin", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - all VIPs (SCH)", color = "#ec5959", description = "Visit of all forest VIPs in Schorfheide-Chorin", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Altenhof", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Arnimswalde", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Chorin", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Eichheide", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Glambeck", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Liepe", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Maienpfuhl", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Melzow", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Poratz", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Ringenwalde", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Senftenthal", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Theerofen", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Voigtswiese", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - Forstgut Altkuenkendorf", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - Fuerstliche Forstverwaltung Oettingen-Spielberg", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - Stiftung Schorfheide-Chorin", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - FOX (SCH)", color = "#ec5959", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Grassland - RP/UP (SCH)", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Grassland - ABP Landwirtschaft Neugrimnitz GmbH", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Grassland - AEVG Stegelitz-Flieth", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Grassland - Agrargemeinschaft Greiffenberg GmbH", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Grassland - all EPs (SCH)", color = "#ff0000", description = "Visit of all grassland EPs in Schorfheide-Chorin", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Grassland - all MIPs (SCH)", color = "#ff0000", description = "Visit of all grassland MIPs in Schorfheide-Chorin", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Grassland - all VIPs (SCH)", color = "#ff0000", description = "Visit of all grassland VIPs in Schorfheide-Chorin", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Grassland - Gut Biesenbrow", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Grassland - Ingolf Limber", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Grassland - Lehrschaeferei Friedrichsfelde", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Grassland - LW-Betrieb Haferkamp", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Grassland - Naturrind GmbH Boeckenberg", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Grassland - Reiner Wegner", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Grassland - Weidewirtschaft Liepe", color = "#ff0000", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "no plot visit (SCH)", color = "#e28f8f", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Sleeping place (SCH)", color = "#9c3939", description = "Sleeping places in Schorfheide-Chorin", duration = 1, quantity = 8, withActivity = false, resourceStructure = rs, type = "Sleeping place", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Drying cabinet (SCH)", color = "#940b0b", description = "Drying cabinet in Schorfheide-Chorin", duration = 1, quantity = 5, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Fridge (SCH)", color = "#940b0b", description = "Fridge in Schorfheide-Chorin", duration = 1, quantity = 2, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Freezer (SCH)", color = "#940b0b", description = "Freezer in Schorfheide-Chorin", duration = 1, quantity = 2, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Metal detector (Magna Trak 100) (SCH)", color = "#940b0b", description = "Metal detector (Magna Trak 100) in Schorfheide-Chorin", duration = 1, quantity = 1, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Binocular (SCH)", color = "#940b0b", description = "", duration = 1, quantity = 1, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Chest freezer (SCH)", color = "#940b0b", description = "", duration = 1, quantity = 1, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Helmet (SCH)", color = "#940b0b", description = "", duration = 1, quantity = 8, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schorfheide-Chorin" }); rs_new.Add(new newResourceStructure() { name = "Forest - all EPs (HAI)", color = "#8cca0d", description = "Visit of all forest EPs in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Forest - all GPs (HAI)", color = "#8cca0d", description = "Visit of all forestGPs in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Forest - all MIPs (HAI)", color = "#8cca0d", description = "Visit of all forest MIPs in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Forest - all VIPs (HAI)", color = "#8cca0d", description = "Visit of all forest VIPs in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Forest - FOX (HAI)", color = "8cca0d", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Anrode", color = "#8cca0d", description = "Forest - district Anrode", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Forest - city of Mühlhausen", color = "#8cca0d", description = "Forest - city of Mühlhausen", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Behringen", color = "#8cca0d", description = "Forest - district Behringen", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Geney", color = "#8cca0d", description = "Forest - district Geney", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Keula", color = "#8cca0d", description = "Forest - district Keula", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Langula", color = "#8cca0d", description = "Forest - district Langula", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Sollstedt", color = "#8cca0d", description = "Forest - district Sollstedt", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Zehnsberg", color = "#8cca0d", description = "Forest - district Zehnsberg", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Forest - national park", color = "#8cca0d", description = "Forest - national park", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Forest - national park Weberstedterholz (core zone)", color = "#8cca0d", description = "Forest - national park Weberstedterholz (core zone)", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Forest - district Westerwald", color = "#8cca0d", description = "Forest - district Westerwald", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - all GPs (HAI)", color = "#9acd32", description = "Visit of all grassland GPs in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - all EPs (HAI)", color = "#9acd32", description = "Visit of all grassland EPs in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - all MIPs (HAI)", color = "#9acd32", description = "Visit of all grassland MIPs in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - all VIPs (HAI)", color = "#9acd32", description = "Visit of all grassland VIPs in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - RP/UP (HAI)", color = "9acd32", description = "Visit of all new landuse experiment plots in HAI (HEG1,2,3,6,14,15)", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - AG Diedorf", color = "#9acd32", description = "Grassland - AG Diedorf", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - AG Großenlupnitz", color = "#9acd32", description = "Grassland - AG Großenlupnitz", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - AG Kirchheiligen", color = "#9acd32", description = "Grassland - AG Kirchheiligen", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - AG Bollstedt", color = "#9acd32", description = "Grassland - AG Bollstedt", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - AG Lengefeld", color = "#9acd32", description = "Grassland - AG Lengefeld", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - AG Mülverstedt", color = "#9acd32", description = "Grassland - AG Mülverstedt", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - AG Wartburgblick", color = "#9acd32", description = "Grassland - AG Wartburgblick", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - AG Wenigenlupnitz", color = "#9acd32", description = "Grassland - AG Wenigenlupnitz", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - AG-Struth-Eigenrieden", color = "#9acd32", description = "Grassland - AG-Struth-Eigenrieden", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - BEAG/TOA", color = "#9acd32", description = "Grassland - BEAG/TOA", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - Bundesforst Dörnaerplatz", color = "#9acd32", description = "Grassland - Bundesforst Dörnaerplatz", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - Gut Sambach", color = "#9acd32", description = "Grassland - Gut Sambach", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - Thüringen Wagyu Becker&Becker", color = "#9acd32", description = "Grassland - Thüringen Wagyu Becker&Becker", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - Heller", color = "#9acd32", description = "Grassland - Heller", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - Schaeferei Effenberger", color = "#9acd32", description = "Grassland - Schaeferei Effenberger", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - Nationalpark", color = "#9acd32", description = "Grassland - Nationalpark", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - Nordagrar (Naturrind Unstruttal)", color = "#9acd32", description = "Grassland - Nordagrar (Naturrind Unstruttal)", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - Schaeferei Goepfert", color = "#9acd32", description = "Grassland - Schaeferei Goepfert", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - Börner", color = "#9acd32", description = "Grassland - Börner", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - Strewe-Winterberg", color = "#9acd32", description = "Grassland - Strewe-Winterberg", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Grassland - TUPAG (Hainich Weiderind)", color = "#9acd32", description = "Grassland - TUPAG (Hainich Weiderind)", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "no plot visit", color = "#a9fb00", description = "No plot visit in Hainich-Dün", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Sleeping place (HAI)", color = "#78ab0f", description = "Sleeping place in Hainich-Dün", duration = 1, quantity = 8, withActivity = false, resourceStructure = rs, type = "Sleeping place", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Drying cabinet (HAI)", color = "#6a8a27", description = "Drying cabinete in Hainich-Dün", duration = 1, quantity = 4, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Fridge (HAI)", color = "#6a8a27", description = "Fridge in Hainich-Dün", duration = 1, quantity = 2, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Freezer (HAI)", color = "#6a8a27", description = "Freezer in Hainich-Dün", duration = 1, quantity = 3, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Metal detector (Magna Trak 100) (HAI)", color = "#6a8a27", description = "Metal detector (Magna Trak 100) in Hainich-Dün", duration = 1, quantity = 1, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Metal detector (Garrett ACE 150) (HAI)", color = "#6a8a27", description = "Metal detector (Garrett ACE 150) in Hainich-Dün", duration = 1, quantity = 1, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Hainich-Dün" }); rs_new.Add(new newResourceStructure() { name = "Forest - all EPs (ALB)", color = "#3a75e0", description = "Visit of all forest EPs in Schwäbische Alb", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb" }); rs_new.Add(new newResourceStructure() { name = "Forest - VIP AEW1-8 (ALB)", color = "#3a75e0", description = "Visit of all VIP AEW1-8 in Schwäbische Alb", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb" }); rs_new.Add(new newResourceStructure() { name = "Forest - VIP AEW9 (Alb)", color = "#3a75e0", description = "Visit of all VIP AEW9 in Schwäbische Alb", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb" }); rs_new.Add(new newResourceStructure() { name = "Forest - FOX (ALB)", color = "#3a75e0", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb" }); rs_new.Add(new newResourceStructure() { name = "Grassland - all EPs excluding former military training area", color = "#6495ed", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb" }); rs_new.Add(new newResourceStructure() { name = "Grassland - all EPs including former military training area", color = "#6495ed", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb" }); rs_new.Add(new newResourceStructure() { name = "Grassland - all VIPs (ALB)", color = "#6495ed", description = "Visit of all grassland VIPs in Schwäbische Alb", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb" }); rs_new.Add(new newResourceStructure() { name = "Grassland - RP/UP (ALB)", color = "#6495ed", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb" }); rs_new.Add(new newResourceStructure() { name = "no plot visit (ALB)", color = "#0057f5", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb" }); rs_new.Add(new newResourceStructure() { name = "total Exploratory outside EP", color = "#0057f6", description = "", duration = 1, quantity = 0, withActivity = true, resourceStructure = rs, type = "Area", explo = "Schwäbische Alb" }); rs_new.Add(new newResourceStructure() { name = "Sleeping place (ALB)", color = "#27509a", description = "Sleeping places in Schwäbische Alb", duration = 1, quantity = 8, withActivity = false, resourceStructure = rs, type = "Sleeping place", explo = "Schwäbische Alb" }); rs_new.Add(new newResourceStructure() { name = "Drying cabinet (ALB)", color = "#7e95bf", description = "Drying cabinet in Schwäbische Alb", duration = 1, quantity = 5, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schwäbische Alb" }); rs_new.Add(new newResourceStructure() { name = "Binocular (ALB)", color = "#7e95bf", description = "", duration = 1, quantity = 1, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schwäbische Alb" }); rs_new.Add(new newResourceStructure() { name = "Metal detector (Magna Trak 100) (ALB)", color = "#7e95bf", description = "Metal detector (Magna Trak 100) in Schwäbische Alb", duration = 1, quantity = 1, withActivity = false, resourceStructure = rs, type = "Equipment", explo = "Schwäbische Alb" }); //get/create admin group for entity rights using (var groupManager = new GroupManager()) using (var permissionManager = new EntityPermissionManager()) using (var entityManager = new EntityManager()) using (var valueManager = new ResourceStructureAttributeManager()) { var adminGroup = groupManager.Groups.Where(r => r.Name == "administrator").FirstOrDefault(); if (adminGroup == null) { // create new group adminGroup = new Group { Name = "administrator", Description = "administrator", DisplayName = "administrator", IsSystemGroup = false, IsValid = true }; groupManager.CreateAsync(adminGroup).Wait(); } //create right type int rights = (int)RightType.Read + (int)RightType.Write + (int)RightType.Delete + (int)RightType.Grant; foreach (newResourceStructure rs_item in rs_new) { var duration = new TimeDuration(); duration.Value = rs_item.duration; var resource = rManager.CreateResource(rs_item.name, rs_item.description, rs_item.quantity, rs_item.color, rs_item.withActivity, rs_item.resourceStructure, duration); //add entity rights permissionManager.Create(adminGroup, entityManager.FindByName("SingleResource"), resource.Id, rights ); ResourceAttributeUsage usage = valueManager.GetResourceAttributeUsageById(1); valueManager.CreateResourceAttributeValue(rs_item.explo, rManager.GetResourceById(resource.Id), usage); ResourceAttributeUsage usage2 = valueManager.GetResourceAttributeUsageById(2); valueManager.CreateResourceAttributeValue(rs_item.type, rManager.GetResourceById(resource.Id), usage2); } } } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); } #endregion #region SECURITY OperationManager operationManager = new OperationManager(); FeatureManager featureManager = new FeatureManager(); try { List <Feature> features = featureManager.FeatureRepository.Get().ToList(); Feature ResourceBooking = features.FirstOrDefault(f => f.Name.Equals("Resource Booking")); if (ResourceBooking == null) { ResourceBooking = featureManager.Create("Resource Booking", "Resource Booking"); } Feature NotificationBlackboard = features.FirstOrDefault(f => f.Name.Equals("Notification Blackboard")); if (NotificationBlackboard == null) { NotificationBlackboard = featureManager.Create("Notification Blackboard", "Notification Blackboard", ResourceBooking); } Feature ResourceAdmin = features.FirstOrDefault(f => f.Name.Equals("Resource Administration")); if (ResourceAdmin == null) { ResourceAdmin = featureManager.Create("Resource Administration", "Resource Administration"); } Feature ResourceManagement = features.FirstOrDefault(f => f.Name.Equals("Resource Management")); if (ResourceManagement == null) { ResourceManagement = featureManager.Create("Resource Management", "Resource Management", ResourceAdmin); } Feature ResourceStructureManagement = features.FirstOrDefault(f => f.Name.Equals("Resource Structure Management")); if (ResourceStructureManagement == null) { ResourceStructureManagement = featureManager.Create("Resource Structure Management", "Resource Structure Management", ResourceAdmin); } Feature ResourceStructureAttributeManagement = features.FirstOrDefault(f => f.Name.Equals("Resource Structure Attribute Management")); if (ResourceStructureAttributeManagement == null) { ResourceStructureAttributeManagement = featureManager.Create("Resource Structure Attribute Management", "Resource Structure Attribute Management", ResourceAdmin); } Feature NotificationManagement = features.FirstOrDefault(f => f.Name.Equals("Notification Management")); if (NotificationManagement == null) { NotificationManagement = featureManager.Create("Notification Management", "Notification Management", ResourceAdmin); } Feature ActivityManagement = features.FirstOrDefault(f => f.Name.Equals("Activity Management")); if (ActivityManagement == null) { ActivityManagement = featureManager.Create("Activity Management", "Activity Management", ResourceAdmin); } operationManager.Create("RBM", "Schedule", "*", ResourceBooking); operationManager.Create("RBM", "Calendar", "*", ResourceBooking); operationManager.Create("RBM", " NotificationBlackboard", "*", NotificationBlackboard); operationManager.Create("RBM", "Resource", "*", ResourceManagement); operationManager.Create("RBM", "ResourceStructure", "*", ResourceStructureManagement); operationManager.Create("RBM", "ResourceStructure", "*", ResourceStructureAttributeManagement); operationManager.Create("RBM", "Notification", "*", NotificationManagement); operationManager.Create("RBM", "Activity", "*", ActivityManagement); #region Help Workflow if (!operationManager.Exists("RBM", "help", "*")) { operationManager.Create("RBM", "Help", "*"); } #endregion Help Workflow } catch (Exception ex) { throw ex; } finally { operationManager.Dispose(); featureManager.Dispose(); } #endregion }