Example #1
0
        public IActionResult Create([FromBody] TimesheetDto timesheetDto)
        {
            // map dto to entity
            var timesheet = _mapper.Map <Timesheet>(timesheetDto);

            try
            {
                // save
                _timesheetService.Create(timesheet);
                return(Ok(timesheet.IdTimesheet));
            }
            catch (AppException ex)
            {
                // return error message if there was an exception
                return(BadRequest(new { message = ex.Message }));
            }
        }