private void startA6WTraining(MyTrainingOperationParam param, A6WTraining dbCycle, Profile dbProfile)
 {
     for (int i = 0; i < A6WManager.Days.Count; i++)
     {
         createEntryObject(param.MyTraining, i, dbProfile, dbCycle, () =>
         {
             var entry       = new A6WEntry();
             entry.DayNumber = i + 1;
             return(new [] { entry });
         });
     }
 }
        public void A6WEntries_TrainingNotFullyFinish()
        {
            var        profile       = CreateProfile("profile");
            MyTraining endedTraining = new MyTraining();

            endedTraining.EndDate             = DateTime.UtcNow.AddDays(-1).Date;
            endedTraining.StartDate           = DateTime.UtcNow.AddDays(-3).Date;
            endedTraining.TrainingEnd         = TrainingEnd.Break;
            endedTraining.Name                = "TempName";
            endedTraining.PercentageCompleted = null;
            endedTraining.Profile             = profile;
            insertToOldDatabase(endedTraining);

            var day1 = new TrainingDay(DateTime.UtcNow.AddDays(-10));

            day1.Comment = "cmt";
            day1.Profile = profile;
            var a6w1 = new A6WEntry();

            a6w1.Comment    = "test";
            a6w1.Completed  = true;
            a6w1.MyTraining = endedTraining;
            a6w1.DayNumber  = 1;
            day1.AddEntry(a6w1);
            insertToOldDatabase(day1);

            var day2 = new TrainingDay(DateTime.UtcNow.AddDays(-10));

            day2.Comment = "cmt";
            day2.Profile = profile;
            var a6w2 = new A6WEntry();

            a6w2.Comment    = "test";
            a6w2.MyTraining = endedTraining;
            a6w2.Completed  = false;
            a6w2.DayNumber  = 2;
            a6w2.Set1       = 2;
            a6w2.Set2       = 3;
            day2.AddEntry(a6w2);
            insertToOldDatabase(day2);

            Convert();

            var dbProfile = SessionNew.QueryOver <Model.Profile>().Where(x => x.UserName == profile.UserName).SingleOrDefault();
            var count     = SessionNew.QueryOver <Model.A6WEntry>().RowCount();

            Assert.AreEqual(count, dbProfile.Statistics.A6WEntriesCount);
        }
        private void importA6w(TrainingDay day, Profile profile, int oldTrainingDayId, SqlCeConnection oldConnection)
        {
            Log.WriteInfo("Importing a6w for trainingdate={0},oldTrainingDayId={1}", day.TrainingDate, oldTrainingDayId);
            SqlCeCommand cmd = new SqlCeCommand();

            cmd.Connection = oldConnection;

            cmd.CommandText = "SELECT SpecificEntryObject_id,Completed,DayNumber,Set1,Set2,Set3,MyTraining_Id FROM A6WEntry,EntryObject e WHERE e.Id=SpecificEntryObject_id AND e.TrainingDay_ID=" + oldTrainingDayId;
            var reader = cmd.ExecuteReader();

            Log.WriteInfo("A6W reader executed");


            while (reader.Read())
            {
                int strengthTrainingId = getInt32(reader, "SpecificEntryObject_id").Value;
                Log.WriteInfo("Importing A6W id={0}", strengthTrainingId);
                A6WEntry entry = new A6WEntry();

                entry.Set1      = getInt32(reader, "Set1");
                entry.Set2      = getInt32(reader, "Set2");
                entry.Set3      = getInt32(reader, "Set3");
                entry.DayNumber = getInt32(reader, "DayNumber").Value;
                entry.Completed = getBoolean(reader, "Completed").Value;
                var myTrainingId = getGuid(reader, "MyTraining_id").Value;
                entry.MyTraining = importMyTraining(myTrainingId, profile, oldConnection);

                string       entryObjectSelect  = "SELECT Id,Comment,Name,ReportStatus FROM EntryObject WHERE Id=" + strengthTrainingId;
                SqlCeCommand entryObjectCommand = new SqlCeCommand(entryObjectSelect, oldConnection);
                var          entryObjectReader  = entryObjectCommand.ExecuteReader();
                entryObjectReader.Read();
                entry.Comment      = getString(entryObjectReader, "Comment");
                entry.Name         = getString(entryObjectReader, "Name");
                entry.ReportStatus = (ReportStatus)getInt32(entryObjectReader, "ReportStatus").Value;
                entryObjectReader.Close();
                day.AddEntry(entry);
            }
            reader.Close();
            Log.WriteInfo("A6W import complete");
        }
