Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #3
0
        public ResultSingleSerialData HandleUpdateEntity(string entitySetName, QueryParams queryParams, Dto dto)
        {
            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.ValidKeys(entityTypeName, queryObject.Keys, this.metadataSrv))
            {
                throw new DtosException(code: 400, message: "Bad Request");
            }
            if (!ApiProviderDtoUtils.ValidDto(entityTypeName, queryObject.Keys.FirstOrDefault(), dto, this.metadataSrv))
            {
                throw new DtosException(code: 400, message: "Bad Request");
            }
            var resultSingleSerialData = this.dataViewDto.UpdateItem(entityTypeName, DalUtils.Extend(dto, queryObject.Keys.FirstOrDefault()));

            return(resultSingleSerialData);
        }