示例#1
0
        public void AddTwoComments()
        {
            var            profile  = (ProfileDTO)profiles[0].Tag;
            var            profile1 = (ProfileDTO)profiles[1].Tag;
            SessionData    data     = CreateNewSession(profile, ClientInformation);
            TrainingDayDTO day      = new TrainingDayDTO(DateTime.Now);

            day.ProfileId = profile.GlobalId;

            BlogEntryDTO blogEntry = new BlogEntryDTO();

            blogEntry.Comment = "jakis tekst";
            day.AllowComments = true;
            day.AddEntry(blogEntry);

            SaveTrainingDayResult result = null;

            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                result = Service.SaveTrainingDay(data.Token, day);
                day    = result.TrainingDay;
            });


            TrainingDayCommentDTO comment = new TrainingDayCommentDTO();

            comment.Profile = profile;
            comment.Comment = "msg";
            DateTime time = DateTime.UtcNow;

            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                TimerService.UtcNow = time;
                TrainingDayCommentOperationParam arg = new TrainingDayCommentOperationParam();
                arg.TrainingDayId = day.GlobalId;
                arg.Comment       = comment;
                arg.OperationType = TrainingDayOperationType.Add;
                Service.TrainingDayCommentOperation(data.Token, arg);
            });
            data            = CreateNewSession(profile1, ClientInformation);
            comment         = new TrainingDayCommentDTO();
            comment.Profile = profile1;
            comment.Comment = "msg1";
            time            = DateTime.UtcNow.AddHours(2);
            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                TimerService.UtcNow = time;
                TrainingDayCommentOperationParam arg = new TrainingDayCommentOperationParam();
                arg.TrainingDayId = day.GlobalId;
                arg.Comment       = comment;
                arg.OperationType = TrainingDayOperationType.Add;
                Service.TrainingDayCommentOperation(data.Token, arg);
            });

            var dbDay = Session.QueryOver <TrainingDay>().SingleOrDefault();

            Assert.IsNotNull(dbDay);
            Assert.AreEqual(2, dbDay.CommentsCount);
            Assert.IsTrue(dbDay.LastCommentDate.Value.CompareDateTime(time));
        }
示例#2
0
        public void TestGetTrainingDay_Last_FriendsOnly()
        {
            setPrivacy(Privacy.FriendsOnly);

            var profile1 = (ProfileDTO)profiles[1].Tag;
            var profile2 = (ProfileDTO)profiles[2].Tag;

            WorkoutDayGetOperation op = new WorkoutDayGetOperation();

            op.Operation       = GetOperation.Last;
            op.UserId          = profiles[0].GlobalId;
            op.WorkoutDateTime = trainingDays[2].TrainingDate;
            TrainingDayDTO day  = null;
            SessionData    data = CreateNewSession(profile1, ClientInformation);

            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                day = Service.GetTrainingDay(data.Token, op, new RetrievingInfo());
            });
            Assert.AreEqual(trainingDays[trainingDays.Count - 1].TrainingDate, day.TrainingDate);

            data = CreateNewSession(profile2, ClientInformation);
            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                day = Service.GetTrainingDay(data.Token, op, new RetrievingInfo());
            });
            Assert.IsNull(day);
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            //fillToday();
            buildApplicationBar();
            StateHelper stateHelper = new StateHelper(this.State);

            SelectedDate = stateHelper.GetValue("SelectedDate", SelectedDate);
            dayCtrl.Fill(SelectedDate);
            pivot.Title = SelectedDate.ToLongDateString();

            if (ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays.ContainsKey(SelectedDate))
            {
                var info = ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays[SelectedDate];

                viewModel      = new TrainingDayViewModel(info.TrainingDay);
                SelectedDayDTO = info.TrainingDay;
                viewModel.BlogCommentsLoaded += (s, a) =>
                {
                    progressBar.ShowProgress(false);
                    updateApplicationBarButtons();
                };
            }
            else
            {
                viewModel = new TrainingDayViewModel(null);
            }

            viewModel.Restore(State);
            DataContext = viewModel;
        }
