private UserStories getUserStoriesByUriOptions(URIOptions uriOptions) { uriOptions.EntityType = "userstories"; Uri uri = uriOptions.BuildUri(); return(ObjectsConverter.GetObjects <UserStories>(this.TPWebServiceClient.GetResponse(uri))); }
public override void createTestFixture() { base.createTestFixture(); ObjectsConverter.Configure(); configureLogging(); clientInformation = new ClientInformation() { Version = Const.ServiceVersion }; clientInformation.ApplicationLanguage = "en"; clientInformation.PlatformVersion = "fgfdgdfg"; clientInformation.ApplicationVersion = "1.0.0.0"; var conf = new ConfigurationSourceBuilder(); conf.ConfigureCaching().ForCacheManagerNamed(SecurityManager.AuthenticationCacheName).StoreInMemory(); var configSource = new DictionaryConfigurationSource(); conf.UpdateConfigurationWithReplace(configSource); var xmlStream = DateTimeExtension.GetResource("BodyArchitect.UnitTests.V2.BAPointsTests.BAPoints.xml"); var paymentsManager = new PaymentsManager(); this.paymentsManager = paymentsManager.Load(xmlStream); InternalBodyArchitectService.PaymentsManager = this.paymentsManager; EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(configSource); }
public void Setup() { ObjectsConverter.Configure(); ExercisesBuilderPL exercisesBuilder = new ExercisesBuilderPL(); exercises = exercisesBuilder.Create().ToDictionary(t => t.GlobalId); }
private Bugs getBugsByUriOptions(URIOptions uriOptions) { uriOptions.EntityType = "bugs"; Uri uri = uriOptions.BuildUri(); return(ObjectsConverter.GetObjects <Bugs>(this.TPWebServiceClient.GetResponse(uri))); }
public async Task Delete(string typeIdentifier, [FromBody] object obj) { var type = schemaRegistry.GetTypeByTypeIdentifier(typeIdentifier); var schema = schemaRegistry.GetSchemaByTypeIdentifier(typeIdentifier); var typeInfo = TypeInfoExtractor.Extract(type, schema.PropertyDescriptionBuilder, schema.CustomPropertyConfigurationProvider); var x = ObjectsConverter.ApiToStored(typeInfo, type, obj, schema.CustomPropertyConfigurationProvider); await schemaRegistry.GetConnector(typeIdentifier).Delete(x).ConfigureAwait(false); }
public Task DeleteObject([NotNull] string objectIdentifier, [NotNull][FromBody] object obj) { var type = schemaRegistry.GetTypeByTypeIdentifier(objectIdentifier); var schema = schemaRegistry.GetSchemaByTypeIdentifier(objectIdentifier); var typeInfo = TypeInfoExtractor.Extract(type, schema.PropertyDescriptionBuilder, schema.CustomPropertyConfigurationProvider); var x = ObjectsConverter.ApiToStored(typeInfo, type, obj, schema.CustomPropertyConfigurationProvider); return(schemaRegistry.GetConnector(objectIdentifier).Delete(x)); }
public async Task <object> UpdateObject([NotNull] string objectIdentifier, [NotNull][FromBody] object obj) { var type = schemaRegistry.GetTypeByTypeIdentifier(objectIdentifier); var schema = schemaRegistry.GetSchemaByTypeIdentifier(objectIdentifier); var typeInfo = TypeInfoExtractor.Extract(obj, type, schema.PropertyDescriptionBuilder, schema.CustomPropertyConfigurationProvider); var stored = ObjectsConverter.ApiToStored(typeInfo, type, obj, schema.CustomPropertyConfigurationProvider); var newObject = await schemaRegistry.GetConnector(objectIdentifier).Write(stored).ConfigureAwait(false); return(ObjectsConverter.StoredToApi(typeInfo, type, newObject, schema.CustomPropertyConfigurationProvider)); }
public async Task <ObjectDetailsModel> Read(string typeIdentifier, [FromBody] ReadModel filters) { var type = schemaRegistry.GetTypeByTypeIdentifier(typeIdentifier); var schema = schemaRegistry.GetSchemaByTypeIdentifier(typeIdentifier); var result = await schemaRegistry.GetConnector(typeIdentifier).Read(filters.Filters).ConfigureAwait(false); var typeInfo = TypeInfoExtractor.Extract(result, type, schema.PropertyDescriptionBuilder, schema.CustomPropertyConfigurationProvider); var obj = ObjectsConverter.StoredToApi(typeInfo, type, result, schema.CustomPropertyConfigurationProvider); return(new ObjectDetailsModel { Object = obj, TypeInfo = typeInfo, }); }
public async Task <ObjectDetails> ReadObject(string objectIdentifier, ObjectReadRequest query) { var type = schemaRegistry.GetTypeByTypeIdentifier(objectIdentifier); var schema = schemaRegistry.GetSchemaByTypeIdentifier(objectIdentifier); var result = await schemaRegistry.GetConnector(objectIdentifier).Read(query.Conditions).ConfigureAwait(false); var typeMeta = PropertyHelpers.BuildTypeMetaInformation(result, type, type, schema.PropertyDescriptionBuilder, schema.CustomPropertyConfigurationProvider); var obj = ObjectsConverter.StoredToApiDeep(result, schema.CustomPropertyConfigurationProvider); return(new ObjectDetails { Object = obj, Meta = new ObjectDescription { Identifier = objectIdentifier, SchemaDescription = schema.Description, TypeMetaInformation = typeMeta, } }); }
public async Task <SearchResult <object> > SearchObjects([NotNull] string objectIdentifier, [NotNull][FromBody] ObjectSearchRequest query) { var type = schemaRegistry.GetTypeByTypeIdentifier(objectIdentifier); var schema = schemaRegistry.GetSchemaByTypeIdentifier(objectIdentifier); var countLimit = schema.Description.CountLimit; var connector = schemaRegistry.GetConnector(objectIdentifier); var counts = await connector.Count(query.GetFilters(), countLimit + 1).ConfigureAwait(false); var results = await connector.Search(query.GetFilters(), query.GetSorts(), query.Offset ?? 0, query.Count ?? 20).ConfigureAwait(false); var typeInfo = TypeInfoExtractor.Extract(type, schema.PropertyDescriptionBuilder, schema.CustomPropertyConfigurationProvider); var objects = results.Select(x => ObjectsConverter.StoredToApi(typeInfo, type, x, schema.CustomPropertyConfigurationProvider)).ToArray(); return(new SearchResult <object> { Count = counts ?? objects.Length, CountLimit = countLimit, Items = objects, }); }
public async Task <ObjectDetails> ReadObject([NotNull] string objectIdentifier, [NotNull][FromBody] ObjectSearchRequest query) { var type = schemaRegistry.GetTypeByTypeIdentifier(objectIdentifier); var schema = schemaRegistry.GetSchemaByTypeIdentifier(objectIdentifier); var typeMeta = PropertyHelpers.BuildTypeMetaInformation(type, schema.PropertyDescriptionBuilder, schema.CustomPropertyConfigurationProvider); var result = await schemaRegistry.GetConnector(objectIdentifier).Read(query.GetFilters()).ConfigureAwait(false); var typeInfo = TypeInfoExtractor.Extract(result, type, schema.PropertyDescriptionBuilder, schema.CustomPropertyConfigurationProvider); var obj = ObjectsConverter.StoredToApi(typeInfo, type, result, schema.CustomPropertyConfigurationProvider); return(new ObjectDetails { Object = obj, Meta = new ObjectDescription { Identifier = objectIdentifier, SchemaDescription = schema.Description, TypeMetaInformation = typeMeta, } }); }
public override void createTestFixture() { base.createTestFixture(); ObjectsConverter.Configure(); configureLogging(); clientInformation = new ClientInformation() { Version = Const.ServiceVersion }; clientInformation.ApplicationLanguage = "en"; clientInformation.PlatformVersion = "fgfdgdfg"; clientInformation.ApplicationVersion = "1.0.0.0"; var conf = new ConfigurationSourceBuilder(); conf.ConfigureCaching().ForCacheManagerNamed(SecurityManager.AuthenticationCacheName).StoreInMemory(); var configSource = new DictionaryConfigurationSource(); conf.UpdateConfigurationWithReplace(configSource); EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(configSource); }
public async Task <SearchResult> SearchObjects(string objectIdentifier, ObjectSearchRequest query, bool isSuperUser) { var type = schemaRegistry.GetTypeByTypeIdentifier(objectIdentifier); var schema = schemaRegistry.GetSchemaByTypeIdentifier(objectIdentifier); if (!schema.Description.AllowReadAll && !query.Conditions.Any()) { throw new InvalidOperationException($"Reading without filters is not allowed for {objectIdentifier}"); } if (!schema.Description.AllowSort && query.Sorts.Any()) { throw new InvalidOperationException($"Sorting is not allowed for {objectIdentifier}"); } var offset = query.Offset ?? 0; var count = query.Count ?? 20; var countLimit = isSuperUser ? schema.Description.CountLimitForSuperUser : schema.Description.CountLimit; if (offset + count > countLimit) { throw new InvalidOperationException($"Expected offset ({offset}) + count ({count}) to be less than countLimit ({countLimit})"); } var connector = schemaRegistry.GetConnector(objectIdentifier); var counts = await connector.Count(query.Conditions, countLimit + 1).ConfigureAwait(false); var results = counts == null ? await connector.Search(query.Conditions, query.Sorts, 0, countLimit + 1).ConfigureAwait(false) : await connector.Search(query.Conditions, query.Sorts, offset, count).ConfigureAwait(false); var objects = results.Select(x => ObjectsConverter.StoredToApi(type, x, schema.CustomPropertyConfigurationProvider)).ToArray(); return(new SearchResult { Count = counts, CountLimit = countLimit, Items = objects, }); }
public override void BuildDatabase() { ObjectsConverter.Configure(); using (var tx = Session.BeginTransaction()) { profiles.Clear(); workoutPlans.Clear(); exercises.Clear(); TestService_GetExercises.BuildTwoProfilesDatabase(Session, profiles, exercises); profiles[0].Statistics.StrengthTrainingEntriesCount = 40; //remove all favorites items profiles[0].FavoriteWorkoutPlans.Clear(); Session.Update(profiles[0]); profiles[1].FavoriteWorkoutPlans.Clear(); Session.Update(profiles[1]); Profile profile1 = profiles[0]; Profile profile2 = profiles[1]; //creates workout plans for profile 1 var workoutPlan = createPlan(profile1, "test1-1", PublishStatus.Published, TrainingPlanDifficult.Beginner, TrainingType.HST); workoutPlans.Add(workoutPlan.Name, workoutPlan); workoutPlan = createPlan(profile1, "test1-2", PublishStatus.Private, TrainingPlanDifficult.Advanced, TrainingType.HST, exercises["t11"], exercises["t12"], exercises["t01"]); workoutPlans.Add(workoutPlan.Name, workoutPlan); workoutPlan = createPlan(profile1, "test1-3", PublishStatus.Published, TrainingPlanDifficult.Beginner, TrainingType.PushPull); workoutPlans.Add(workoutPlan.Name, workoutPlan); workoutPlan = createPlan(profile1, "test1-4", PublishStatus.Private, TrainingPlanDifficult.NotSet, TrainingType.Split, exercises["t01"], exercises["t12"], exercises["t22"]); workoutPlans.Add(workoutPlan.Name, workoutPlan); workoutPlan = createPlan(profile1, "test1-5", PublishStatus.Private, TrainingPlanDifficult.Beginner, TrainingType.FBW); workoutPlans.Add(workoutPlan.Name, workoutPlan); workoutPlan = createPlan(profile1, "test1-6", PublishStatus.Published, TrainingPlanDifficult.Professional, TrainingType.Split); workoutPlans.Add(workoutPlan.Name, workoutPlan); workoutPlan = createPlan(profile1, "test1-7", PublishStatus.Published, TrainingPlanDifficult.Beginner, TrainingType.ACT); workoutPlans.Add(workoutPlan.Name, workoutPlan); //now for profile 2 workoutPlan = createPlan(profile2, "test2-1", PublishStatus.Private, TrainingPlanDifficult.Advanced, TrainingType.HST); workoutPlans.Add(workoutPlan.Name, workoutPlan); workoutPlan = createPlan(profile2, "test2-2", PublishStatus.Published, TrainingPlanDifficult.Professional, TrainingType.ACT); workoutPlans.Add(workoutPlan.Name, workoutPlan); workoutPlan = createPlan(profile2, "test2-3", PublishStatus.Published, TrainingPlanDifficult.Beginner, TrainingType.PushPull); workoutPlans.Add(workoutPlan.Name, workoutPlan); workoutPlan = createPlan(profile2, "test2-4", PublishStatus.Published, TrainingPlanDifficult.NotSet, TrainingType.HIT); workoutPlans.Add(workoutPlan.Name, workoutPlan); workoutPlan = createPlan(profile2, "test2-5", PublishStatus.Private, TrainingPlanDifficult.Beginner, TrainingType.Split); workoutPlans.Add(workoutPlan.Name, workoutPlan); workoutPlan = createPlan(profile2, "test2-6", PublishStatus.Private, TrainingPlanDifficult.Advanced, TrainingType.ACT); workoutPlans.Add(workoutPlan.Name, workoutPlan); workoutPlan = createPlan(profile2, "test2-7", PublishStatus.Published, TrainingPlanDifficult.NotSet, TrainingType.FBW); workoutPlans.Add(workoutPlan.Name, workoutPlan); workoutPlan = createPlan(profile2, "test2-8", PublishStatus.Private, TrainingPlanDifficult.Beginner, TrainingType.Split); workoutPlans.Add(workoutPlan.Name, workoutPlan); ////add favorities for profile 1 //profile1.FavoriteWorkoutPlans.Add(workoutPlans["test2-2"]); //Session.SaveOrUpdate(profile1); ////and for profile 2 //profile2.FavoriteWorkoutPlans.Add(workoutPlans["test1-1"]); //profile2.FavoriteWorkoutPlans.Add(workoutPlans["test1-6"]); //Session.SaveOrUpdate(profile2); tx.Commit(); } }
private Users getUsersByUriOption(Uri uri) { return(ObjectsConverter.GetObjects <Users>(this.TPWebServiceClient.GetResponse(uri))); }
static AdminService() { ObjectsConverter.Configure(); }
public void Setup() { ObjectsConverter.Configure(); }
public FriendInvitationDTO InviteFriendOperation(InviteFriendOperationData data) { Log.WriteWarning("InviteFriendOperation:Username={0},Operation:{1},User:{2}", SecurityInfo.SessionData.Profile.UserName, data.Operation, data.User.UserName); if (SecurityInfo.SessionData.Profile.GlobalId == data.User.GlobalId) { throw new InvalidOperationException("You cannot add yourself as a friend"); } var session = Session; FriendInvitation returnValue = null; using (var tx = session.BeginSaveTransaction()) { var friendProfile = session.Get <Profile>(data.User.GlobalId); var inviter = session.Get <Profile>(SecurityInfo.SessionData.Profile.GlobalId); if (friendProfile.IsDeleted) { throw new UserDeletedException("Cannot invite a deleted profile"); } if (data.Operation == Model.InviteFriendOperation.Invite) { if (inviter.Friends.Contains(friendProfile)) { throw new ProfileAlreadyFriendException("Specified profile is already a friend"); } //check if user add invitation second time var existingInvitation = session.Get <FriendInvitation>(new FriendInvitation() { Inviter = inviter, Invited = friendProfile }); if (existingInvitation == null) { Log.WriteVerbose("1: existingInvitation == null"); existingInvitation = session.Get <FriendInvitation>(new FriendInvitation() { Inviter = friendProfile, Invited = inviter }); if (existingInvitation == null) { Log.WriteVerbose("2: existingInvitation == null. Perform invite operation"); FriendInvitation invitation = new FriendInvitation(); invitation.Inviter = inviter; invitation.Invited = friendProfile; invitation.Message = data.Message; invitation.CreateDate = Configuration.TimerService.UtcNow; invitation.InvitationType = FriendInvitationType.Invite; session.Save(invitation); returnValue = invitation; if ((friendProfile.Settings.NotificationSocial & ProfileNotification.Email) == ProfileNotification.Email) { EmailService.SendEMail(friendProfile, "InviteFriendEMailSubject", "InviteFriendEMailMessage", inviter.UserName, DateTime.Now, data.Message); } } else { acceptInvitation(session, friendProfile, inviter, existingInvitation, data); } } } else if (data.Operation == Model.InviteFriendOperation.Accept) { var existingInvitation = session.Get <FriendInvitation>(new FriendInvitation() { Inviter = friendProfile, Invited = inviter }); if (existingInvitation != null) { acceptInvitation(session, friendProfile, inviter, existingInvitation, data); } else { throw new CannotAcceptRejectInvitationDoesntExistException("You are not invited to be a friend for specified user"); } } else {//reject var existingInvitation = session.Get <FriendInvitation>(new FriendInvitation() { Inviter = friendProfile, Invited = inviter }); if (existingInvitation != null) { Log.WriteVerbose("3: existingInvitation != null."); if (existingInvitation.InvitationType == FriendInvitationType.Invite) { session.Delete(existingInvitation); //messageService.SendSystemMessage(data.Message, inviter, friendProfile, MessageType.InvitationRejected); //SendMessage(friendProfile.Settings.NotificationSocial, inviter, friendProfile, data.Message, MessageType.InvitationRejected //, "RejectInvitationEmailSubject", "RejectInvitationEmailMessage", inviter.UserName, DateTime.Now, data.Message); NewSendMessageEx(inviter.Settings.NotificationSocial, inviter, friendProfile, "RejectInvitationEmailSubject", "RejectInvitationEmailMessage", inviter.UserName, DateTime.Now, data.Message); } else { Log.WriteError("4:This should not be invoked."); } } else if (inviter.Friends.Contains(friendProfile)) { Log.WriteVerbose("Reject friendship"); inviter.Friends.Remove(friendProfile); friendProfile.Friends.Remove(inviter); ProfileStatisticsUpdater.UpdateFriends(session, inviter, friendProfile); //SendMessage(friendProfile.Settings.NotificationSocial, inviter, friendProfile, data.Message, MessageType.FriendshipRejected // , "RejectFriendshipEmailSubject", "RejectFriendshipEmailMessage", inviter.UserName, DateTime.Now, data.Message); NewSendMessageEx(inviter.Settings.NotificationSocial, inviter, friendProfile, "RejectFriendshipEmailSubject", "RejectFriendshipEmailMessage", inviter.UserName, DateTime.Now, data.Message); //messageService.SendSystemMessage(data.Message, inviter, friendProfile, MessageType.FriendshipRejected); } else { existingInvitation = session.Get <FriendInvitation>(new FriendInvitation() { Inviter = inviter, Invited = friendProfile }); //user whats to cancel invitation if (existingInvitation != null) { Log.WriteVerbose("Reject invitation"); session.Delete(existingInvitation); } else { throw new CannotAcceptRejectInvitationDoesntExistException("There is no invitation to reject"); } } } tx.Commit(); Log.WriteVerbose("Operation completed"); if (returnValue != null) { return(ObjectsConverter.ConvertFriendInvitation(inviter, returnValue)); } return(null); } }