Пример #1
0
 public CreateTrainingDayViewModel() : base()
 {
     ShowDelayInMs       = 0;
     _dbContext          = Resolver.Resolve <ISQLite>().GetConnection();
     _trainingDayService = new TrainingDayService(_dbContext);
     _userDialog         = Resolver.Resolve <IUserDialogs>();
 }
Пример #2
0
        //public TrainingPlan GetWorkoutPlan(Token token, Guid planId, RetrievingInfo retrievingInfo)
        //{
        //    var securityInfo = SecurityManager.EnsureAuthentication(token);
        //    WorkoutPlanService service = new WorkoutPlanService(Session,securityInfo,Configuration);
        //    return service.GetWorkoutPlan(planId, retrievingInfo);
        //}

        public void DeleteTrainingDay(Token token, DeleteTrainingDayParam param)
        {
            var securityInfo           = SecurityManager.EnsureAuthentication(token);
            TrainingDayService service = new TrainingDayService(Session, securityInfo, Configuration, PushNotificationService, EMailService);

            service.DeleteTrainingDay(param);
        }
Пример #3
0
        public PagedResult <TrainingDayDTO> GetTrainingDays(Token token, WorkoutDaysSearchCriteria searchCriteria, PartialRetrievingInfo retrievingInfo)
        {
            var securityInfo           = SecurityManager.EnsureAuthentication(token);
            TrainingDayService service = new TrainingDayService(Session, securityInfo, Configuration, PushNotificationService, EMailService);

            return(service.GetTrainingDays(searchCriteria, retrievingInfo));
        }
Пример #4
0
        public TrainingDayDTO GetTrainingDay(Token token, WorkoutDayGetOperation operationParams, RetrievingInfo retrievingInfo)
        {
            var securityInfo           = SecurityManager.EnsureAuthentication(token);
            TrainingDayService service = new TrainingDayService(Session, securityInfo, Configuration, PushNotificationService, EMailService);

            return(service.GetTrainingDay(operationParams, retrievingInfo));
        }
Пример #5
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));
        }
Пример #6
0
 public TrainingDayViewModel() : base()
 {
     ShowDelayInMs       = 0;
     _dbContext          = Resolver.Resolve <ISQLite>().GetConnection();
     _trainingDayService = new TrainingDayService(_dbContext);
     _userDialog         = Resolver.Resolve <IUserDialogs>();
     CreateTrainingLabel = Translation.Get(TRS.CREATE); //necessary for ios Toolbaritem binding failed
     PrintLabel          = Translation.Get(TRS.PRINT);  //necessary for ios Toolbaritem binding failed
 }
Пример #7
0
        private static void performGpsPointsCalculations(GPSTrackerEntry res, List <GPSPoint> points, Profile dbProfile)
        {
            if (res.Status == EntryObjectStatus.Planned)
            {
                res.Status = EntryObjectStatus.Done;
            }
            //perform calculation based on gps coordinates
            res.Distance = (decimal?)GPSTrackerHelper.GetDistance(points);
            var pointsWithSpeed = points.Where(x => !float.IsNaN(x.Speed) && x.Speed > -1).ToList();

            if (pointsWithSpeed.Count > 0)
            {
                res.MaxSpeed = (decimal?)pointsWithSpeed.Max(x => x.Speed);
            }
            //res.AvgSpeed = (decimal?) points.Average(x => x.Speed);
            var pointsWithAltitude = points.Where(x => !float.IsNaN(x.Altitude) && x.Altitude > -1).ToList();

            if (pointsWithAltitude.Count > 0)
            {
                res.MaxAltitude  = (decimal?)pointsWithAltitude.Max(x => x.Altitude);
                res.MinAltitude  = (decimal?)pointsWithAltitude.Min(x => x.Altitude);
                res.TotalAscent  = (decimal?)GPSTrackerHelper.GetTotalAscents(pointsWithAltitude);
                res.TotalDescent = (decimal?)GPSTrackerHelper.GetTotalDescends(pointsWithAltitude);
            }

            if (res.Duration == null || res.Duration == 0)
            {
                res.Duration = (decimal?)points.Last().Duration;
            }
            if (res.Calories == null || res.Calories == 0)
            {
                TrainingDayService.CalculateCaloriesBurned(res,
                                                           res.TrainingDay.Customer != null
                                                               ? (IPerson)res.TrainingDay.Customer
                                                               : dbProfile);
            }
            if (res.Duration.Value > 0)
            {
                res.AvgSpeed = res.Distance.Value / res.Duration.Value;
            }
        }
 public TrainingWeekManager(ApplicationDbContext dbContext) : base(dbContext)
 {
     _trainingWeekModule = new TrainingWeekModule(DbContext);
     _trainingDayService = new TrainingDayService(DbContext);
     _userInfosService   = new UserInfoService(DbContext);
 }