示例#4
0
        //public static Boolean IsDirtyEntity(ISession session, Object entity,Object oldEntity)
        //{

        //    String className = NHibernateProxyHelper.GuessClass(entity).FullName;

        //    ISessionImplementor sessionImpl = session.GetSessionImplementation();

        //    IPersistenceContext persistenceContext = sessionImpl.PersistenceContext;

        //    IEntityPersister persister = sessionImpl.Factory.GetEntityPersister(className);

        //    EntityEntry oldEntry = sessionImpl.PersistenceContext.GetEntry(oldEntity);


        //    if ((oldEntry == null) && (entity is INHibernateProxy))
        //    {

        //        INHibernateProxy proxy = entity as INHibernateProxy;

        //        Object obj = sessionImpl.PersistenceContext.Unproxy(proxy);

        //        oldEntry = sessionImpl.PersistenceContext.GetEntry(obj);

        //    }



        //    Object[] oldState = oldEntry.LoadedState;

        //    Object[] currentState = persister.GetPropertyValues(entity, sessionImpl.EntityMode);

        //    Int32[] dirtyProps = persister.FindDirty(currentState, oldState, entity, sessionImpl);


        //    return (dirtyProps != null);

        //}

        public SaveTrainingDayResult SaveTrainingDay(Token token, TrainingDayDTO day)
        {
            var securityInfo           = SecurityManager.EnsureAuthentication(token);
            TrainingDayService service = new TrainingDayService(Session, securityInfo, Configuration, PushNotificationService, EMailService);

            return(service.SaveTrainingDay(day));
        }
示例#5
0
        public static TrainingDayPageContext CreateTrainingDayWindow(TrainingDayDTO day, UserDTO user, CustomerDTO customer, IEntryObjectBuilderProvider builder = null)
        {
            if (day.GlobalId == Constants.UnsavedGlobalId)
            {
                day.AllowComments = UserContext.Current.ProfileInformation.Settings.AllowTrainingDayComments;
                //set default entries for newly created TrainingDay
                var options = UserContext.Current.Settings.GuiState.CalendarOptions;
                foreach (var defaultEntry in options.DefaultEntries)
                {
                    if (defaultEntry.IsDefault == true)
                    {
                        var plugin = PluginsManager.Instance.GetEntryObjectProvider(defaultEntry.ModuleId);
                        if (plugin != null && plugin.EntryObjectType.CanBeManuallyAdded())
                        {
                            var entry = day.AddEntry(plugin.EntryObjectType);
                            if (builder != null)
                            {
                                builder.EntryObjectCreated(entry);
                            }
                            if (day.TrainingDate.IsFuture())
                            {//for entries in future set planned status
                                entry.Status = EntryObjectStatus.Planned;
                            }
                        }
                    }
                }
                //needed for SizeEntryDTO for example
                day.ChangeDate(day.TrainingDate);
            }
            TrainingDayPageContext context = new TrainingDayPageContext(user, customer, day, builder);

            return(context);
        }
示例#6
0
        public ImageItem[] GetDayContents(TrainingDayDTO day)
        {
            List <ImageItem> items = new List <ImageItem>();

            foreach (var gpsEntry in day.Objects.OfType <GPSTrackerEntryDTO>())
            {
                StringBuilder builder = new StringBuilder();
                builder.AppendLine(gpsEntry.Exercise.Name);
                if (gpsEntry.Distance.HasValue)
                {//
                    builder.AppendFormat(GPSStrings.GPSTrackerCalendarDayContent_Distance, gpsEntry.Distance.Value.ToDisplayDistance(), UIHelper.DistanceType);
                }
                if (gpsEntry.Duration.HasValue)
                {
                    builder.AppendFormat(GPSStrings.GPSTrackerCalendarDayContent_Duration, gpsEntry.Duration.Value.ToDisplayDuration());
                }
                ImageItem item = new ImageItem();
                item.BackBrush = EntryObjectColors.GPSTracker;
                item.Content   = builder.ToString();
                item.Entry     = gpsEntry;
                item.ToolTip   = Name;
                item.Image     = Image;
                items.Add(item);
            }
            return(items.ToArray());
        }
