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