public async Task <IActionResult> GetHoursWorkedDetailById(Int64 IdDetallehorastrabajadas)
        {
            HoursWorkedDetail Items = new HoursWorkedDetail();

            try
            {
                Items = await _context.HoursWorkedDetail.Where(q => q.IdDetallehorastrabajadas == IdDetallehorastrabajadas).FirstOrDefaultAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(await Task.Run(() => BadRequest($"Ocurrio un error:{ex.Message}")));
            }


            return(Ok(Items));
        }
        public async Task <ActionResult <HoursWorkedDetail> > Insert([FromBody] HoursWorkedDetail _HoursWorkedDetail)
        {
            HoursWorkedDetail _HoursWorkedDetailq = new HoursWorkedDetail();

            try
            {
                _HoursWorkedDetailq = _HoursWorkedDetail;
                _context.HoursWorkedDetail.Add(_HoursWorkedDetailq);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(await Task.Run(() => BadRequest($"Ocurrio un error:{ex.Message}")));
            }

            return(await Task.Run(() => Ok(_HoursWorkedDetailq)));
        }
        public async Task <IActionResult> Delete([FromBody] HoursWorkedDetail _HoursWorkedDetail)
        {
            HoursWorkedDetail _HoursWorkedDetailq = new HoursWorkedDetail();

            try
            {
                _HoursWorkedDetailq = _context.HoursWorkedDetail
                                      .Where(x => x.IdDetallehorastrabajadas == (Int64)_HoursWorkedDetail.IdDetallehorastrabajadas)
                                      .FirstOrDefault();

                _context.HoursWorkedDetail.Remove(_HoursWorkedDetailq);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }

            return(await Task.Run(() => Ok(_HoursWorkedDetailq)));
        }
        public async Task <ActionResult <HoursWorkedDetail> > Update([FromBody] HoursWorkedDetail _HoursWorkedDetail)
        {
            HoursWorkedDetail _HoursWorkedDetailq = _HoursWorkedDetail;

            try
            {
                _HoursWorkedDetailq = await(from c in _context.HoursWorkedDetail
                                            .Where(q => q.IdDetallehorastrabajadas == _HoursWorkedDetail.IdDetallehorastrabajadas)
                                            select c
                                            ).FirstOrDefaultAsync();

                _context.Entry(_HoursWorkedDetailq).CurrentValues.SetValues((_HoursWorkedDetail));

                //_context.HoursWorkedDetail.Update(_HoursWorkedDetailq);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }

            return(await Task.Run(() => Ok(_HoursWorkedDetailq)));
        }