示例#7
0
        public void PrepareTrainingDay()
        {
            if (ApplicationState.Current.CurrentBrowsingTrainingDays.IsMine)
            {
                ApplicationState.Current.TimerStartTime = null;
                if (!ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays.ContainsKey(currentDate))
                {
                    var day = new TrainingDayDTO();
                    day.TrainingDate = currentDate;
                    day.ProfileId    = ApplicationState.Current.SessionData.Profile.GlobalId;
                    if (ApplicationState.Current.CurrentViewCustomer != null)
                    {
                        day.CustomerId = ApplicationState.Current.CurrentViewCustomer.GlobalId;
                    }
                    ApplicationState.Current.TrainingDay = new TrainingDayInfo(day);
                    return;
                }
            }

            if (ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays.ContainsKey(currentDate))
            {
                ApplicationState.Current.TrainingDay = ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays[currentDate].Copy();
            }
            else
            {
                BAMessageBox.ShowError("Nie powinien tutaj wejsc. PrepareTrainingDay");
            }
            return;
        }
示例#8
0
        public void TwoEntries_SameType_OneIsNew()
        {
            TrainingDayDTO daySource = new TrainingDayDTO();

            daySource.InstanceId = Guid.NewGuid();
            daySource.GlobalId   = Guid.NewGuid();
            SizeEntryDTO size = new SizeEntryDTO();

            size.ReservationId = Guid.NewGuid();//for testing purposes
            size.InstanceId    = Guid.NewGuid();
            size.GlobalId      = Guid.NewGuid();
            daySource.Objects.Add(size);
            size.TrainingDay = daySource;
            SizeEntryDTO tracker = new SizeEntryDTO();

            tracker.InstanceId    = Guid.NewGuid();
            tracker.ReservationId = Guid.NewGuid();//for testing purposes
            daySource.Objects.Add(tracker);
            tracker.TrainingDay = daySource;

            var dayCopy = daySource.Copy();

            dayCopy.Objects[1].GlobalId   = Guid.NewGuid();
            dayCopy.InstanceId            = Guid.Empty;
            dayCopy.Objects[0].InstanceId = Guid.Empty;
            dayCopy.Objects[1].InstanceId = Guid.Empty;

            dayCopy.FillInstaneId(daySource);

            Assert.AreEqual(daySource.InstanceId, dayCopy.InstanceId);
            Assert.AreEqual(size.ReservationId, dayCopy.Objects.Where(x => x.InstanceId == size.InstanceId).SingleOrDefault().ReservationId);
            Assert.AreEqual(tracker.ReservationId, dayCopy.Objects.Where(x => x.InstanceId == tracker.InstanceId).SingleOrDefault().ReservationId);
        }
示例#9
0
 public static TrainingDayDTO SaveTrainingDay(TrainingDayDTO day)
 {
     return(exceptionHandling(delegate
     {
         return Instance.SaveTrainingDay(Token, day);
     }));
 }
示例#10
0
        public ImageItem[] GetDayContents(TrainingDayDTO day)
        {
            List <ImageItem> items = new List <ImageItem>();

            foreach (var supple in day.Objects.OfType <SuplementsEntryDTO>())
            {
                StringBuilder builder = new StringBuilder();

                foreach (var suppleItem in supple.Items)
                {
                    string name = suppleItem.Suplement.Name;
                    if (!string.IsNullOrEmpty(suppleItem.Name))
                    {
                        name = suppleItem.Name;
                    }
                    builder.AppendLine(string.Format("{0}: {1} {2}", name, suppleItem.Dosage.ToString("0.##"), EnumLocalizer.Default.Translate(suppleItem.DosageType)));
                }
                ImageItem item = new ImageItem();
                item.BackBrush = EntryObjectColors.Supplements;
                item.Content   = builder.ToString();
                item.Entry     = supple;
                item.ToolTip   = Name;
                item.Image     = Image;
                items.Add(item);
            }
            return(items.ToArray());
        }
