public IActionResult Register([FromBody] DaiLyDto dailyDto) { // map dto to entity var daily = _mapper.Map <DaiLy>(dailyDto); try { // save dai ly var flag = _dailyRepository.Create(daily); return(Ok(new { success = flag })); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } }
public IActionResult Update(int id, [FromBody] DaiLyDto dailyDto) { // map dto to entity and set id var daily = _mapper.Map <DaiLy>(dailyDto); daily.Id = id; try { // save // _userService.Update(user, userDto.Password); return(Ok()); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(new { message = ex.Message })); } }