public async Task <int> CreateEventAsync( int meetId, int eventNum, int roundNum, int flightNum, string eventName, CancellationToken ct) { // If (exists) // Update // Else // Add var newEvent = _context.Events.Add(new EventEntity { meetId = meetId, EventNum = eventNum, RoundNum = roundNum, FlightNum = flightNum, EventName = eventName }); var created = await _context.SaveChangesAsync(); if (created < 1) { throw new InvalidOperationException("Could not create and add the event"); } return(_context.Events.Last().eventId); }
public async Task <int> AddOrUpdateVerticalMarksAsync( MarksForm <VerticalAttempt> marksForm, CancellationToken ct) { var query = _context.VerticalMarks .Where(e => e.entryId == marksForm.entryId).ToArray(); _context.VerticalMarks.RemoveRange(query); foreach (VerticalAttempt att in marksForm.Marks) { _context.VerticalMarks.Add(new VerticalMarkEntity { entryId = marksForm.entryId, AttemptNum = att.AttemptNum, Marks = att.Mark }); } var created = await _context.SaveChangesAsync(ct); if (created < 1) { throw new InvalidOperationException ("Could not Add/Update marks"); } return(0); }
public async Task <int> CreateAthleteAsync( int meetId, int compNumber, string firstName, string lastName, string teamName, string gender, CancellationToken ct) { var newAthlete = _context.Athletes.Add(new AthleteEntity { meetId = meetId, CompNum = compNumber, FirstName = firstName, LastName = lastName, TeamName = teamName, Gender = gender }); var created = await _context.SaveChangesAsync(); if (created < 1) { throw new InvalidOperationException("Could not create and add the athlete"); } return(_context.Athletes.Last().athleteId); }
public async Task <int> CreateMeetAsync(string meetName, DateTime meetDate, string meetLocation, string measurementType, CancellationToken ct) { var newMeet = _context.Meets.Add(new MeetEntity { MeetName = meetName, MeetDate = meetDate, MeetLocation = meetLocation, MeasurementType = measurementType, }); var created = await _context.SaveChangesAsync(); if (created < 1) { throw new InvalidOperationException("Could not create and add the athlete"); } return(_context.Meets.Last().meetId); }