示例#11
0
 public static void DeleteTrainingDay(TrainingDayDTO day)
 {
     exceptionHandling(delegate
     {
         Instance.DeleteTrainingDay(Token, day);
     });
 }
        public ImageItem[] GetDayContents(TrainingDayDTO day)
        {
            List <ImageItem> items = new List <ImageItem>();

            foreach (var size in day.Objects.OfType <SizeEntryDTO>())
            {
                string weightUnitType = UIHelper.WeightType;
                string lengthUnitType = UIHelper.LengthType;

                StringBuilder builder = new StringBuilder();
                if (size.Wymiary != null)
                {
                    addLine(size.Wymiary.RightBiceps.ToDisplayLength(), "usrWymiaryEditor_RightBicepsLabel".TranslateGUI(), builder, lengthUnitType);
                    addLine(size.Wymiary.LeftBiceps.ToDisplayLength(), "usrWymiaryEditor_LeftBicepsLabel".TranslateGUI(), builder, lengthUnitType);
                    addLine(size.Wymiary.Klatka.ToDisplayLength(), "usrWymiaryEditor_KlatkaLabel".TranslateGUI(), builder, lengthUnitType);
                    addLine(size.Wymiary.RightForearm.ToDisplayLength(), "usrWymiaryEditor_RightForearmLabel".TranslateGUI(), builder, lengthUnitType);
                    addLine(size.Wymiary.LeftForearm.ToDisplayLength(), "usrWymiaryEditor_LeftForearmsLabel".TranslateGUI(), builder, lengthUnitType);
                    addLine(size.Wymiary.RightUdo.ToDisplayLength(), "usrWymiaryEditor_RightUdoLabel".TranslateGUI(), builder, lengthUnitType);
                    addLine(size.Wymiary.LeftUdo.ToDisplayLength(), "usrWymiaryEditor_LeftUdoLabel".TranslateGUI(), builder, lengthUnitType);
                    addLine(size.Wymiary.Pas.ToDisplayLength(), "usrWymiaryEditor_PasLabel".TranslateGUI(), builder, lengthUnitType);
                    addLine(size.Wymiary.Weight.ToDisplayWeight(), "usrWymiaryEditor_WeightLabel".TranslateGUI(), builder, weightUnitType);
                }
                ImageItem item = new ImageItem();
                item.BackBrush = EntryObjectColors.Measurements;
                item.Content   = builder.ToString();
                item.Entry     = size;
                item.ToolTip   = Name;
                item.Image     = Image;
                items.Add(item);
            }
            return(items.ToArray());
        }
        public void ForCustomer_SaveTrainingDay_UpdateSize_TwoTimes_SecondInThePast()
        {
            var            profile = (ProfileDTO)profiles[0].Tag;
            SessionData    data    = CreateNewSession(profile, ClientInformation);
            TrainingDayDTO day     = new TrainingDayDTO(DateTime.Now.AddDays(-1));

            day.ProfileId  = profile.GlobalId;
            day.CustomerId = customers[0].GlobalId;
            SizeEntryDTO entry = new SizeEntryDTO();

            entry.Wymiary        = new WymiaryDTO();
            entry.Wymiary.Height = 100;
            day.AddEntry(entry);
            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                service.SaveTrainingDay(data.Token, day);
            });

            day                  = new TrainingDayDTO(DateTime.Now.AddDays(-2));
            day.ProfileId        = profile.GlobalId;
            day.CustomerId       = customers[0].GlobalId;
            entry                = new SizeEntryDTO();
            entry.Wymiary        = new WymiaryDTO();
            entry.Wymiary.Height = 50;
            day.AddEntry(entry);
            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                service.SaveTrainingDay(data.Token, day);
            });
            var dbCustomer = Session.Get <Customer>(customers[0].GlobalId);

            Assert.AreEqual(100, dbCustomer.Wymiary.Height);
        }
