public async Task <IActionResult> PutCharacteristic(int id, Characteristic characteristic) { if (id != characteristic.Characteristicid) { return(BadRequest()); } _context.Entry(characteristic).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CharacteristicExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutHorse(int id, Horse horse) { if (id != horse.Horseid) { return(BadRequest()); } _context.Entry(horse).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HorseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEvent(int id, Event @event) { if (id != @event.Eventid) { return(BadRequest()); } var curEC = _context.Eventcharacteristic .Where(_ec => _ec.Eventid == @event.Eventid) .ToList(); var newEC = @event.Eventcharacteristic; _context.Eventcharacteristic.RemoveRange(curEC.Except(newEC)); _context.Eventcharacteristic.AddRange(newEC.Except(curEC)); var curEHC = _context.Eventhclass .Where(_ec => _ec.Eventid == @event.Eventid) .ToList(); var newEHC = @event.Eventhclass; _context.Eventhclass.RemoveRange(curEHC.Except(newEHC)); _context.Eventhclass.AddRange(newEHC.Except(curEHC)); var curEH = _context.Eventhorse .Where(_ec => _ec.Eventid == @event.Eventid) .ToList(); var newEH = @event.Eventhorse; _context.Eventhorse.RemoveRange(curEH.Except(newEH)); _context.Eventhorse.AddRange(newEH.Except(curEH)); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EventExists(id)) { return(NotFound()); } else { throw; } } _context.Entry(@event).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EventExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }