public void Delete() { ResultDisplayModel e = Results.Where(x => x.Id == SelectedResult.Id).FirstOrDefault(); if (e != null) { SqlDataAccess sql = new SqlDataAccess(); sql.DeleteData <dynamic>("dbo.spResult_Delete", new { Id = SelectedResult.Id }, "ADBData"); Results = new BindingList <ResultDisplayModel>(GetAllResults()); SelectedResult = null; Clear(); //_events.PublishOnUIThread(new ResultChangedEvent()); } }
public void Update() { ResultDisplayModel exists = Results.Where(x => x.Id == SelectedResult.Id).FirstOrDefault(); if (exists != null) { if (SelectedResult != null && Results.Count > 0) { isUpdating = true; float mark = ConvertMarkToFloat(); ResultModel e = new ResultModel { Id = SelectedResult.Id, AthleteId = SelectedResult.AthleteId, MeetId = SelectedResult.MeetId, EventId = SelectedResult.EventId, Mark = mark, PerfDate = _perfDate }; SqlDataAccess sql = new SqlDataAccess(); sql.UpdateData <ResultModel>("dbo.spResult_Update", e, "ADBData"); msg = $"Result {SelectedResult.FullName} was successfully updated."; MessageBox.Show(msg, "Result Updated"); Results = new BindingList <ResultDisplayModel>(GetAllResults()); Clear(); isUpdating = false; } } //_events.PublishOnUIThread(new ResultChangedEvent()); }