示例#14
0
        public void TestSplitByType_EmptyList_ExtensionMethod()
        {
            TrainingDayDTO day    = new TrainingDayDTO(DateTime.Now);
            var            groups = day.SplitByType(true);

            Assert.AreEqual(0, groups.Count);
        }
        public void AddAnotherEntryToTraining()
        {
            DateTime date  = new DateTime(2012, 03, 26);//monday
            var      cycle = new A6WTrainingDTO();

            cycle.Name      = "My A6W";
            cycle.StartDate = date;
            var         profile1 = (ProfileDTO)profiles[0].Tag;
            SessionData data     = CreateNewSession(profile1, ClientInformation);

            MyTrainingDTO result = null;

            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                var param        = new MyTrainingOperationParam();
                param.Operation  = MyTrainingOperationType.Start;
                param.MyTraining = cycle;
                result           = service.MyTrainingOperation(data.Token, param);
            });

            TrainingDayDTO day   = new TrainingDayDTO(DateTime.UtcNow.AddDays(50));
            A6WEntryDTO    entry = new A6WEntryDTO();

            entry.Day        = A6WManager.Days[0];
            entry.MyTraining = result;
            day.AddEntry(entry);
            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                TimerService.UtcNow = DateTime.UtcNow.AddDays(3).Date;
                service.SaveTrainingDay(data.Token, day);
            });
        }
示例#16
0
        public void TwoEntries_EachDifferentType()
        {
            TrainingDayDTO daySource = new TrainingDayDTO();

            daySource.InstanceId = Guid.NewGuid();
            SizeEntryDTO size = new SizeEntryDTO();

            size.InstanceId = Guid.NewGuid();
            daySource.Objects.Add(size);
            size.TrainingDay = daySource;
            GPSTrackerEntryDTO tracker = new GPSTrackerEntryDTO();

            tracker.InstanceId = Guid.NewGuid();
            daySource.Objects.Add(tracker);
            tracker.TrainingDay = daySource;

            var dayCopy = daySource.Copy();

            dayCopy.GlobalId              = Guid.NewGuid();
            dayCopy.Objects[0].GlobalId   = Guid.NewGuid();
            dayCopy.Objects[1].GlobalId   = Guid.NewGuid();
            dayCopy.InstanceId            = Guid.Empty;
            dayCopy.Objects[0].InstanceId = Guid.Empty;
            dayCopy.Objects[1].InstanceId = Guid.Empty;

            dayCopy.FillInstaneId(daySource);

            Assert.AreEqual(daySource.InstanceId, dayCopy.InstanceId);
            Assert.AreEqual(daySource.Objects.OfType <SizeEntryDTO>().Single().InstanceId, dayCopy.Objects.OfType <SizeEntryDTO>().Single().InstanceId);
            Assert.AreEqual(daySource.Objects.OfType <GPSTrackerEntryDTO>().Single().InstanceId, dayCopy.Objects.OfType <GPSTrackerEntryDTO>().Single().InstanceId);
        }
        public void CreateNewTrainingInSaveTrainingDay()
        {
            DateTime date  = new DateTime(2012, 03, 26);//monday
            var      cycle = new A6WTrainingDTO();

            cycle.Name      = "My A6W";
            cycle.StartDate = date;
            var         profile1 = (ProfileDTO)profiles[0].Tag;
            SessionData data     = CreateNewSession(profile1, ClientInformation);


            TrainingDayDTO day   = new TrainingDayDTO(DateTime.UtcNow.AddDays(50));
            A6WEntryDTO    entry = new A6WEntryDTO();

            entry.Day        = A6WManager.Days[0];
            entry.MyTraining = cycle;
            day.AddEntry(entry);
            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                var result = service.SaveTrainingDay(data.Token, day);
                day        = result.TrainingDay;
            });
            var count = Session.QueryOver <MyTrainingDTO>().RowCount();

            Assert.AreEqual(0, count);
            var dbDay = Session.Get <TrainingDay>(day.GlobalId);

            Assert.IsNull(dbDay.Objects.ElementAt(0).MyTraining);
        }
