Beispiel #1
0
        public IHttpActionResult Post(ExternalResourcePostRequest requestData)
        {
            var requestService = new Service.Utility.RequestDataHelper <ExternalResourcePostRequest>();
            var response       = new BaseResponse <List <ExternalResource> >();

            response.Success = false;
            response.Data    = new List <ExternalResource>();
            var checkColumnKeys = new string[2] {
                "token", "orgcode"
            };
            var checkDataEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKeys);

            if (checkDataEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var externalResourceService = new ExternalResourceService();
            var responseData            = externalResourceService.DataProxy(requestData);

            if (responseData == null)
            {
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                response.Message = "資料處理錯誤";
                return(Ok(response));
            }
            response.Success = true;
            response.Message = "資料處理成功";
            response.Data    = responseData;
            return(Ok(response));
        }
Beispiel #2
0
        public IHttpActionResult Get(string strAccess)
        {
            var requestData    = JsonConvert.DeserializeObject <BackendBaseRequest>(strAccess);
            var requestService = new Service.Utility.RequestDataHelper <BackendBaseRequest>();

            var response = new ResultBaseModel <ExternalResource>();

            response.Success = false;
            response.Data    = new ExternalResource[0];
            var checkColumnKeys = new string[1] {
                "token"
            };
            var checkDataEmpty = requestService.CheckColumnEmpty(requestData, checkColumnKeys);

            if (checkDataEmpty == false)
            {
                response.Message = "遺漏參數";
                response.State   = LogState.RequestDataError;
                return(Content(HttpStatusCode.BadRequest, response));
            }
            var externalResourceService = new ExternalResourceService();
            var responseData            = externalResourceService.GetListByRequest(requestData);

            if (responseData == null)
            {
                response.Message = "查詢失敗";
                response.State   = Infrastructure.ViewModel.Base.LogState.Error;
                return(Ok(response));
            }
            response.Message = "查詢成功";
            response.Success = true;
            response.Data    = responseData.ToArray();
            return(Ok(response));
        }