public async Task <IActionResult> UpdateAsync([FromBody] UpdateTimesheetRequest request) { Logger.LogInformation($"Calling api Create Timesheet with Json : {JsonConvert.SerializeObject(request)}"); await _timesheetService.UpdateAsync(request); Logger.LogInformation("Updated successfully."); return(Ok(await Result.SuccessAsync("Updated successfully."))); }
public async Task <int> UpdateAsync(UpdateTimesheetRequest request) { var timesheet = await _timesheetRepository.GetByIdAsync(request.Id); timesheet.ProjectId = request.ProjectId; timesheet.HourRate = request.HourRate; timesheet.Hours = request.Hours; timesheet.Activity = request.Activity; timesheet.Date = request.Date; timesheet.Comment = request.Comment; //if (request.EmployeeId == 0) //{ // var currentEmployee = await _employeeRepository.FirstOrDefaultAsync(x => x.SystemUserId.Equals(_currentUserService.UserId)); // timesheet.EmployeeId = currentEmployee.Id; //} _timesheetRepository.Update(timesheet); return(await _unitOfWork.SaveChangesAsync()); }
public async Task <IResult> UpdateAsync(UpdateTimesheetRequest request) { var response = await _httpClient.PutAsJsonAsync(Routes.TimesheetEndpoint.Update, request); return(await response.ToResult()); }