public async Task <IActionResult> CreateAsync([FromBody] TimesheetViewModel vmTimesheet) { var timesheet = mapper.Map <Timesheet>(vmTimesheet); var result = await timesheetRepo.CreateTimesheet(timesheet); return(CreatedAtAction(nameof(GetTimesheetAsync), new { id = result.TimesheetId }, mapper.Map <TimesheetViewModel>(result))); }
public IActionResult Start() { var userId = GetUserId(); var startTime = DateTime.Now; var existingTimesheet = _timesheetRepository.GetTimesheet(userId, startTime.Date); if (existingTimesheet != null) { return(BadRequest()); } var timesheet = new Timesheet { UserId = userId, Date = startTime.Date, StartTime = startTime.TimeOfDay, }; _timesheetRepository.CreateTimesheet(timesheet); var result = _mapper.Map <TimesheetResponse>(timesheet); CalculateFlexTime(result); return(Ok(result)); }