Пример #9
0
        private List <Serie> createStrengthTrainingEntries(Profile dbProfile, Championship championshipDb, Championship originalChampionship)
        {
            List <Serie> records = new List <Serie>();

            foreach (var customer in championshipDb.Entries.GroupBy(x => x.Customer))
            {
                StrengthTrainingEntry strengthEntry = null;
                if (originalChampionship != null)
                {
                    var origChamCust = originalChampionship.Customers.Where(x => x.Customer == customer.Key.Customer).SingleOrDefault();
                    if (origChamCust != null)
                    {
                        strengthEntry = origChamCust.StrengthTraining;
                    }
                }

                if (strengthEntry == null)
                {
                    var trainingDay = Session.QueryOver <TrainingDay>()
                                      .Fetch(x => ((StrengthTrainingEntry)x.Objects.First()).Entries).Eager
                                      .Fetch(x => ((StrengthTrainingEntry)x.Objects.First()).MyPlace).Eager
                                      .Fetch(x => (((StrengthTrainingEntry)x.Objects.First()).Entries.First().Series)).Eager
                                      .Where(x => x.Profile == dbProfile && x.Customer == customer.Key.Customer && x.TrainingDate == championshipDb.StartTime.Date).SingleOrDefault();

                    if (trainingDay == null)
                    {
                        trainingDay         = new TrainingDay(championshipDb.StartTime);
                        trainingDay.Profile = dbProfile;

                        trainingDay.AllowComments = dbProfile.Settings.AllowTrainingDayComments;
                        trainingDay.Customer      = customer.Key.Customer;
                    }
                    strengthEntry         = new StrengthTrainingEntry();
                    strengthEntry.Status  = EntryObjectStatus.System;
                    strengthEntry.MyPlace = championshipDb.MyPlace;
                    trainingDay.AddEntry(strengthEntry);
                    Session.SaveOrUpdate(trainingDay);
                }

                strengthEntry.Entries.Clear();

                foreach (var entryDto in customer)
                {
                    StrengthTrainingItem item = new StrengthTrainingItem();
                    item.Exercise = entryDto.Exercise;
                    strengthEntry.AddEntry(item);
                    addSet(item, entryDto.Try1);
                    addSet(item, entryDto.Try2);
                    addSet(item, entryDto.Try3);
                }
                Session.SaveOrUpdate(strengthEntry);
                customer.Key.StrengthTraining = strengthEntry;

                TrainingDayService service = new TrainingDayService(Session, SecurityInfo, Configuration, null, null);
                service.EnsureRecords(dbProfile, customer.Key.Customer, new List <StrengthTrainingEntry>()
                {
                    strengthEntry
                });

                records.AddRange(strengthEntry.Entries.SelectMany(x => x.Series).Where(x => x.ExerciseProfileData != null));
            }

            return(records);
        }
 public EditTrainingExerciseViewModel() : base()
 {
     _dbContext          = Resolver.Resolve <ISQLite>().GetConnection();
     _trainingDayService = new TrainingDayService(_dbContext);
     _userDialog         = Resolver.Resolve <IUserDialogs>();
 }
 public TrainingWeekManager(SQLiteConnection dbContext) : base(dbContext)
 {
     _trainingWeekModule = new TrainingWeekModule(DbContext);
     _trainingDayService = new TrainingDayService(DbContext);
 }