Example #1
0
 /// <summary>
 /// Create a new athlete and add it to the athlete list.
 /// </summary>
 /// <param name="athleteName">name of the athlete</param>
 /// <param name="club">athlete's club</param>
 /// <param name="initialHandicapMinutes">initial handicap (minutes)</param>
 /// <param name="initialHandicapSeconds">initial handicap (seconds)</param>
 /// <param name="sex">athlete's sex</param>
 /// <param name="runningNumbers">collection of registed running numbers</param>
 /// <param name="birthYear">birth year, not used</param>
 /// <param name="birthMonth">birth month, not used</param>
 /// <param name="birthDay">birth day, not used</param>
 /// <param name="signedConsent">
 /// Indicates whether the parental consent form has been signed.
 /// </param>
 /// <param name="active">Indicates whether the athlete is currently active</param>
 public void CreateNewAthlete(
     string athleteName,
     string club,
     int initialHandicapMinutes,
     int initialHandicapSeconds,
     SexType sex,
     List <string> runningNumbers,
     string birthYear,
     string birthMonth,
     string birthDay,
     bool signedConsent,
     bool active)
 {
     Athletes.SetNewAthlete(
         new AthleteDetails(
             Athletes.NextKey,
             athleteName,
             club,
             new TimeType(initialHandicapMinutes, initialHandicapSeconds),
             sex,
             birthYear,
             birthMonth,
             birthDay,
             signedConsent,
             active,
             this.normalisationConfigurationManager)
     {
         RunningNumbers = runningNumbers
     });
 }
        public async Task <IActionResult> Edit(int id, [Bind("AthletesID,ParticipantName,Distance,Fitness")] Athletes athletes)
        {
            if (id != athletes.AthletesID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(athletes);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AthletesExists(athletes.AthletesID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(athletes));
        }
 public void AddAthletes(List <Athlete> athletes)
 {
     if (athletes.Any())
     {
         athletes.ForEach(_x => { _x.Start(); Athletes.Add(_x); });
     }
 }
Example #4
0
        private int GetAthleteId(string firstName, string lastName)
        {
            int id = 0;

            id = Athletes.Where(x => x.FirstName == firstName && x.LastName == lastName).FirstOrDefault().Id;
            return(id);
        }
 public async Task <IActionResult> Login(Users model)
 {
     if (ModelState.IsValid)
     {
         SHA512Managed sha  = new SHA512Managed();
         string        hash = System.Text.Encoding.UTF8.GetString(sha.ComputeHash(System.Text.Encoding.UTF8.GetBytes(model.Password)));
         Users         user = AppDbContext.db.Users.FirstOrDefault(u => u.Email == model.Email && u.Password == hash);
         if (user != null)
         {
             byte        pass = 0;
             Athletes    a    = AppDbContext.db.Athletes.FirstOrDefault(u => u.Id == user);
             Trainers    t    = AppDbContext.db.Trainers.FirstOrDefault(u => u.User == user);
             RDSUWorkers r    = AppDbContext.db.RDSUWorkers.FirstOrDefault(u => u.User == user);
             if (a != null && a.Status >= 0)
             {
                 pass &= 0b00000001;
             }
             if (t != null && t.Status)
             {
                 pass &= 0b00000010;
             }
             if (r != null && r.Status)
             {
                 pass &= 0b00000100;
             }
             return(Ok(new { token = GenerateJWT(user, pass) }));
         }
         ModelState.AddModelError("", "Некорректные логин и(или) пароль"); // : проверка логина и пароля отдельно
     }
     return(UnprocessableEntity());
 }
Example #6
0
        public MainWindow()
        {
            // Init
            _openAthletes = new ObservableCollection <Athlete>();

            InitializeComponent();

            // Set culture
            CultureInfo.DefaultThreadCurrentCulture   = new CultureInfo("pt-PT");
            CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo("pt-PT");

            BindingOperations.GetBinding(MinDateRange, DatePicker.SelectedDateProperty)?.ValidationRules.Add(SliderRange.MinDateValidator);
            BindingOperations.GetBinding(MaxDateRange, DatePicker.SelectedDateProperty)?.ValidationRules.Add(SliderRange.MaxDateValidator);

            OpenAthletesList.ItemsSource            = _openAthletes; // empty on start
            ModalityList.ItemsSource                = Modalities.GetModalities();
            AthletesWithOpenEvaluations.ItemsSource = Athletes.AthletesWithOpenEvaluations();

            // Modal
            EvaluationModal.PreviewMouseUp += delegate { if (!_withinMarkPopup)
                                                         {
                                                             BodyChartMarkPopup.IsPopupOpen = false;
                                                         }
            };
        }
Example #7
0
        public void OnGet()
        {
            Countries = _context.Country.ToList();
            Athletes  = _context.Athlete.ToList();

            AthleteCount = Athletes.Count();
        }
Example #8
0
 public AthleteModel this[int athleteId]
 {
     get
     {
         var athlete = Athletes.FirstOrDefault(a => a.Id == athleteId);
         return(athlete);
     }
 }
Example #9
0
 public async void OnEditButtonClick(int id, int level, int shuttle)
 {
     foreach (var athlete in Athletes.Where(i => i.Id == id))
     {
         athlete.Level   = level;
         athlete.Shuttle = shuttle;
     }
 }
Example #10
0
 public void UpdateAthleteInfo()
 {
     foreach (var athlete in Athletes.Where(i => i.IsStopped == false))
     {
         athlete.Level   = Level;
         athlete.Shuttle = Shuttle;
     }
 }
 private void DeleteAthlete(Athletes athlete)
 {
     using var context = _contextFactory.CreateDbContext();
     foreach (var attempt in context.Attempts.Where(attempt => attempt.AthleteId == athlete.Id))
     {
         context.Attempts.Remove(attempt);
     }
     context.Athletes.Remove(athlete);
     context.SaveChanges();
 }
    // method to normalize our GPS data
    public Cartesian Normalized_Point(Athletes athlete)
    {
        double x = (athlete.lat - min_Lat) / (max_Lat - min_Lat);
        double y = (athlete.lon - min_Lon) / (max_Lon - min_Lon);

        x = x * (MAX_X - MIN_X) + MIN_X;
        y = y * (MAX_Y - MIN_Y) + MIN_Y;

        return(new Cartesian(athlete, x, y));
    }
        public ActionResult <List <string> > RegTourInfo()
        {
            int Id = UsersController.isValidJWT(Request);

            if (Id != -1)
            {
                Athletes athletes = AppDbContext.db.Athletes.FirstOrDefault(u => u.Id.Id == Id);
                return(AppDbContext.db.Scorecards.ToList().Where(u => (u.Athletes1 == athletes || u.Athletes2 == athletes)));
            }
            return(Unauthorized());
        }
    public Cartesian convertSphericalToCartesian(Athletes athlete)
    {
        double lat = DegToRad(athlete.lat);
        double lon = DegToRad(athlete.lon);

        var x = earthRadius * Mathf.Cos((float)lat) * Mathf.Cos((float)lon);
        var y = earthRadius * Mathf.Cos((float)lat) * Mathf.Sin((float)lon); //altitude
        var z = earthRadius * Mathf.Sin((float)lat);

        return(new Cartesian(athlete, x, y));
    }
        public async Task <IActionResult> Create([Bind("AthletesID,ParticipantName,Distance,Fitness")] Athletes athletes)
        {
            if (ModelState.IsValid)
            {
                _context.Add(athletes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(athletes));
        }
Example #16
0
File: Season.cs Project: abs508/jHc
        /// <summary>
        /// Update the points earnt for position for the indicated athlete on the indicated date.
        /// </summary>
        /// <param name="key">unique key</param>
        /// <param name="date">date of the event</param>
        /// <param name="points">earned points</param>
        public void UpdatePositionPoints(int key, DateType date, int points)
        {
            IAthleteSeasonDetails athlete = Athletes.Find(a => a.Key == key);

            if (athlete == null)
            {
                return;
            }

            athlete.UpdatePositionPoints(date, points);
        }
Example #17
0
File: Season.cs Project: abs508/jHc
        /// <summary>
        /// Add a new time to the indicated (key) athlete.
        /// </summary>
        /// <param name="key">unique key</param>
        /// <param name="newTime">new time to add</param>
        public void AddNewTime(int key, Appearances newTime)
        {
            IAthleteSeasonDetails athlete = Athletes.Find(a => a.Key == key);

            if (athlete == null)
            {
                return;
            }

            athlete.AddNewTime(newTime);
        }
Example #18
0
File: Season.cs Project: abs508/jHc
        /// <summary>
        /// Get the current handicap for the athlete. The handicap is the rounded one.
        /// </summary>
        /// <param name="key">unique key</param>
        /// <returns>rounded handicap</returns>
        public RaceTimeType GetAthleteHandicap(int key, NormalisationConfigType hcConfiguration)
        {
            if (Athletes != null && Athletes.Count > 0)
            {
                if (Athletes.Exists(athlete => athlete.Key == key))
                {
                    return(Athletes.Find(athlete => athlete.Key == key).GetRoundedHandicap(hcConfiguration));
                }
            }

            return(null);
        }
Example #19
0
        public async Task <IActionResult> RemoveMe()
        {
            int Id = UsersController.isValidJWT(Request);

            if (Id != -1)
            {
                Athletes athletes = AppDbContext.db.Athletes.FirstOrDefault(u => u.Id == AppDbContext.db.Users.Find(Id));
                athletes.Status = -1;
                await AppDbContext.db.SaveChangesAsync();
            }
            return(Unauthorized());
        }
Example #20
0
        public void Stop()
        {
            var allowedAthletes = Athletes.Where(_x => _x.State == AppEnum.State.RUNNING || _x.State == AppEnum.State.WARNED).ToList();

            allowedAthletes.ForEach(_x =>
            {
                _x.Finish();
            });

            OnStopEvent();
            CancellationTokenSource.Cancel();
            ToggleTimer(false);
        }
Example #21
0
 public AthleteDetailsVM(IDataAccessService DbAccess, FitLogImporter FitLogImporter, GpxImporter GpxImporter)
 {
     _Logger         = NLog.LogManager.GetCurrentClassLogger();
     _DbAccess       = DbAccess;
     _FitLogImporter = FitLogImporter;
     _GpxImporter    = GpxImporter;
     Messenger.Default.Register <NotificationMessage <IList <AthleteEntity> > >(this, message =>
     {
         if (message.Notification == MessengerNotifications.LOADED)
         {
             if (message.Content == null)
             {
                 Athletes = new ObservableCollection <AthleteEntity>();
             }
             else
             {
                 Athletes = new ObservableCollection <AthleteEntity>(message.Content);
             }
         }
     });
     Messenger.Default.Register <NotificationMessage <ImporterTypeEnum> >(this, message =>
     {
         if (message.Notification == MessengerNotifications.IMPORT)
         {
             ImportDialog(message.Content);
         }
     });
     Messenger.Default.Register <NotificationMessage <AthleteEntity> >(this, message =>
     {
         if (message.Notification == MessengerNotifications.NEW)
         {
             var athlete = message.Content;
             Athletes.Add(athlete);
             SelectedAthlete = athlete;
         }
     });
     Messenger.Default.Register <NotificationMessage <ACTION_TYPE> >(this, message =>
     {
         if (message.Notification == MessengerNotifications.ASK_FOR_ACTION && message.Content == ACTION_TYPE.DELETE_SELECTED_ACTIVITIES)
         {
             DispatcherHelper.CheckBeginInvokeOnUI(() =>
             {
                 var toRemove = new List <ActivityEntity>(SelectedActivities);
                 foreach (var activity in toRemove)
                 {
                     _SelectedAthlete.Activities.Remove(activity);
                 }
             });
         }
     });
 }
Example #22
0
File: Season.cs Project: abs508/jHc
        /// <summary>
        /// Add a new time to the indicated (key) athlete.
        /// </summary>
        /// <param name="key">unique key</param>
        /// <param name="points">new points to add</param>
        public void AddNewPoints(
            int key,
            CommonPoints points)
        {
            IAthleteSeasonDetails athlete = Athletes.Find(a => a.Key == key);

            if (athlete == null)
            {
                return;
            }

            athlete.AddNewPoints(points);
            this.AthletesChangedEvent?.Invoke(this, new EventArgs());
        }
Example #23
0
        public void Delete()
        {
            AthleteDisplayModel e = Athletes.Where(x => x.Id == SelectedAthlete.Id).FirstOrDefault();

            if (e != null)
            {
                SqlDataAccess sql = new SqlDataAccess();
                sql.DeleteData <dynamic>("dbo.spAthlete_Delete", new { Id = SelectedAthlete.Id }, "ADBData");

                Athletes        = new BindingList <AthleteDisplayModel>(GetAllAthletes());
                SelectedAthlete = null;
                Clear();

                _events.PublishOnUIThread(new AthleteChangedEvent());
            }
        }
Example #24
0
        public bool CanDelete( )
        {
            if (Championship == null)
            {
                return(true);
            }

            if (Championship.isLocked( ))
            {
                return(false);
            }

            // 2016-05-29 optimised by not using getAllAthletes which instantiates each athlete.
            return(Athletes.Count( ) == 0);
            //return ( getAllAthletes ( ).Count == 0 );
        }
Example #25
0
        /**
         * ### 8. feladat ###
         * egyszeru egy felteteles query csokkeno sorrendben, csak az elso elemmel
         *
         * custom header kell, mert csak egy elemmel terunk vissza ilyenkor nem irja ki automatikusan
         */
        private void Task8()
        {
            Athletes query = (from athlete in athletes
                              where athlete.Team == "Norway"
                              orderby athlete.Height descending
                              select athlete).FirstOrDefault();

            using (var writer = new StreamWriter(Path.Combine(outPutFolder, task8Name)))
                using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
                {
                    csv.WriteHeader <Athletes>();
                    csv.NextRecord();
                    csv.WriteField(query.ToString(), false);
                    writer.Flush();
                }
            Console.WriteLine("{0} created", task8Name);
        }
Example #26
0
 public void UpdateFields()
 {
     if (SelectedResult != null)
     {
         //SelectedMeet.Id = SelectedResult.MeetId;
         //SelectedAthlete.Id = SelectedResult.AthleteId;
         //SelectedEvent.Id = SelectedResult.EventId;
         //Mark = SelectedResult.Mark.ToString();
         //PerfDate = SelectedResult.PerfDate;
         SelectedMeet    = Meets.Where(x => x.Id == SelectedResult.MeetId).FirstOrDefault();
         SelectedAthlete = Athletes.Where(x => x.Id == SelectedResult.AthleteId).FirstOrDefault();
         SelectedEvent   = EventList.Where(x => x.Id == SelectedResult.EventId).FirstOrDefault();
         Mark            = SelectedResult.Mark.ToString();
         Wind            = SelectedResult.Wind;
         PerfDate        = SelectedResult.PerfDate;
     }
 }
        public ActionResult <List <Category> > CategoryInfo(int ID)
        {
            int Id = UsersController.isValidJWT(Request);

            if (Id != -1)
            {
                Athletes athletes = AppDbContext.db.Athletes.FirstOrDefault(u => u.Id.Id == Id);
                Athletes parthner = athletes.Athlet;
                byte     old      = athletes.DateOfBirth > parthner.DateOfBirth ? Categories.OldReader(DateTime.Today.Year - athletes.DateOfBirth.Year) : Categories.OldReader(DateTime.Today.Year - parthner.DateOfBirth.Year);
                byte     danceSt  = athletes.St > parthner.St ? athletes.St : parthner.St;
                byte     danceLa  = athletes.La > parthner.La ? athletes.La : parthner.La;
                return(AppDbContext.db.Categories.ToList().Where(t => t.Tournament.Id == ID && (Categories.Categorieser(false, danceLa, old) == t.Category || Categories.Categorieser(true, danceSt, old) == t.Category) &&
                                                                 AppDbContext.db.Scorecards.ToList().Where(u => u.Category == t && u.Athletes1 == athletes || u.Athletes1 == parthner || u.Athletes2 == athletes || u.Athletes2 == parthner).Count() == 0).ToList().ConvertAll(u => new Category {
                    name = Categories.StringCategory(u.Category), id = u.Id
                }));
            }
            return(Unauthorized());
        }
Example #28
0
        /// <summary>
        /// Create and add a new athlete to the athletes list. Save the list.
        /// </summary>
        /// <param name="key">athlete key</param>
        /// <param name="name">athlete name</param>
        /// <param name="runningNumbers">athlete running numbers</param>
        /// <param name="handicap">athlete handicap</param>
        /// <param name="firstTimer">first timer flag</param>
        public void AddNewAthlete(
            int key,
            string name,
            string handicap,
            bool firstTimer)
        {
            AthleteSeasonDetails newAthlete =
                new AthleteSeasonDetails(
                    key,
                    name,
                    this.resultsConfigurationManager);

            Athletes.Add(newAthlete);

            this.athleteData.SaveAthleteSeasonData(Name, Athletes);

            this.AthletesChangedEvent?.Invoke(this, new EventArgs());
        }
        public RegistrantWorkerTest()
        {
            _mockTrainingRepository     = new Mock <ITrainingRepository>();
            _mockOrganizationRepository = new Mock <IOrganizationRepository>();
            _athlete1 = new Athletes {
                Id = 67, BirthDate = new DateTime(1985, 1, 17), MF = "M", MedicalExpirationDate = new DateTime(2 / 22 / 2020)
            };
            _athlete2 = new Athletes {
                Id = 219, BirthDate = new DateTime(1970, 10, 29), MF = "M", MedicalExpirationDate = new DateTime(8 / 5 / 2018)
            };
            List <Athletes> athletes = new List <Athletes> {
                _athlete1, _athlete2
            };

            _mockOrganizationRepository.Setup(repository => repository.GetAllAthletes()).ReturnsAsync(athletes);

            _worker = new RegistrantWorker(_mockTrainingRepository.Object, _mockOrganizationRepository.Object);
        }
Example #30
0
File: Season.cs Project: abs508/jHc
        /// <summary>
        /// Create and add a new athlete to the athletes list. Save the list.
        /// </summary>
        /// <param name="key">athlete key</param>
        /// <param name="name">athlete name</param>
        /// <param name="runningNumbers">athlete running numbers</param>
        /// <param name="handicap">athlete handicap</param>
        /// <param name="firstTimer">first timer flag</param>
        public void AddNewAthlete(
            int key,
            string name,
            string handicap,
            bool firstTimer)
        {
            AthleteSeasonDetails newAthlete =
                new AthleteSeasonDetails(
                    key,
                    name);

            Athletes.Add(newAthlete);

            this.athleteData.SaveAthleteSeasonData(Name, Athletes);

            this.AthletesChangedEvent?.Invoke(this, new EventArgs());
            this.AthleteCollectionChangedEvent?.Invoke(this, EventArgs.Empty);
        }