示例#18
0
        public static TrainingDayDTO FillInstaneId(this TrainingDayDTO newObj, TrainingDayDTO dayOld, bool fillOldGlobalId = false)
        {
            newObj.InstanceId = dayOld.InstanceId;
            if (fillOldGlobalId)
            {
                dayOld.GlobalId = newObj.GlobalId;
            }
            foreach (var newEntry in newObj.Objects)
            {
                //first find by GlobalId
                var oldEntry = dayOld.Objects.SingleOrDefault(x => !newEntry.IsNew && x.GlobalId == newEntry.GlobalId);
                if (oldEntry != null)
                {
                    InstanceIdResolver.fillOldGlobalId(newEntry, oldEntry, fillOldGlobalId);
                    continue;
                }
                //next we assume that there is only one type of entry in training day (e.g. one size entry or strength training entry)
                var oldEntriesWithSameType = dayOld.Objects.Where(x => x.GetType() == newEntry.GetType()).ToList();
                if (oldEntriesWithSameType.Count == 1 && oldEntriesWithSameType.Single().IsNew)
                {//we must check if this single entry is new (GlobalId = empty). If not we cannot attach InstanceId
                    InstanceIdResolver.fillOldGlobalId(newEntry, oldEntriesWithSameType.Single(), fillOldGlobalId);
                    continue;
                }

                //if there are more then one entry with the same type, we check if there is only one with IsNew status in old day. If yes then we can find out instanceid
                var oldIsNewEntries = oldEntriesWithSameType.Where(x => x.IsNew).ToList();
                if (oldEntriesWithSameType.Count > 1 && oldIsNewEntries.Count == 1)
                {
                    InstanceIdResolver.fillOldGlobalId(newEntry, oldIsNewEntries.Single(), fillOldGlobalId);
                    continue;
                }
            }
            return(newObj);
        }
示例#19
0
        public void TwoEntries_SameType_FindingByGlobalId()
        {
            TrainingDayDTO daySource = new TrainingDayDTO();

            daySource.GlobalId   = Guid.NewGuid();
            daySource.InstanceId = Guid.NewGuid();
            SizeEntryDTO size = new SizeEntryDTO();

            size.GlobalId   = Guid.NewGuid();
            size.InstanceId = Guid.NewGuid();
            daySource.Objects.Add(size);
            size.TrainingDay = daySource;
            SizeEntryDTO tracker = new SizeEntryDTO();

            tracker.InstanceId = Guid.NewGuid();
            tracker.GlobalId   = Guid.NewGuid();
            daySource.Objects.Add(tracker);
            tracker.TrainingDay = daySource;

            var dayCopy = daySource.Copy();

            dayCopy.InstanceId            = Guid.Empty;
            dayCopy.Objects[0].InstanceId = Guid.Empty;
            dayCopy.Objects[1].InstanceId = Guid.Empty;

            dayCopy.FillInstaneId(daySource);

            Assert.AreEqual(daySource.InstanceId, dayCopy.InstanceId);
            Assert.AreEqual(size.InstanceId, dayCopy.Objects.Single(x => x.GlobalId == size.GlobalId).InstanceId);
            Assert.AreEqual(tracker.InstanceId, dayCopy.Objects.Single(x => x.GlobalId == tracker.GlobalId).InstanceId);
        }
        public void TestGetTrainingDay_Current_Private()
        {
            setPrivacy(Privacy.Private);

            var profile1 = (ProfileDTO)profiles[1].Tag;
            var profile2 = (ProfileDTO)profiles[2].Tag;

            WorkoutDayGetOperation op = new WorkoutDayGetOperation();

            op.Operation       = GetOperation.Last;
            op.UserId          = profiles[0].Id;
            op.WorkoutDateTime = trainingDays[2].TrainingDate;
            TrainingDayDTO day  = null;
            SessionData    data = SecurityManager.CreateNewSession(profile1, ClientInformation);

            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                day = Service.GetTrainingDay(data.Token, op, new RetrievingInfo());
            });
            Assert.IsNull(day);

            data = SecurityManager.CreateNewSession(profile2, ClientInformation);
            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                day = Service.GetTrainingDay(data.Token, op, new RetrievingInfo());
            });
            Assert.IsNull(day);
        }
