public async Task <IActionResult> GetTimesheetAsync(int id)
        {
            var timesheet = await timesheetRepo.GetTimesheet(id);

            if (timesheet != null)
            {
                return(Ok(mapper.Map <TimesheetViewModel>(timesheet)));
            }

            return(NotFound());
        }
        public async Task <ActionResult <Timesheet> > GetTimesheet(long timesheetId)
        {
            var timesheet = await _timesheetRepository.GetTimesheet(timesheetId);

            if (timesheet == null)
            {
                return(NotFound());
            }

            return(timesheet);
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
 // GET api/timesheets/5
 public Timesheet Get(int id)
 {
     return(_TimesheetRepository.GetTimesheet(id));
 }