public IHttpActionResult Update(int id, [FromBody] UserInfoCreateUpdate userInfo) { try { var oRequest = new ORequest(AccessTokenManager.ScopeUsers); if (!oRequest.IsApiAuthorized) { return(Unauthorized()); } if (userInfo == null) { return(BadRequest("Could not read user from body")); } if (!DataProvider.UserDao.ApiIsExists(id)) { return(NotFound()); } string errorMessage; var retval = DataProvider.UserDao.ApiUpdate(id, userInfo, out errorMessage); if (retval == null) { return(BadRequest(errorMessage)); } return(Ok(new OResponse(retval))); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }
public IHttpActionResult Create([FromBody] UserInfoCreateUpdate userInfo) { try { var oRequest = new ORequest(AccessTokenManager.ScopeUsers); if (!oRequest.IsApiAuthorized) { return(Unauthorized()); } string errorMessage; var retval = DataProvider.UserDao.ApiInsert(userInfo, PageUtils.GetIpAddress(), out errorMessage); if (retval == null) { return(BadRequest(errorMessage)); } return(Ok(new OResponse(retval))); } catch (Exception ex) { LogUtils.AddErrorLog(ex); return(InternalServerError(ex)); } }