示例#21
0
 public void Fill(TrainingDayDTO day)
 {
     this.day = day;
     blogCommentsList1.Fill(day);
     cmbAllowComments.SelectedIndex = day.AllowComments ? 0 : 1;
     IsCommentsAvailable            = !day.IsNew && day.AllowComments;
 }
        public static bool DeleteTrainingDay(SessionData sessionData, TrainingDayDTO day)
        {
            bool res = false;

            if (day != null)
            {
                if (FMMessageBox.AskYesNo(ApplicationStrings.QRemoveTrainingDay, day.TrainingDate.ToShortDateString()) == DialogResult.Yes)
                {
                    PleaseWait.Run(delegate(MethodParameters par)
                    {
                        try
                        {
                            ServiceManager.DeleteTrainingDay(day);
                            res = true;
                        }
                        catch (TrainingIntegrationException te)
                        {
                            res = false;
                            par.CloseProgressWindow();
                            ExceptionHandler.Default.Process(te, ApplicationStrings.ErrorCannotDeleteTrainingDayPartOfTraining, ErrorWindow.MessageBox);
                        }
                    });
                }
            }
            return(res);
        }
示例#23
0
        public ImageItem[] GetDayContents(TrainingDayDTO day)
        {
            StringBuilder builder = new StringBuilder();

            if (day.AllowComments)
            {
                string lastCommentDate = null;
                if (day.LastCommentDate.HasValue)
                {
                    lastCommentDate = day.LastCommentDate.Value.ToLocalTime().ToRelativeDate();
                }
                builder.AppendFormat("TrainingDayInfoDayContent_CommentsEnabled".TranslateStrings(), day.CommentsCount, lastCommentDate);
            }
            else
            {
                builder.AppendLine("TrainingDayInfoDayContent_CommentsDisabled".TranslateStrings());
            }

            ImageItem item = new ImageItem();

            item.BackBrush = new SolidColorBrush(Colors.Orange);
            item.Content   = builder.ToString();
            item.Entry     = null;
            item.ToolTip   = Name;
            item.Image     = Image;
            return(new ImageItem[] { item });
        }
示例#24
0
        public void TestDeleteTrainingDay_RemoveAllTrainingDays()
        {
            var            profile = (ProfileDTO)profiles[0].Tag;
            SessionData    data    = SecurityManager.CreateNewSession(profile, ClientInformation);
            DateTime       date    = DateTime.Now.AddDays(-2);
            TrainingDayDTO day     = new TrainingDayDTO(date);

            day.ProfileId = profile.Id;

            SizeEntryDTO sizeEntry = new SizeEntryDTO();

            sizeEntry.Wymiary        = new WymiaryDTO();
            sizeEntry.Wymiary.Height = 100;
            day.AddEntry(sizeEntry);

            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                day = Service.SaveTrainingDay(data.Token, day);
            });

            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                Service.DeleteTrainingDay(data.Token, day);
            });

            var dbProfile = Session.Get <Profile>(profile.Id);

            Assert.AreEqual(0, dbProfile.Statistics.TrainingDaysCount);
            Assert.AreEqual(null, dbProfile.Statistics.LastEntryDate);
            Assert.AreEqual(0, dbProfile.Statistics.SizeEntriesCount);
        }
        public void Test_SaveTrainingDay_UpdateSize_TwoTimes()
        {
            var            profile = (ProfileDTO)profiles[0].Tag;
            SessionData    data    = SecurityManager.CreateNewSession(profile, ClientInformation);
            TrainingDayDTO day     = new TrainingDayDTO(DateTime.Now.AddDays(-2));

            day.ProfileId = profile.Id;
            SizeEntryDTO entry = new SizeEntryDTO();

            entry.Wymiary        = new WymiaryDTO();
            entry.Wymiary.Height = 100;
            day.AddEntry(entry);
            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                service.SaveTrainingDay(data.Token, day);
            });

            day                  = new TrainingDayDTO(DateTime.Now.AddDays(-1));
            day.ProfileId        = profile.Id;
            entry                = new SizeEntryDTO();
            entry.Wymiary        = new WymiaryDTO();
            entry.Wymiary.Height = 50;
            day.AddEntry(entry);
            RunServiceMethod(delegate(InternalBodyArchitectService service)
            {
                service.SaveTrainingDay(data.Token, day);
            });
            var dbProfile = Session.Get <Profile>(profile.Id);

            Assert.AreEqual(50, dbProfile.Wymiary.Height);
        }