Exemple #4
0
        public void TestDeleteTrainingDay_Mode_OnlyWithoutMyTraining_TrainingDayShouldNotBeDeleted_OneEntryShouldBeDeletedOnly()
        {
            var         profile = (ProfileDTO)profiles[0].Tag;
            SessionData data    = CreateNewSession(profile, ClientInformation);
            DateTime    date    = DateTime.Now.AddDays(-2);
            var         day     = new TrainingDay(date);

            day.Profile = profiles[0];
            SizeEntry size = new SizeEntry();

            size.Wymiary = new Wymiary();
            MyTraining training = new A6WTraining();

            training.Name    = "test";
            training.Profile = day.Profile;
            size.MyTraining  = training;
            day.AddEntry(size);
            A6WEntry a6w = new A6WEntry();

            a6w.DayNumber = 1;
            day.AddEntry(a6w);
            insertToDatabase(day);


            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                var param           = new DeleteTrainingDayParam();
                param.TrainingDayId = day.GlobalId;
                param.Mode          = DeleteTrainingDayMode.OnlyWithoutMyTraining;
                Service.DeleteTrainingDay(data.Token, param);
            });

            Assert.AreEqual(1, Session.QueryOver <TrainingDay>().RowCount());
            Assert.AreEqual(1, Session.QueryOver <SizeEntry>().RowCount());
            Assert.AreEqual(0, Session.QueryOver <A6WEntry>().RowCount());
        }
        public override void BuildDatabase()
        {
            using (var tx = Session.BeginTransaction())
            {
                profiles.Clear();
                profiles.Add(CreateProfile(Session, "test1"));
                profiles.Add(CreateProfile(Session, "test2"));
                profiles.Add(CreateProfile(Session, "test3"));
                profiles.Add(CreateProfile(Session, "test4"));

                profiles[0].Wymiary     = new Wymiary();
                profiles[0].Wymiary.Pas = 102;

                Session.SaveOrUpdate(profiles[0]);



                TrainingDay day = new TrainingDay(DateTime.Now);
                day.Profile = profiles[0];
                StrengthTrainingEntry strengthEntry = new StrengthTrainingEntry();
                StrengthTrainingItem  item          = new StrengthTrainingItem();
                strengthEntry.AddEntry(item);
                item.ExerciseId = Guid.NewGuid();
                Serie serie = new Serie("10x20");
                item.AddSerie(serie);
                day.AddEntry(strengthEntry);
                SizeEntry sizeEntry = new SizeEntry();
                sizeEntry.Wymiary        = new Wymiary();
                sizeEntry.Wymiary.Height = 100;
                day.AddEntry(sizeEntry);
                SuplementsEntry suplementsEntry = new SuplementsEntry();
                SuplementItem   suplementItem   = new SuplementItem();
                suplementItem.SuplementId = Guid.NewGuid();
                suplementItem.Name        = "fdgdfg";
                suplementsEntry.AddItem(suplementItem);
                day.AddEntry(suplementsEntry);
                BlogEntry blogEntry = new BlogEntry();
                day.AddEntry(blogEntry);
                A6WEntry a6WEntry = new A6WEntry();
                a6WEntry.DayNumber          = 1;
                a6WEntry.MyTraining         = new MyTraining();
                a6WEntry.MyTraining.Name    = "fdgdfg";
                a6WEntry.MyTraining.TypeId  = A6WEntry.EntryTypeId;
                a6WEntry.MyTraining.Profile = profiles[0];
                day.AddEntry(a6WEntry);
                Session.Save(day);

                BlogComment comment = new BlogComment();
                comment.BlogEntry = blogEntry;
                comment.Profile   = profiles[1];
                comment.Comment   = "fgdfgd";
                Session.Save(comment);
                comment           = new BlogComment();
                comment.BlogEntry = blogEntry;
                comment.Comment   = "fgdfgd";
                comment.Profile   = profiles[0];
                Session.Save(comment);

                Session.Update(blogEntry);

                Exercise exercise = new Exercise(Guid.NewGuid());
                exercise.Profile  = profiles[0];
                exercise.Name     = "Private";
                exercise.Shortcut = "PP";
                Session.Save(exercise);

                exercise             = new Exercise(Guid.NewGuid());
                exercise.Profile     = profiles[0];
                exercise.Name        = "Public";
                exercise.Shortcut    = "PP";
                exercise.Status      = PublishStatus.Published;
                exercise.PublishDate = DateTime.UtcNow;
                Session.Save(exercise);

                RatingUserValue exComment = new RatingUserValue();
                exComment.ProfileId     = profiles[1].Id;
                exComment.ShortComment  = "dffgdfgdf";
                exComment.Rating        = 2;
                exComment.RatedObjectId = exercise.GlobalId;
                Session.Save(exComment);

                exercise             = new Exercise(Guid.NewGuid());
                exercise.Profile     = profiles[1];
                exercise.Name        = "Public1";
                exercise.Shortcut    = "PP1";
                exercise.Status      = PublishStatus.Published;
                exercise.PublishDate = DateTime.UtcNow;
                Session.Save(exercise);

                exComment               = new RatingUserValue();
                exComment.ProfileId     = profiles[0].Id;
                exComment.ShortComment  = "dffgdfgdf";
                exComment.Rating        = 2;
                exComment.RatedObjectId = exercise.GlobalId;
                Session.Save(exComment);

                TrainingPlan plan = new TrainingPlan();
                plan.Profile     = profiles[0];
                plan.GlobalId    = Guid.NewGuid();
                plan.Language    = "pl";
                plan.Author      = "dfgdfg";
                plan.Name        = "dfgdfg";
                plan.PlanContent = "fgdgdfg";
                Session.Save(plan);

                plan             = new TrainingPlan();
                plan.Profile     = profiles[0];
                plan.Language    = "pl";
                plan.GlobalId    = Guid.NewGuid();
                plan.Author      = "dfgdfg";
                plan.Status      = PublishStatus.Published;
                plan.PublishDate = DateTime.UtcNow;
                plan.Name        = "dfgdfg";
                plan.PlanContent = "fgdgdfg";
                Session.Save(plan);

                exComment               = new RatingUserValue();
                exComment.ProfileId     = profiles[1].Id;
                exComment.ShortComment  = "dffgdfgdf";
                exComment.Rating        = 2;
                exComment.RatedObjectId = plan.GlobalId;
                Session.Save(exComment);

                plan             = new TrainingPlan();
                plan.Profile     = profiles[1];
                plan.Language    = "pl";
                plan.GlobalId    = Guid.NewGuid();
                plan.Author      = "dfgdfg";
                plan.Status      = PublishStatus.Published;
                plan.PublishDate = DateTime.UtcNow;
                plan.Name        = "dfgdfg";
                plan.PlanContent = "fgdgdfg";
                Session.Save(plan);

                exComment               = new RatingUserValue();
                exComment.ProfileId     = profiles[0].Id;
                exComment.ShortComment  = "dffgdfgdf";
                exComment.Rating        = 2;
                exComment.RatedObjectId = plan.GlobalId;
                Session.Save(plan);


                exComment               = new RatingUserValue();
                exComment.ProfileId     = profiles[1].Id;
                exComment.ShortComment  = "dffgdfgdf";
                exComment.Rating        = 2;
                exComment.RatedObjectId = plan.GlobalId;
                Session.Save(exComment);

                exComment               = new RatingUserValue();
                exComment.ProfileId     = profiles[0].Id;
                exComment.ShortComment  = "dffgdfgdf";
                exComment.Rating        = 2;
                exComment.RatedObjectId = plan.GlobalId;
                Session.Save(plan);

                Message msg = new Message();
                msg.Receiver = profiles[0];
                msg.Sender   = profiles[1];
                msg.Topic    = "dfgdfgdf";
                Session.Save(msg);
                msg          = new Message();
                msg.Receiver = profiles[1];
                msg.Sender   = profiles[0];
                msg.Topic    = "dfgdfgdf";
                Session.Save(msg);

                FriendInvitation invitation = new FriendInvitation();
                invitation.Invited    = profiles[0];
                invitation.Inviter    = profiles[2];
                invitation.CreateDate = DateTime.UtcNow;
                Session.Save(invitation);

                invitation            = new FriendInvitation();
                invitation.Invited    = profiles[3];
                invitation.Inviter    = profiles[0];
                invitation.CreateDate = DateTime.UtcNow;
                Session.Save(invitation);

                profiles[0].Friends.Add(profiles[1]);
                profiles[1].Friends.Add(profiles[0]);
                profiles[1].Statistics.FriendsCount = 1;

                profiles[0].FavoriteUsers.Add(profiles[1]);
                profiles[1].Statistics.FollowersCount = 1;
                profiles[0].FavoriteWorkoutPlans.Add(plan);

                profiles[2].FavoriteUsers.Add(profiles[0]);
                Session.Update(profiles[0]);
                Session.Update(profiles[1]);
                Session.Update(profiles[2]);
                tx.Commit();
            }
        }