public async Task <TimeSheetDto> AddTimeSheetAsync(TimeSheetDto model)
        {
            var dataTimeSheet  = new TimeSheet();
            var timeSheetModel = mapper.Map(model, dataTimeSheet);
            await context.TimeSheets.AddAsync(timeSheetModel);

            await context.SaveChangesAsync();

            return(mapper.Map <TimeSheetDto>(timeSheetModel));
        }
        public async Task <bool> UpdateTimeSheetAsync(TimeSheetDto model)
        {
            var datatimesheet = await context.TimeSheets.FirstOrDefaultAsync(s => s.EmployeeId == model.EmployeeId);

            if (datatimesheet is not null)
            {
                mapper.Map(model, datatimesheet);
                await context.SaveChangesAsync();

                return(true);
            }
            return(false);
        }
        public async Task <ActionResult <TimeSheetDto> > Post([FromBody] TimeSheetDto model)
        {
            try
            {
                var Location = linkGenerator.GetPathByAction("GetTimeSheetById", "TimeSheet", new { id = model.EmployeeId });
                if (string.IsNullOrWhiteSpace(Location))
                {
                    return(BadRequest($"Could not find id path"));
                }

                var newTimeSheet = await timeSheetRepository.AddTimeSheetAsync(model);

                return(Created(Location, newTimeSheet));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new Response {
                    Status = "Error", Message = "An Error Occurred!"
                }));
            }
        }
        public async Task <ActionResult> Put([FromBody] TimeSheetDto model)
        {
            try
            {
                var updatedTimeSheet = await timeSheetRepository.UpdateTimeSheetAsync(model);

                if (updatedTimeSheet)
                {
                    return(Ok(new Response {
                        Status = "Success", Message = "The Update was Successful"
                    }));
                }
                return(BadRequest(new Response {
                    Status = "Unsuccessful", Message = "The Update was not Successful"
                }));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new Response {
                    Status = "Error", Message = "An Error Occurred!"
                }));
            }
        }