public async Task <bool> Insert(ITable ety) { BancoHorasTable dev = (BancoHorasTable)ety; var tt = context.BancoHoras.Where(x => x.Desenvolvedor == dev.Desenvolvedor); double acc = 0; foreach (var i in tt) { acc += (i.DataFim - i.DataIni).TotalHours; } var hora = new HorasAcomuladasDevTable() { Desenvolvedor = dev.Desenvolvedor, HorasAcomuladas = acc }; var coot = context.HorasAcomuladasDev.FirstOrDefault(x => x.Desenvolvedor == dev.Desenvolvedor); if (coot is null) { await context.HorasAcomuladasDev.AddAsync(hora); await context.SaveChangesAsync(); } else { await this.Update(hora); } return(true); }
public async Task <bool> Insert(ITable ety) { BancoHorasTable entity = (BancoHorasTable)ety; await context.BancoHoras.AddAsync(entity); await context.SaveChangesAsync(); return(true); }
public async Task <bool> Put(BancoHorasTable horas) { var res = await bancoCRUD.Update(horas); if (res is true) { return(true); } return(false); }
public async Task <ITable> GetOne(ITable ety, bool isId = true) { BancoHorasTable entity = (BancoHorasTable)ety; if (isId) { return(await context.BancoHoras.FirstOrDefaultAsync(x => x.Id == entity.Id)); } else { return(await context.BancoHoras.FirstOrDefaultAsync(x => x.Desenvolvedor == entity.Desenvolvedor)); } }
public async Task <bool> Post(BancoHorasTable horas) { var res = await bancoCRUD.Insert(horas); var res2 = await horasCrud.Insert(horas); if (res is true && res2 is true) { return(true); } return(false); }
public async Task <ActionResult <ITable> > One(BancoHorasTable ety) { try { var all = await bancoCRUD.GetOne(ety); return(Ok(all)); } catch (System.Exception) { return(BadRequest()); throw; } }
public async Task <bool> Update(ITable ety) { BancoHorasTable entity = (BancoHorasTable)ety; var res = context.BancoHoras.FirstOrDefault(x => x.DataId == entity.DataId); if (res is not null) { res.Desenvolvedor = entity.Desenvolvedor; res.DataIni = entity.DataIni; res.DataFim = entity.DataFim; await context.SaveChangesAsync(); return(true); } return(false); }
public async Task <ActionResult <ITable> > One(BancoHorasTable ety) { return(await horasCrud.GetOne(ety)); }