Пример #1
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);
        }
Пример #2
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;
     }
 }
Пример #3
0
 public void UpdateAthleteInfo()
 {
     foreach (var athlete in Athletes.Where(i => i.IsStopped == false))
     {
         athlete.Level   = Level;
         athlete.Shuttle = Shuttle;
     }
 }
Пример #4
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);
        }
Пример #5
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());
            }
        }
Пример #6
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;
     }
 }
Пример #7
0
        public void Update()
        {
            AthleteDisplayModel exists = Athletes.Where(x => x.Id == SelectedAthlete.Id).FirstOrDefault();

            if (exists != null)
            {
                if (SelectedAthlete != null && Athletes.Count > 0)
                {
                    isUpdating = true;

                    AthleteModel e = new AthleteModel
                    {
                        Id        = SelectedAthlete.Id,
                        FirstName = _firstName,
                        LastName  = _lastName,
                        BirthDate = _birthDate,
                        IsMale    = _isMale,
                        Phone     = _phone,
                        Email     = _email,
                        AddressId = SelectedAddress.Id,
                        ParentId  = SelectedParent.Id,
                        SchoolId  = SelectedSchool.Id,
                        CoachId   = SelectedCoach.Id
                    };

                    SqlDataAccess sql = new SqlDataAccess();
                    sql.UpdateData <AthleteModel>("dbo.spAthlete_Update", e, "ADBData");

                    msg = $"Athlete ({SelectedAthlete.FullName}) was successfully updated.";
                    MessageBox.Show(msg, "Athlete Updated");
                    Athletes = new BindingList <AthleteDisplayModel>(GetAllAthletes());
                    Clear();


                    isUpdating = false;

                    _events.PublishOnUIThread(new AthleteChangedEvent());
                }
            }
        }
Пример #8
0
        public void Add()
        {
            isAdding = true;

            AthleteDisplayModel e = Athletes.Where(x => x.FirstName == FirstName && x.LastName == LastName).FirstOrDefault();

            if (e == null)
            {
                SqlDataAccess sql = new SqlDataAccess();
                sql.SaveData <dynamic>("dbo.spAthlete_Insert",
                                       new
                {
                    FirstName = _firstName,
                    LastName  = _lastName,
                    BirthDate = _birthDate,
                    IsMale    = _isMale,
                    Phone     = _phone,
                    Email     = _email,
                    AddressId = _selectedAddress.Id,
                    ParentId  = SelectedParent.Id,
                    SchoolId  = SelectedSchool.Id,
                    CoachId   = _selectedCoach.Id
                }, "ADBData");

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

                _events.PublishOnUIThread(new AthleteChangedEvent());
            }
            else
            {
                msg = $"Error: An Event named ({SelectedAthlete.FullName}) already exist!!!";
                MessageBox.Show(msg, "Error");
            }

            isAdding = false;
        }
Пример #9
0
 public void Stop(int Id)
 {
     Athletes.Where(i => i.Id == Id).FirstOrDefault(i => i.IsStopped = true);
 }
Пример #10
0
 public void Warn(int Id)
 {
     Athletes.Where(i => i.Id == Id && i.IsWarned == true).FirstOrDefault(i => i.IsStopped = true);
     Athletes.Where(i => i.Id == Id && i.IsWarned == false).FirstOrDefault(i => i.IsWarned = true);
 }