示例#26
0
        public TrainingDayDTO SaveTrainingDay(Token token, TrainingDayDTO day)
        {
            BodyArchitect.Service.V2.InternalBodyArchitectService service = new V2.InternalBodyArchitectService(NHibernateContext.Current().Session);

            //var test=service.SaveTrainingDay(token,);
            throw new NotImplementedException();
        }
示例#27
0
        public void DeleteTrainingDay_EntryWithReminder()
        {
            var            profile = (ProfileDTO)profiles[0].Tag;
            SessionData    data    = CreateNewSession(profile, ClientInformation);
            DateTime       date    = DateTime.Now.AddDays(-2);
            TrainingDayDTO day     = new TrainingDayDTO(date);

            day.ProfileId = profile.GlobalId;
            SizeEntryDTO sizeEntry = new SizeEntryDTO();

            sizeEntry.Wymiary        = new WymiaryDTO();
            sizeEntry.RemindBefore   = TimeSpan.FromMinutes(10);
            sizeEntry.Wymiary.Height = 100;
            day.AddEntry(sizeEntry);

            SaveTrainingDayResult result = null;

            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                result = Service.SaveTrainingDay(data.Token, day);
                day    = result.TrainingDay;
            });

            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                var param           = new DeleteTrainingDayParam();
                param.TrainingDayId = day.GlobalId;

                Service.DeleteTrainingDay(data.Token, param);
            });

            var count = Session.QueryOver <ReminderItem>().RowCount();

            Assert.AreEqual(0, count);
        }
示例#28
0
        public void TestDeleteTrainingDay_Mode_OnlyWithoutMyTraining_TrainingDayShouldBeDeleted()
        {
            var            profile = (ProfileDTO)profiles[0].Tag;
            SessionData    data    = CreateNewSession(profile, ClientInformation);
            DateTime       date    = DateTime.Now.AddDays(-2);
            TrainingDayDTO day     = new TrainingDayDTO(date);

            day.ProfileId = profile.GlobalId;

            SizeEntryDTO sizeEntry = new SizeEntryDTO();

            sizeEntry.Wymiary        = new WymiaryDTO();
            sizeEntry.Wymiary.Height = 100;
            day.AddEntry(sizeEntry);

            SaveTrainingDayResult result = null;

            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                result = Service.SaveTrainingDay(data.Token, day);
                day    = result.TrainingDay;
            });

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

            Assert.AreEqual(0, Session.QueryOver <TrainingDay>().RowCount());
            Assert.AreEqual(0, Session.QueryOver <SizeEntry>().RowCount());
        }
示例#29
0
        public void DeleteTrainingDay_AnotherProfile()
        {
            var            profile = (ProfileDTO)profiles[0].Tag;
            SessionData    data    = CreateNewSession(profile, ClientInformation);
            DateTime       date    = DateTime.Now.AddDays(-2);
            TrainingDayDTO day     = new TrainingDayDTO(date);

            day.ProfileId = profile.GlobalId;
            SizeEntryDTO sizeEntry = new SizeEntryDTO();

            sizeEntry.Wymiary        = new WymiaryDTO();
            sizeEntry.Wymiary.Height = 100;
            day.AddEntry(sizeEntry);

            SaveTrainingDayResult result = null;

            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                result = Service.SaveTrainingDay(data.Token, day);
                day    = result.TrainingDay;
            });

            data = CreateNewSession((ProfileDTO)profiles[1].Tag, ClientInformation);
            RunServiceMethod(delegate(InternalBodyArchitectService Service)
            {
                var param           = new DeleteTrainingDayParam();
                param.TrainingDayId = day.GlobalId;

                Service.DeleteTrainingDay(data.Token, param);
            });
        }
示例#30
0
 private void addTrainingDayInfo(TrainingDayDTO day)
 {
     if (day != null)
     {
         var item = dayInfoFiller.AddDayInfo(monthCalendar1, day);
         item.Tag = day;
     }
 }