Exemplo n.º 1
0
        public ResultSerialResponse HandleGet(string entitySetName, QueryParams queryParams)
        {
            entitySetName = ApiProviderDtoUtils.FixEntitySetNameCase(entitySetName, this.metadataSrv);
            var queryObject          = QueryUtils.RenderQueryObject(queryParams);
            var entityTypeName       = ApiProviderDtoUtils.GetEntityTypeName(entitySetName, this.metadataSrv);
            var resultSerialResponse = this.resultSerialUtils.FetchResponseData(entityTypeName, queryObject);

            return(resultSerialResponse);
        }
Exemplo n.º 2
0
        public List <ResultSingleSerialData> HandleInsertEntityBatch(string entitySetName, IEnumerable <Dto> dtos)
        {
            entitySetName = ApiProviderDtoUtils.FixEntitySetNameCase(entitySetName, this.metadataSrv);
            var entityTypeName = ApiProviderDtoUtils.GetEntityTypeName(entitySetName, this.metadataSrv);

            if (!ApiProviderDtoUtils.ValidKeys(entityTypeName, dtos, this.metadataSrv))
            {
                throw new DtosException(code: 400, message: "Bad Request");
            }
            var resultSingleSerialDataList = this.dataViewDto.InsertItems(entityTypeName, dtos);

            return(resultSingleSerialDataList);
        }
Exemplo n.º 3
0
        public ResultSingleSerialData HandleInsertEntity(string entitySetName, Dto dto)
        {
            entitySetName = ApiProviderDtoUtils.FixEntitySetNameCase(entitySetName, this.metadataSrv);
            var entityTypeName = ApiProviderDtoUtils.GetEntityTypeName(entitySetName, this.metadataSrv);

            if (!ApiProviderDtoUtils.ValidDtoKey(entityTypeName, dto, this.metadataSrv))
            {
                throw new DtosException(code: 400, message: "Bad Request");
            }
            var resultSingleSerialData = this.dataViewDto.InsertItem(entityTypeName, dto);

            return(resultSingleSerialData);
        }
Exemplo n.º 4
0
        public ResultSerialData HandleGetMany(string entitySetName, QueryParams queryParams)
        {
            entitySetName = ApiProviderDtoUtils.FixEntitySetNameCase(entitySetName, this.metadataSrv);
            var queryObject    = QueryUtils.RenderQueryObject(queryParams);
            var entityTypeName = ApiProviderDtoUtils.GetEntityTypeName(entitySetName, this.metadataSrv);

            if (queryObject.Keys == null || queryObject.Keys.Count() == 0 || !ApiProviderDtoUtils.ValidKeys(entityTypeName, queryObject.Keys, this.metadataSrv))
            {
                throw new DtosException(code: 400, message: "Bad Request");
            }
            var resultSerialData = this.dataViewDto.GetMultipleItems(entityTypeName, queryObject.Keys, queryObject.Expand);

            return(resultSerialData);
        }
Exemplo n.º 5
0
        public ResultSingleSerialData HandleDeleteEntity(string entitySetName, QueryParams queryParams)
        {
            entitySetName = ApiProviderDtoUtils.FixEntitySetNameCase(entitySetName, this.metadataSrv);
            var queryObject    = QueryUtils.RenderQueryObject(queryParams);
            var entityTypeName = ApiProviderDtoUtils.GetEntityTypeName(entitySetName, this.metadataSrv);

            if (queryObject.Keys == null || queryObject.Keys.Count() != 1 || !ApiProviderDtoUtils.ValidDtoKey(entityTypeName, queryObject.Keys.FirstOrDefault(), this.metadataSrv))
            {
                throw new DtosException(code: 400, message: "Bad Request");
            }
            var resultSingleSerialData = this.dataViewDto.DeleteItem(entityTypeName, queryObject.Keys.FirstOrDefault());

            return(resultSingleSerialData);
        }