public void Design(TrainingSetTemplate template) { var view = serviceLocator.GetInstance <IDesignerView>(); view.Model.SelectedTemplate = template; view.Model.Show(); }
public void AddTemplateToLibrary(TrainingSetTemplate template) { var proxy = CreateApplicationUserServiceClient(); proxy.AddTemplateToLibraryCompleted += (sender, e) => { if (e.Error != null) { if (AddTemplateError != null) { AddTemplateError(this, new DataEventArgs <Exception>(e.Error)); } } else { if (AddTemplateCompleted != null) { if (e.Result.AddTemplateStatus == AddTemplateStatus.Success) { ApplicationUser.CurrentUser.Credits = e.Result.Credits; } AddTemplateCompleted(this, new DataEventArgs <AddTemplateResponse>(e.Result)); } } }; proxy.AddTemplateToLibraryAsync(new AddTemplateRequest() { User = ApplicationUser.CurrentUser.Username, TemplateId = template.Id }); }
public void SaveTemplate(TrainingSetTemplate template) { var proxy = CreateTrainingSetTemplateServiceClient(); proxy.SaveCompleted += (sender, e) => { if (e.Error != null) { if (TrainingSetTemplateSaveError != null) { TrainingSetTemplateSaveError(this, new DataEventArgs <Exception>(e.Error)); } } else { if (TrainingSetTemplateSaved != null) { TrainingSetTemplateSaved(this, new DataEventArgs <SaveTemplateResponse>(e.Result)); } } }; proxy.SaveAsync(new SaveTemplateRequest() { Template = template, User = ApplicationUser.CurrentUser.Username }); }
private void EditTemplate(TrainingSetTemplate arg) { if (arg.IsPublic) { dialogFacade.Alert(MyLibraryResources.NoEditingOfPublicTemplates); } else { var view = serviceLocator.GetInstance <ITemplateView>(); view.Model.EditTemplate(arg); } }
private void RemoveTemplate(TrainingSetTemplate arg) { dialogFacade.Confirm(MyLibraryResources.RemoveTemplateConfirmation, result => { if (result) { var service = serviceLocator.GetInstance <ITrainingSetTemplateService>(); service.TrainingSetTemplateRemoved += (sender, e) => { switch (e.Value.Status) { case RemoveTemplateStatus.Success: SmartDispatcher.BeginInvoke(() => { ApplicationUser.CurrentUser.Templates.Remove(arg); this.IsBusy = false; //OnTemplateRemoved(); }); break; case RemoveTemplateStatus.Error: this.IsBusy = false; dialogFacade.Alert(MyLibraryResources.ErrorRemovingTemplate); break; default: break; } }; service.TrainingSetTemplateRemoveError += (sender, e) => { throw e.Value; }; this.IsBusy = true; try { service.RemoveTemplate(arg); } catch { IsBusy = false; throw; } } }); }
public void EditTemplate(TrainingSetTemplate template) { this.TemplateOperation = CrudOperation.Update; this.Template = template; this.Template.PropertyChanged += (sender, e) => { if (e.PropertyName == "EffortType") { foreach (var interval in Intervals) { interval.EffortType = this.Template.EffortType; } } }; PopulateIntervals(template.Intervals, x => intervals.Add(x)); this.Template.BeginEdit(); shell.AddToLayoutRoot(View as UIElement); }
public void NewTemplate() { this.TemplateOperation = CrudOperation.Create; this.Template = new TrainingSetTemplate(); this.Template.EffortType = ApplicationContext.Current.EffortTypes.FirstOrDefault(); this.Template.PropertyChanged += (sender, e) => { if (e.PropertyName == "EffortType") { foreach (var interval in Intervals) { interval.EffortType = this.Template.EffortType; } } }; this.Template.BeginEdit(); shell.AddToLayoutRoot(View as UIElement); }
private void AddToMyLibrary(TrainingSetTemplate template) { ApplicationUser.CurrentUser.AddTemplateToLibrary(template, () => { }); }
private void CreateRide(TrainingSetTemplate arg) { eventAggregator.GetEvent <DesignEvent>().Publish(arg); }
static void Main(string[] args) { var sessionFactory = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2008.ConnectionString(x => x.FromConnectionStringWithKey("IndoorWorx"))) .Mappings(x => x.FluentMappings.AddFromAssemblyOf <Module>()) .ExposeConfiguration(x => new SchemaExport(x).SetOutputFile("../../Schema/createdb.sql").Create(true, true)) .BuildSessionFactory(); using (var session = sessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { session.Save(new ApplicationUser() { Email = "*****@*****.**", Firstname = "Ross", Gender = Genders.Male, Lastname = "McEwan", Username = "******", Credits = 100 }); var power = new EffortType() { Title = "Power", Sequence = 10, Tag = "POWER" }; session.Save(power); var hr = new EffortType() { Title = "Heart Rate", Sequence = 20, Tag = "HR" }; session.Save(hr); var rpe = new EffortType() { Title = "RPE", Description = "Rate of perceived exertion", Sequence = 30, Tag = "RPE" }; session.Save(rpe); var l1 = new IntervalLevel() { Title = "L1 - Active Recovery", Sequence = 10, MaximumPercentageOfFthr = 68, MaximumPercentageOfFtp = 55, MinRPE = 0, MaxRPE = 2 }; session.Save(l1); var l2 = new IntervalLevel() { Title = "L2 - Endurance", Sequence = 20, MinimumPercentageOfFthr = 69, MaximumPercentageOfFthr = 83, MaximumPercentageOfFtp = 75, MinimumPercentageOfFtp = 56, MinRPE = 2, MaxRPE = 3 }; session.Save(l2); var l3 = new IntervalLevel() { Title = "L3 - Tempo", Sequence = 30, MinimumPercentageOfFthr = 84, MaximumPercentageOfFthr = 94, MaximumPercentageOfFtp = 90, MinimumPercentageOfFtp = 76, MinRPE = 3, MaxRPE = 4 }; session.Save(l3); var l4 = new IntervalLevel() { Title = "L4 - Lactate Threshold", Sequence = 40, MinimumPercentageOfFthr = 95, MaximumPercentageOfFthr = 105, MaximumPercentageOfFtp = 105, MinimumPercentageOfFtp = 91, MinRPE = 4, MaxRPE = 5, TypicalMinDuration = TimeSpan.FromMinutes(8), TypicalMaxDuration = TimeSpan.FromMinutes(30) }; session.Save(l4); var l5 = new IntervalLevel() { Title = "L5 - VO2max", Sequence = 50, MinimumPercentageOfFthr = 106, MaximumPercentageOfFtp = 120, MinimumPercentageOfFtp = 106, MinRPE = 6, MaxRPE = 7, TypicalMinDuration = TimeSpan.FromMinutes(3), TypicalMaxDuration = TimeSpan.FromMinutes(8) }; session.Save(l5); var l6 = new IntervalLevel() { Title = "L6 - Anaerobic Capacity", Sequence = 60, MaximumPercentageOfFtp = 150, MinimumPercentageOfFtp = 121, MinRPE = 7, TypicalMinDuration = TimeSpan.FromSeconds(30), TypicalMaxDuration = TimeSpan.FromMinutes(3) }; session.Save(l6); var l7 = new IntervalLevel() { Title = "L7 - Neuromuscular Power", Sequence = 70, TypicalMaxDuration = TimeSpan.FromSeconds(30) }; session.Save(l7); //var warmup = new IntervalType() { Name = "Warm up", Tag = "WARMUP", Sequence = 10 }; //session.Save(warmup); //var cooldown = new IntervalType() { Name = "Cool down", Tag = "COOLDOWN", Sequence = 20 }; //session.Save(cooldown); //var recover = new IntervalType() { Name = "Recovery", Tag = "RECOVERY", Sequence = 30 }; //session.Save(recover); //var longHills = new IntervalType() { Name = "Long Hills", Tag = "LONGHILLS", Sequence = 40 }; //session.Save(longHills); //var shortHills = new IntervalType() { Name = "Short Hills", Tag = "SHORTHILLS", Sequence = 50 }; //session.Save(shortHills); //var tt = new IntervalType() { Name = "Time Trial", Tag = "TIMETRIAL", Sequence = 60 }; //session.Save(tt); //var sprints = new IntervalType() { Name = "Sprints", Tag = "SPRINTS", Sequence = 70 }; //session.Save(sprints); //var breakaways = new IntervalType() { Name = "Breakaways", Tag = "BREAKAWAYS", Sequence = 80 }; //session.Save(breakaways); var levels = new IntervalType() { Name = "Levels", Sequence = 10, Tag = IntervalType.LevelsTag }; session.Save(levels); var stepped = new IntervalType() { Name = "Stepped", Sequence = 20, Tag = IntervalType.SteppedTag }; session.Save(stepped); var recover = new IntervalType() { Name = "Recovery", Tag = IntervalType.RecoveryTag, Sequence = 30 }; session.Save(recover); #region 4x10 var trainingTemplate = new TrainingSetTemplate(); trainingTemplate.IsPublic = true; trainingTemplate.EffortType = power; trainingTemplate.Duration = TimeSpan.FromMinutes(70); trainingTemplate.Title = "4 x 10"; trainingTemplate.Description = "An easy 10 minute warm up followed by 4 10 minute intervals at threshold with 5 minutes recovery. This is followed by an easy 5 minute cool down."; trainingTemplate.Intervals.Add(new Interval() { Title = "Warm up", TemplateSection = "WARMUP", SectionGroup = "W1", IntervalType = levels, IntervalLevel = l1, Duration = TimeSpan.FromMinutes(10), EffortType = power, Effort = (l1.MinimumPercentageOfFtp + l1.MaximumPercentageOfFtp) / 2, Sequence = 0 }); trainingTemplate.Intervals.Add(new Interval() { Title = "Interval #1", TemplateSection = "MAINSET", SectionGroup = "M1", IntervalType = levels, IntervalLevel = l3, Duration = TimeSpan.FromMinutes(10), EffortType = power, Effort = (l3.MinimumPercentageOfFtp + l3.MaximumPercentageOfFtp) / 2, Sequence = 1 }); trainingTemplate.Intervals.Add(new Interval() { Title = "Recovery", TemplateSection = "MAINSET", SectionGroup = "M1", IntervalType = levels, IntervalLevel = l1, Duration = TimeSpan.FromMinutes(5), EffortType = power, Effort = (l1.MinimumPercentageOfFtp + l1.MaximumPercentageOfFtp) / 2, Sequence = 2 }); trainingTemplate.Intervals.Add(new Interval() { Title = "Interval #2", TemplateSection = "MAINSET", SectionGroup = "M1", IntervalType = levels, IntervalLevel = l3, Duration = TimeSpan.FromMinutes(10), EffortType = power, Effort = (l3.MinimumPercentageOfFtp + l3.MaximumPercentageOfFtp) / 2, Sequence = 3 }); trainingTemplate.Intervals.Add(new Interval() { Title = "Recovery", TemplateSection = "MAINSET", SectionGroup = "M1", IntervalType = levels, IntervalLevel = l1, Duration = TimeSpan.FromMinutes(5), EffortType = power, Effort = (l1.MinimumPercentageOfFtp + l1.MaximumPercentageOfFtp) / 2, Sequence = 4 }); trainingTemplate.Intervals.Add(new Interval() { Title = "Interval #3", TemplateSection = "MAINSET", SectionGroup = "M1", IntervalType = levels, IntervalLevel = l3, Duration = TimeSpan.FromMinutes(10), EffortType = power, Effort = (l3.MinimumPercentageOfFtp + l3.MaximumPercentageOfFtp) / 2, Sequence = 5 }); trainingTemplate.Intervals.Add(new Interval() { Title = "Recovery", TemplateSection = "MAINSET", SectionGroup = "M1", IntervalType = levels, IntervalLevel = l1, Duration = TimeSpan.FromMinutes(5), EffortType = power, Effort = (l1.MinimumPercentageOfFtp + l1.MaximumPercentageOfFtp) / 2, Sequence = 6 }); trainingTemplate.Intervals.Add(new Interval() { Title = "Interval #4", TemplateSection = "MAINSET", SectionGroup = "M1", IntervalType = levels, IntervalLevel = l3, Duration = TimeSpan.FromMinutes(10), EffortType = power, Effort = (l3.MinimumPercentageOfFtp + l3.MaximumPercentageOfFtp) / 2, Sequence = 7 }); trainingTemplate.Intervals.Add(new Interval() { Title = "Recovery", TemplateSection = "MAINSET", SectionGroup = "M1", IntervalType = levels, IntervalLevel = l1, Duration = TimeSpan.FromMinutes(5), EffortType = power, Effort = (l1.MinimumPercentageOfFtp + l1.MaximumPercentageOfFtp) / 2, Sequence = 8 }); trainingTemplate.Intervals.Add(new Interval() { Title = "Cool down", TemplateSection = "COOLDOWN", SectionGroup = "C1", IntervalType = levels, IntervalLevel = l1, Duration = TimeSpan.FromMinutes(5), EffortType = power, Effort = (l1.MinimumPercentageOfFtp + l1.MaximumPercentageOfFtp) / 2, Sequence = 9 }); session.Save(trainingTemplate); #endregion #region 2x20 var trainingTemplate1 = new TrainingSetTemplate(); trainingTemplate1.IsPublic = true; trainingTemplate1.EffortType = power; trainingTemplate1.Duration = TimeSpan.FromHours(1); trainingTemplate1.Title = "2 x 20"; trainingTemplate1.Description = "An easy 10 minute warm up followed by 2 20 minute intervals at threshold with 5 minutes recovery. This is followed by an easy 5 minute cool down."; trainingTemplate1.Intervals.Add(new Interval() { Title = "Warm up", TemplateSection = "WARMUP", SectionGroup = "W1", IntervalType = levels, IntervalLevel = l1, Duration = TimeSpan.FromMinutes(10), EffortType = power, Effort = (l1.MinimumPercentageOfFtp + l1.MaximumPercentageOfFtp) / 2, Sequence = 0 }); trainingTemplate1.Intervals.Add(new Interval() { Title = "Interval #1", TemplateSection = "MAINSET", SectionGroup = "M1", IntervalType = levels, IntervalLevel = l3, Duration = TimeSpan.FromMinutes(20), EffortType = power, Effort = (l3.MinimumPercentageOfFtp + l3.MaximumPercentageOfFtp) / 2, Sequence = 1 }); trainingTemplate1.Intervals.Add(new Interval() { Title = "Recovery", IntervalType = levels, TemplateSection = "MAINSET", SectionGroup = "M1", IntervalLevel = l1, Duration = TimeSpan.FromMinutes(5), EffortType = power, Effort = (l1.MinimumPercentageOfFtp + l1.MaximumPercentageOfFtp) / 2, Sequence = 2 }); trainingTemplate1.Intervals.Add(new Interval() { Title = "Interval #2", IntervalType = levels, TemplateSection = "MAINSET", SectionGroup = "M1", IntervalLevel = l3, Duration = TimeSpan.FromMinutes(20), EffortType = power, Effort = (l3.MinimumPercentageOfFtp + l3.MaximumPercentageOfFtp) / 2, Sequence = 3 }); trainingTemplate1.Intervals.Add(new Interval() { Title = "Recovery", IntervalType = levels, TemplateSection = "MAINSET", SectionGroup = "M1", IntervalLevel = l1, Duration = TimeSpan.FromMinutes(5), EffortType = power, Effort = (l1.MinimumPercentageOfFtp + l1.MaximumPercentageOfFtp) / 2, Sequence = 4 }); trainingTemplate1.Intervals.Add(new Interval() { Title = "Cool down", TemplateSection = "COOLDOWN", SectionGroup = "C1", IntervalType = levels, IntervalLevel = l1, Duration = TimeSpan.FromMinutes(5), EffortType = power, Effort = (l1.MinimumPercentageOfFtp + l1.MaximumPercentageOfFtp) / 2, Sequence = 5 }); session.Save(trainingTemplate1); #endregion session.Save(new Category() { Title = "ALL", Sequence = 0, CatalogUri = new Uri("/IndoorWorx.Catalog.Silverlight;component/Pages/VideoCatalogPage.xaml?filter=ALL&orderBy=CATEGORY", UriKind.RelativeOrAbsolute), LibraryUri = new Uri("/IndoorWorx.MyLibrary.Silverlight;component/Pages/VideoCatalogPage.xaml?filter=ALL&orderBy=CATEGORY", UriKind.RelativeOrAbsolute) }); session.Save(BuildRidesCategory()); session.Save(BuildSnippetsCategory()); session.Save(new Category() { Title = "WORKOUTS", Sequence = 3, CatalogUri = new Uri("/IndoorWorx.Catalog.Silverlight;component/Pages/VideoCatalogPage.xaml?filter=WORKOUTS&orderBy=CATEGORY", UriKind.RelativeOrAbsolute), LibraryUri = new Uri("/IndoorWorx.MyLibrary.Silverlight;component/Pages/VideoCatalogPage.xaml?filter=WORKOUTS&orderBy=CATEGORY", UriKind.RelativeOrAbsolute) }); transaction.Commit(); } } }