public void SupplementCycleDefinition_SendEMail() { var sup = CreateSupplement("sup"); var def = CreateSupplementsCycleDefinition("def", sup, profiles[0]); var profile1 = (ProfileDTO)profiles[1].Tag; profiles[0].Settings.NotificationVoted = ProfileNotification.Email; insertToDatabase(profiles[0]); SessionData data = CreateNewSession(profile1, ClientInformation); var dto = def.Map <SupplementCycleDefinitionDTO>(); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.SupplementCycleDefinition; param.GlobalId = dto.GlobalId; param.UserRating = 3; param.UserShortComment = "test"; service.Vote(data.Token, param); Assert.IsTrue(((MockEmailService)service.EMailService).EMailSent); }); var count = Session.QueryOver <Message>().RowCount(); Assert.AreEqual(0, count); }
public void SupplementCycleDefinition_RatingUpdate_Twice() { var sup = CreateSupplement("sup"); var def = CreateSupplementsCycleDefinition("def", sup, profiles[0]); var profile = (ProfileDTO)profiles[0].Tag; var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation); var dto = def.Map <SupplementCycleDefinitionDTO>(); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.SupplementCycleDefinition; param.GlobalId = dto.GlobalId; param.UserRating = 3; param.UserShortComment = "test"; dto.Rating = service.Vote(data.Token, param).Rating; }); data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.SupplementCycleDefinition; param.GlobalId = dto.GlobalId; param.UserRating = 1; param.UserShortComment = "test"; dto.Rating = service.Vote(data.Token, param).Rating; }); Assert.AreEqual(2, dto.Rating); }
public void SupplementCycleDefinition_DisabledSendMessage() { var sup = CreateSupplement("sup"); var def = CreateSupplementsCycleDefinition("def", sup, profiles[0]); profiles[0].Settings.NotificationVoted = ProfileNotification.None; insertToDatabase(profiles[0]); var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation); var dto = def.Map <SupplementCycleDefinitionDTO>(); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.SupplementCycleDefinition; param.GlobalId = dto.GlobalId; param.UserRating = 3; param.UserShortComment = "test"; service.Vote(data.Token, param); Assert.IsFalse(((MockEmailService)service.EMailService).EMailSent); }); var messages = Session.QueryOver <Message>().Where(x => x.Receiver == profiles[0]).SingleOrDefault(); Assert.IsNull(messages); }
public void Exercise_RatingUpdateTwice() { var profile = (ProfileDTO)profiles[0].Tag; var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation); ExerciseDTO dto = Mapper.Map <Exercise, ExerciseDTO>(exercises["t"]); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.Exercise; param.GlobalId = dto.GlobalId; param.UserRating = 3; param.UserShortComment = "test"; dto.Rating = service.Vote(data.Token, param).Rating; }); data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.Exercise; param.GlobalId = dto.GlobalId; param.UserRating = 1; param.UserShortComment = "test"; dto.Rating = service.Vote(data.Token, param).Rating; }); Assert.AreEqual(2, dto.Rating); }
public void WorkoutPlan_RatingUpdate_Twice() { var profile = (ProfileDTO)profiles[0].Tag; var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation); var dto = (Service.V2.Model.TrainingPlans.TrainingPlan)workoutPlans["test1-1"].Tag; RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.WorkoutPlan; param.GlobalId = dto.GlobalId; param.UserRating = 3; param.UserShortComment = "test"; dto.Rating = service.Vote(data.Token, param).Rating; }); data = CreateNewSession(profile, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.WorkoutPlan; param.GlobalId = dto.GlobalId; param.UserRating = 1; param.UserShortComment = "test"; dto.Rating = service.Vote(data.Token, param).Rating; }); Assert.AreEqual(2, dto.Rating); }
//public WorkoutPlanDTO VoteWorkoutPlan(Token token, WorkoutPlanDTO planDto) //{ // var securityInfo = SecurityManager.EnsureAuthentication(token); // VoteService service = new VoteService(Session, securityInfo, Configuration, PushNotificationService); // return service.VoteWorkoutPlan(planDto); //} //public ExerciseDTO VoteExercise(Token token, ExerciseDTO exercise) //{ // var securityInfo = SecurityManager.EnsureAuthentication(token); // VoteService service = new VoteService(Session, securityInfo, Configuration, PushNotificationService); // return service.VoteExercise(exercise); //} //public SuplementDTO VoteSupplement(Token token, SuplementDTO supplement) //{ // var securityInfo = SecurityManager.EnsureAuthentication(token); // VoteService service = new VoteService(Session, securityInfo, Configuration, PushNotificationService); // return service.VoteSupplement(supplement); //} public VoteResult Vote(Token token, VoteParams param) { var securityInfo = SecurityManager.EnsureAuthentication(token); VoteService service = new VoteService(Session, securityInfo, Configuration, PushNotificationService, EMailService); return(service.Vote(param)); }
//public WorkoutPlanDTO VoteWorkoutPlan( WorkoutPlanDTO planDto) //{ // Log.WriteWarning("VoteWorkoutPlan: Username={0},planId={1}", SecurityInfo.SessionData.Profile.UserName, planDto.GlobalId); // var session = Session; // using (var tx = session.BeginTransaction()) // { // var dbProfile = session.Load<Profile>(SecurityInfo.SessionData.Profile.Id); // var planFromDb = (from p in session.Query<BodyArchitect.Model.TrainingPlan>() // where p.GlobalId == planDto.GlobalId // select p).SingleOrDefault(); // saveRating(SecurityInfo, planDto, dbProfile, planFromDb); // tx.Commit(); // try // { // //send message only when someone else vote // if (planFromDb.Profile != dbProfile) // { // if (planFromDb.Profile.Settings.NotificationWorkoutPlanVoted) // { // string param = string.Format("{0},{1},{2},{3}", planFromDb.Name, dbProfile.UserName, DateTime.Now, planDto.UserRating); // MessageService messageService = new MessageService(Session, SecurityInfo, Configuration, pushNotification); // messageService.SendSystemMessage(param, dbProfile, planFromDb.Profile, BodyArchitect.Model.MessageType.WorkoutPlanVoted); // } // } // } // catch (Exception ex) // { // ExceptionHandler.Default.Process(ex); // } // session.Refresh(planFromDb); // Mapper.Map<BodyArchitect.Model.TrainingPlan, WorkoutPlanDTO>(planFromDb, planDto); // return planDto; // } //} //public ExerciseDTO VoteExercise( ExerciseDTO exercise) //{ // Log.WriteWarning("VoteExercise: Username={0},planId={1}", SecurityInfo.SessionData.Profile.UserName, exercise.GlobalId); // var session = Session; // using (var tx = session.BeginTransaction()) // { // var dbProfile = session.Load<Profile>(SecurityInfo.SessionData.Profile.Id); // var planFromDb = (from p in session.Query<BodyArchitect.Model.Exercise>() // where p.GlobalId == exercise.GlobalId // select p).SingleOrDefault(); // saveRating(SecurityInfo, exercise, dbProfile, planFromDb); // tx.Commit(); // try // { // //send message only when someone else vote // if (planFromDb.Profile != null && planFromDb.Profile != dbProfile) // { // if (planFromDb.Profile.Settings.NotificationExerciseVoted) // { // string param = string.Format("{0},{1},{2},{3}", planFromDb.Name, dbProfile.UserName, DateTime.Now, exercise.UserRating); // MessageService messageService = new MessageService(Session, SecurityInfo, Configuration, pushNotification); // messageService.SendSystemMessage(param, dbProfile, planFromDb.Profile, BodyArchitect.Model.MessageType.ExerciseVoted); // } // } // } // catch (Exception ex) // { // ExceptionHandler.Default.Process(ex); // } // session.Refresh(planFromDb); // Mapper.Map<BodyArchitect.Model.Exercise, ExerciseDTO>(planFromDb, exercise); // return exercise; // } //} float saveRating(SecurityInfo SecurityInfo, VoteParams ratingable, Profile profile, BodyArchitect.Model.IRatingable globalObject) { var session = Session; if (ratingable.UserRating != null)// && (ratingObject == null || ratingObject != null && ratingObject.Rating != ratingable.UserRating.Value)) { var ratingObject = (from rating in session.Query <RatingUserValue>() where rating.ProfileId == profile.GlobalId && rating.RatedObjectId == globalObject.GlobalId select rating).SingleOrDefault(); if (ratingObject == null) { ratingObject = new RatingUserValue(); ratingObject.ProfileId = profile.GlobalId; ratingObject.RatedObjectId = globalObject.GlobalId; } ratingObject.LoginData = SecurityInfo.LoginData; ratingObject.Rating = ratingable.UserRating.Value; ratingObject.ShortComment = ratingable.UserShortComment; ratingObject.VotedDate = Configuration.TimerService.UtcNow; session.SaveOrUpdate(ratingObject); ProfileStatisticsUpdater.UpdateVotings(session, profile); //session.SaveOrUpdate(globalObject); //var res = (from t in session.Query<RatingUserValue>() where t.RatedObjectId == globalObject.GlobalId select t).Average(t => t.Rating); var res = session.QueryOver <RatingUserValue>().Where(t => t.RatedObjectId == globalObject.GlobalId). SelectList(t => t.SelectAvg(r => r.Rating)).SingleOrDefault <double>(); globalObject.Rating = (float)res; session.SaveOrUpdate(globalObject); return((float)res); } return(globalObject.Rating); }
public VoteResult Vote(VoteParams voteParams) { Log.WriteWarning("Vote: Username={0},globalId={1},type={2}", SecurityInfo.SessionData.Profile.UserName, voteParams.GlobalId, voteParams.ObjectType); var session = Session; using (var tx = session.BeginSaveTransaction()) { var dbProfile = session.Load <Profile>(SecurityInfo.SessionData.Profile.GlobalId); bool sendMessage = false; ISortable planFromDb = null; if (voteParams.ObjectType == VoteObject.SupplementCycleDefinition) { planFromDb = session.Get <SupplementCycleDefinition>(voteParams.GlobalId); sendMessage = true; } else if (voteParams.ObjectType == VoteObject.Exercise) { planFromDb = session.Get <Exercise>(voteParams.GlobalId); sendMessage = true; } else if (voteParams.ObjectType == VoteObject.WorkoutPlan) { planFromDb = session.Get <TrainingPlan>(voteParams.GlobalId); sendMessage = true; } else if (voteParams.ObjectType == VoteObject.Supplement) { planFromDb = session.Get <Suplement>(voteParams.GlobalId); } ProfileNotification notificationType = planFromDb.Profile != null ? planFromDb.Profile.Settings.NotificationVoted : ProfileNotification.None; VoteResult result = new VoteResult(); result.Rating = saveRating(SecurityInfo, voteParams, dbProfile, planFromDb); try { //send message only when someone else vote if (planFromDb.Profile != null && planFromDb.Profile != dbProfile && sendMessage) { //SendMessage(notificationType, dbProfile, planFromDb.Profile, messageFormat, messageTypeToSend.Value, "VoteEMailSubject", "VoteEMailMessage", DateTime.Now, dbProfile.UserName, planFromDb.Name, voteParams.UserRating); NewSendMessageEx(notificationType, dbProfile, planFromDb.Profile, "VoteEMailSubject", "VoteEMailMessage", DateTime.Now, dbProfile.UserName, planFromDb.Name, voteParams.UserRating); } } catch (Exception ex) { ExceptionHandler.Default.Process(ex); } tx.Commit(); return(result); } }
private void voteOnWorkoutPlan(VoteObject objType) { var m = new ServiceManager <VoteCompletedEventArgs>( delegate(BodyArchitectAccessServiceClient client1, EventHandler <VoteCompletedEventArgs> operationCompleted) { VoteParams param = new VoteParams(); param.GlobalId = Item.GlobalId; param.UserRating = Item.UserRating; param.UserShortComment = Item.UserShortComment; param.ObjectType = objType; client1.VoteCompleted -= operationCompleted; client1.VoteCompleted += operationCompleted; //client1.VoteAsync(ApplicationState.Current.SessionData.Token, (WorkoutPlanDTO)Item); client1.VoteAsync(ApplicationState.Current.SessionData.Token, param); }); m.OperationCompleted += (s, a) => { progressBar.ShowProgress(false); if (a.Error != null) { BAMessageBox.ShowError(ApplicationStrings.VotingPage_ErrSendRating); } else { saved = true; Item.Rating = a.Result.Result.Rating; if (NavigationService.CanGoBack) { NavigationService.GoBack(); } } }; if (!m.Run()) { progressBar.ShowProgress(false); if (ApplicationState.Current.IsOffline) { BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode); } else { BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork); } } }
public void TestVotePlan_Statistics() { var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.WorkoutPlan; param.GlobalId = workoutPlans["test1-1"].GlobalId; param.UserRating = 3; param.UserShortComment = "test"; service.Vote(data.Token, param); }); var dbProfile = Session.Get <Profile>(profile1.GlobalId); Assert.AreEqual(1, dbProfile.Statistics.VotingsCount); }
public void TestVoteExercise_Global_DontSendMessage() { //var profile = (ProfileDTO)profiles[0].Tag; var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.Exercise; param.GlobalId = exercises["global"].GlobalId; param.UserRating = 3; param.UserShortComment = "test"; service.Vote(data.Token, param); }); var count = Session.QueryOver <Message>().RowCount(); Assert.AreEqual(0, count); }
public void SupplementCycleDefinitionUpdateRating_SetLoginData() { var sup = CreateSupplement("sup"); var def = CreateSupplementsCycleDefinition("def", sup, profiles[0]); var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation, null, apiKey); var loginData = Session.QueryOver <LoginData>().SingleOrDefault(); var dto = def.Map <SupplementCycleDefinitionDTO>(); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.SupplementCycleDefinition; param.GlobalId = dto.GlobalId; param.UserRating = 3; param.UserShortComment = "test"; dto.Rating = service.Vote(data.Token, param).Rating; }); var key = new APIKey(); key.ApiKey = Guid.NewGuid(); key.ApplicationName = "UnitTest1"; key.EMail = "*****@*****.**"; key.RegisterDateTime = DateTime.UtcNow; insertToDatabase(key); data = CreateNewSession(profile1, ClientInformation, null, key); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.SupplementCycleDefinition; param.GlobalId = dto.GlobalId; param.UserRating = 1; param.UserShortComment = "test"; dto.Rating = service.Vote(data.Token, param).Rating; }); var rating = Session.QueryOver <RatingUserValue>().SingleOrDefault(); Assert.AreEqual(key.ApiKey, rating.LoginData.ApiKey.ApiKey); }
public void TestVoteSupplementsCycleDefinition_Statistics() { var sup = CreateSupplement("sup"); var def = CreateSupplementsCycleDefinition("def", sup, profiles[1]); var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.SupplementCycleDefinition; param.GlobalId = def.GlobalId; param.UserRating = 3; param.UserShortComment = "test"; service.Vote(data.Token, param); }); var dbProfile = Session.Get <Profile>(profile1.GlobalId); Assert.AreEqual(1, dbProfile.Statistics.VotingsCount); }
public void Supplement_RatingUpdate() { var sup = CreateSupplement("sup", false, false, profiles[0]); //var profile = (ProfileDTO)profiles[0].Tag; var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation); var dto = sup.Map <SuplementDTO>(); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.Supplement; param.GlobalId = dto.GlobalId; param.UserRating = 3; param.UserShortComment = "test"; dto.Rating = service.Vote(data.Token, param).Rating; }); Assert.AreEqual(3, dto.Rating); }
public void WorkoutPlanUpdateRating_SetLoginData() { //var profile = (ProfileDTO)profiles[0].Tag; var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation, null, apiKey); var loginData = Session.QueryOver <LoginData>().SingleOrDefault(); var dto = (Service.V2.Model.TrainingPlans.TrainingPlan)workoutPlans["test1-1"].Tag; RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.WorkoutPlan; param.GlobalId = dto.GlobalId; param.UserRating = 3; param.UserShortComment = "test"; dto.Rating = service.Vote(data.Token, param).Rating; }); var key = new APIKey(); key.ApiKey = Guid.NewGuid(); key.ApplicationName = "UnitTest1"; key.EMail = "*****@*****.**"; key.RegisterDateTime = DateTime.UtcNow; insertToDatabase(key); data = CreateNewSession(profile1, ClientInformation, null, key); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.WorkoutPlan; param.GlobalId = dto.GlobalId; param.UserRating = 1; param.UserShortComment = "test"; dto.Rating = service.Vote(data.Token, param).Rating; }); var rating = Session.QueryOver <RatingUserValue>().SingleOrDefault(); Assert.AreEqual(key.ApiKey, rating.LoginData.ApiKey.ApiKey); }
private void btnRateIt_Click(object sender, RoutedEventArgs e) { VoteParams param = new VoteParams(); param.UserRating = ratingable.UserRating = (float?)rbUserRating.RatingValue; param.UserShortComment = ratingable.UserShortComment = txtShortComment.Text; param.GlobalId = ratingable.GlobalId; ParentWindow.RunAsynchronousOperation(delegate { if (ratingable is TrainingPlan) { param.ObjectType = VoteObject.WorkoutPlan; } else if (ratingable is ExerciseDTO) { param.ObjectType = VoteObject.Exercise; } else if (ratingable is SuplementDTO) { param.ObjectType = VoteObject.Supplement; } else if (ratingable is SupplementCycleDefinitionDTO) { param.ObjectType = VoteObject.SupplementCycleDefinition; } else { #if DEBUG throw new NotImplementedException(); #else return; #endif } ratingable.Rating = ServiceManager.Vote(param).Rating; UIHelper.BeginInvoke(delegate { rbGlobalRating.RatingValue = ratingable.Rating; RaiseEvent(new VoteEventArgs(VotedEvent, this, ratingable)); }, Dispatcher); }, asyncOperationStateChange); }
public void Exercise_SetLoginData() { //var profile = (ProfileDTO)profiles[0].Tag; var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation, null, apiKey); var loginData = Session.QueryOver <LoginData>().SingleOrDefault(); ExerciseDTO dto = Mapper.Map <Exercise, ExerciseDTO>(exercises["t"]); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.Exercise; param.GlobalId = dto.GlobalId; param.UserRating = 3; param.UserShortComment = "test"; dto.Rating = service.Vote(data.Token, param).Rating; }); var rating = Session.QueryOver <RatingUserValue>().SingleOrDefault(); Assert.AreEqual(loginData.ApiKey.ApiKey, rating.LoginData.ApiKey.ApiKey); }
public void WorkoutPlan_SetLoginData() { //var profile = (ProfileDTO)profiles[0].Tag; var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation, null, apiKey); var loginData = Session.QueryOver <LoginData>().SingleOrDefault(); var dto = (Service.V2.Model.TrainingPlans.TrainingPlan)workoutPlans["test1-1"].Tag; RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.WorkoutPlan; param.GlobalId = dto.GlobalId; param.UserRating = 3; param.UserShortComment = "test"; dto.Rating = service.Vote(data.Token, param).Rating; }); var rating = Session.QueryOver <RatingUserValue>().SingleOrDefault(); Assert.AreEqual(loginData.ApiKey.ApiKey, rating.LoginData.ApiKey.ApiKey); }
public void TestVotePlan_SendMessage() { //var profile = (ProfileDTO)profiles[0].Tag; var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.WorkoutPlan; param.GlobalId = workoutPlans["test1-1"].GlobalId; param.UserRating = 3; param.UserShortComment = "test"; service.Vote(data.Token, param); Assert.IsFalse(((MockEmailService)service.EMailService).EMailSent); }); var messages = Session.QueryOver <Message>().Where(x => x.Receiver == profiles[0]).SingleOrDefault(); Assert.IsNotNull(messages); Assert.IsNotNull(messages.Content); Assert.AreEqual(MessagePriority.System, messages.Priority); }
public void TestVotePlan_SendEMail() { profiles[0].Settings.NotificationVoted = ProfileNotification.Email; insertToDatabase(profiles[0]); var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.WorkoutPlan; param.GlobalId = workoutPlans["test1-1"].GlobalId; param.UserRating = 3; param.UserShortComment = "test"; service.Vote(data.Token, param); Assert.IsTrue(((MockEmailService)service.EMailService).EMailSent); }); var count = Session.QueryOver <Message>().RowCount(); Assert.AreEqual(0, count); }
public void TestVotePlan_DisabledSendMessage() { profiles[0].Settings.NotificationVoted = ProfileNotification.None; insertToDatabase(profiles[0]); var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.WorkoutPlan; param.GlobalId = workoutPlans["test1-1"].GlobalId; param.UserRating = 3; param.UserShortComment = "test"; service.Vote(data.Token, param); Assert.IsFalse(((MockEmailService)service.EMailService).EMailSent); }); var messages = Session.QueryOver <Message>().Where(x => x.Receiver == profiles[0]).SingleOrDefault(); Assert.IsNull(messages); }
public void SupplementCycleDefinition_SetLoginData() { var sup = CreateSupplement("sup"); var def = CreateSupplementsCycleDefinition("def", sup, profiles[0]); var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation, null, apiKey); var loginData = Session.QueryOver <LoginData>().SingleOrDefault(); var dto = def.Map <SupplementCycleDefinitionDTO>(); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.SupplementCycleDefinition; param.GlobalId = dto.GlobalId; param.UserRating = 3; param.UserShortComment = "test"; dto.Rating = service.Vote(data.Token, param).Rating; }); var rating = Session.QueryOver <RatingUserValue>().SingleOrDefault(); Assert.AreEqual(loginData.ApiKey.ApiKey, rating.LoginData.ApiKey.ApiKey); }
public void SendMessage_NonActiveAccount() { profiles[0].Statistics.LastLoginDate = DateTime.UtcNow.AddMonths(-2); insertToDatabase(profiles[0].Statistics); var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation); var prevCount = Session.QueryOver <Message>().RowCount(); ExerciseDTO dto = Mapper.Map <Exercise, ExerciseDTO>(exercises["t"]); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.Exercise; param.GlobalId = dto.GlobalId; param.UserRating = 3; param.UserShortComment = "test"; dto.Rating = service.Vote(data.Token, param).Rating; }); var newCount = Session.QueryOver <Message>().RowCount(); Assert.AreEqual(prevCount, newCount); }
public void TestVoteExercise_SendMessageAndEMail() { profiles[0].Settings.NotificationVoted = ProfileNotification.Message | ProfileNotification.Email; insertToDatabase(profiles[0]); var profile1 = (ProfileDTO)profiles[1].Tag; SessionData data = CreateNewSession(profile1, ClientInformation); RunServiceMethod(delegate(InternalBodyArchitectService service) { VoteParams param = new VoteParams(); param.ObjectType = VoteObject.Exercise; param.GlobalId = exercises["t"].GlobalId; param.UserRating = 3; param.UserShortComment = "test"; service.Vote(data.Token, param); Assert.IsTrue(((MockEmailService)service.EMailService).EMailSent); }); var messages = Session.QueryOver <Message>().Where(x => x.Receiver == profiles[0]).SingleOrDefault(); Assert.IsNotNull(messages); Assert.IsNotNull(messages.Content); Assert.AreEqual(MessagePriority.System, messages.Priority); }
public VoteResult Vote(Token token, VoteParams param) { return(exceptionHandling(token, () => InternalService.Vote(token, param))); }