public async Task <IActionResult> PutSpeaker([FromRoute] int id, [FromBody] Speaker speaker) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != speaker.Id) { return(BadRequest()); } _context.Entry(speaker).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SpeakerExists(id)) { return(NotFound()); } else { throw; } } return(Ok($"Updated user - {speaker.FirstName} {speaker.LastName}")); //return NoContent(); }
public async Task<IActionResult> PutTag([FromRoute] int id, [FromBody] Tag tag) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != tag.Id) { return BadRequest(); } _context.Entry(tag).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TagExists(id)) { return NotFound(); } else { throw; } } return NoContent(); }
public async Task <WildApricotToken> SetTokenAsync(WildApricotToken respToken, bool updateToken) { if (updateToken) { respToken.AccessToken = respToken.AccessToken; respToken.TokenExpires = respToken.TokenExpires; await _context.SaveChangesAsync(); } else { try { _context.WaTokens.Add(respToken); await _context.SaveChangesAsync(); } catch (Exception e) { Console.WriteLine(e); throw; } } return(respToken); }
public async Task <IActionResult> PutEvent([FromRoute] int id, [FromBody] Event @event) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != @event.Id) { return(BadRequest()); } _context.Entry(@event).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EventExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <Event> CreateEvent(Event newEvent) { await _context.AddAsync(newEvent); await _context.SaveChangesAsync(); return(newEvent); }
public async Task <Day> CreateDayAsync(Day newDay) { await _context.AddAsync(newDay); await _context.SaveChangesAsync(); return(newDay); }
public async Task <Speaker> CreateSpeakerAsync(Speaker newSpeaker) { await _context.AddAsync(newSpeaker); await _context.SaveChangesAsync(); return(newSpeaker); }
public async Task <EventRegistrationAudit> CreateEventRegistrationAudit(Registration newEventRegistration) { var newRegistrationAudit = new EventRegistrationAudit { EventId = newEventRegistration.EventId.ToString(), RegistrationTypeId = newEventRegistration.RegistrationTypeId.ToString(), FirstName = newEventRegistration.FirstName, LastName = newEventRegistration.LastName, Email = newEventRegistration.Email, Modified = DateTime.Now, Status = "Starting" }; await _context.AddAsync(newRegistrationAudit); await _context.SaveChangesAsync(); return(newRegistrationAudit); }