Exemple #1
0
        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));
            }
        }
Exemple #2
0
        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));
            }
        }