public async Task <IActionResult> PutEvento(int id, Evento evento) { if (id != evento.Id) { return(BadRequest()); } _context.Entry(evento).State = EntityState.Modified; Local local = _context.Locais.Find(evento.LocalId); local.NomeLocal = evento.Local.NomeLocal; local.Morada = evento.Local.Morada; local.Localidade = evento.Local.Localidade; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EventoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutTipo(int id, Tipo tipo) { if (id != tipo.Id) { return(BadRequest()); } _context.Entry(tipo).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TipoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutEvento(Guid id, Evento evento) { if (id != evento.Id) { return(BadRequest()); } _context.Entry(evento).State = EntityState.Modified; try { await unitOfWork.Commit(); unitOfWork.Dispose(); } catch (DbUpdateConcurrencyException) { if (!await EventoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }