public IActionResult Create([FromBody] TimeZoneCreateModel model) { var currUser = _userService.GetById(Int32.Parse(User.Identity.Name)); // if an admin is inserting a row, it might be for any user so preserve the user id if (!_userService.CheckIf(currUser, Roles.ROLE_ADMIN)) { model.UserId = currUser.Id; } // map model to entity var timeZone = _mapper.Map <Entities.TimeZone>(model); try { _timeZoneService.Create(timeZone); return(Ok()); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } }