public async Task <IActionResult> Post(HistoricoAssistencia historico) { _db.Add(historico); await _db.SaveChangesAsync(); return(Ok(historico)); }
public async Task <IActionResult> Put(HistoricoAssistencia historico) { _db.Entry(historico).State = EntityState.Modified; await _db.SaveChangesAsync(); return(Ok(historico)); }
private void AddExcelToDB(IExcelDataReader excelReader) { DataTable excelTable = excelReader.AsDataSet().Tables[0]; for (int i = 1; i < excelTable.Rows.Count; i++) { string msg = (string)excelTable.Rows[i].ItemArray[0]; string aeroporto = (string)excelTable.Rows[i].ItemArray[1]; string notif = (string)excelTable.Rows[i].ItemArray[2]; DateTime data = Convert.ToDateTime(excelTable.Rows[i].ItemArray[3] + " " + excelTable.Rows[i].ItemArray[4]); DateTime?dataContacto = IsItDateNull((string)excelTable.Rows[i].ItemArray[5], (string)excelTable.Rows[i].ItemArray[6]); DateTime?dataInicio = IsItDateNull((string)excelTable.Rows[i].ItemArray[7], (string)excelTable.Rows[i].ItemArray[8]); DateTime?dataFim = IsItDateNull((string)excelTable.Rows[i].ItemArray[9], (string)excelTable.Rows[i].ItemArray[10]); string voo = (string)excelTable.Rows[i].ItemArray[11]; string mov = (string)excelTable.Rows[i].ItemArray[12]; string origDest = (string)excelTable.Rows[i].ItemArray[13]; string pax = (string)excelTable.Rows[i].ItemArray[14]; string ssr = (string)excelTable.Rows[i].ItemArray[15]; string ac = (string)excelTable.Rows[i].ItemArray[16]; string stand = (string)excelTable.Rows[i].ItemArray[17]; string exit = (string)excelTable.Rows[i].ItemArray[18]; string ckIn = (string)excelTable.Rows[i].ItemArray[19]; string gate = (string)excelTable.Rows[i].ItemArray[20]; string transferencia = (string)excelTable.Rows[i].ItemArray[21]; HistoricoAssistencia currentExcel = new HistoricoAssistencia { Msg = msg, Aeroporto = aeroporto, Notif = notif, Data = data, DataContacto = dataContacto, DataInicio = dataInicio, DataFim = dataFim, Voo = voo, Mov = mov, OrigDest = origDest, Pax = pax, SSR = ssr, AC = ac, Stand = stand, Exit = exit, CkIn = ckIn, Gate = gate, Transferencia = transferencia }; DateTime?dataV = (DateTime)currentExcel.Data; string vooV = currentExcel.Voo; string paxV = currentExcel.Pax; if (!db.HistoricoAssistencias.Any(e => e.Data == dataV && e.Voo == vooV && e.Pax == paxV)) { db.HistoricoAssistencias.Add(currentExcel); } } db.SaveChanges(); }
public async Task <IActionResult> Delete(Guid id) { var historico = new HistoricoAssistencia { ID = id }; _db.Remove(historico); await _db.SaveChangesAsync(); return(NoContent()); }