public async Task <IActionResult> Transfer([FromBody] TransferTask ent) { var tsk = await InitialQuery.SingleOrDefaultAsync(t => t.Id == ent.taskId); if (tsk == null) { return(NotFound()); } tsk.InterrompidoEm = DateTime.UtcNow; DbContext.Tarefa.Add(new Tarefa { AgendadaEm = tsk.AgendadaEm, IniciadoEm = tsk.IniciadoEm, FinalizadoEm = tsk.FinalizadoEm, Origem = tsk.Origem, Destino = ent.userId, TarefaEquipamentos = tsk.TarefaEquipamentos, TarefaMateriais = tsk.TarefaMateriais, Nome = tsk.Nome, RepetirEm = tsk.RepetirEm }); DbContext.Entry(tsk).State = EntityState.Modified; await DbContext.SaveChangesAsync(); return(StatusCode(StatusCodes.Status204NoContent)); }
public async Task <IActionResult> Rate([FromBody] RateTask ent) { var tsk = await InitialQuery.SingleOrDefaultAsync(t => t.Id == ent.taskId); tsk.Avaliacao = new TarefaAvaliacao { Nota = ent.rate, NotaMaxima = ent.rateMax }; DbContext.Entry(tsk).State = EntityState.Modified; await DbContext.SaveChangesAsync(); return(StatusCode(StatusCodes.Status204NoContent)); }
public async Task <IActionResult> Start(int id) { var tsk = await InitialQuery.SingleOrDefaultAsync(t => t.Id == id); if (tsk == null) { return(NotFound()); } tsk.IniciadoEm = DateTime.UtcNow; DbContext.Entry(tsk).State = EntityState.Modified; await DbContext.SaveChangesAsync(); return(Ok(new { ok = true })); }
public async Task <IActionResult> Read(int?id) { var alert = await InitialQuery.SingleOrDefaultAsync(a => a.Id == id); if (alert == null) { return(NotFound()); } alert.VisualizadaEm = DateTime.UtcNow; DbContext.Entry(alert).State = EntityState.Modified; await DbContext.SaveChangesAsync(); return(StatusCode(StatusCodes.Status204NoContent)); }