Esempio n. 1
0
        public void ShouldExpectException_WhenConvertedExpressionHasWrongFieldName()
        {
            const string originalExpression =
                "Id eq 456 and Tags/any(t: t eq 'Dummy') and Details/Description eq 'Desc'";

            var fakeFieldMapper = new StubIFieldMapper()
            {
                MapStringStringString = (productPropertyName, propertyParentName, root) =>
                {
                    if (productPropertyName == "Id")
                    {
                        return("Id");
                    }
                    if (productPropertyName == "Tags" && string.IsNullOrEmpty(propertyParentName))
                    {
                        return("Tags");
                    }
                    if (productPropertyName == "Description" && propertyParentName == "Details")
                    {
                        return("DetailsDescription");
                    }
                    return("");
                }
            };
            var productEdmModel     = Product.GetEdmModel();
            var productDocsEdmModel = ProductDoc.GetProductsModel();

            _odataConverter = new ODataConverter(productEdmModel, typeof(Product), productDocsEdmModel, typeof(ProductDoc), fakeFieldMapper);
            var convertedExpression = _odataConverter.Convert(originalExpression);
        }
Esempio n. 2
0
        public ODataConverterTests()
        {
            _fieldMapper = new ProductFieldMapper();
            var productEdmModel     = Product.GetEdmModel();
            var productDocsEdmModel = ProductDoc.GetProductsModel();

            _odataConverter = new ODataConverter(productEdmModel, typeof(Product), productDocsEdmModel, typeof(ProductDoc), _fieldMapper);
        }
Esempio n. 3
0
        public ProductsController()
        {
            _queryService = new InMemoryProductsQueryService();

            var fieldMapper         = new ProductFieldMapper();
            var productEdmModel     = Product.GetEdmModel();
            var productDocsEdmModel = ProductDoc.GetProductsModel();

            _oDataConverter = new ODataConverter(productEdmModel, typeof(Product), productDocsEdmModel, typeof(ProductDoc), fieldMapper);
        }
Esempio n. 4
0
        public void Product(string ChannelId, string ChannelRef, string TransactionId, ProductDoc aProductDoc)
        {
            EnterProc();

            ProductInsert aProductHandler;

            try
            {
                MessageTransaction mt = BeginWebmethod(ChannelId, ChannelRef, TransactionId, "ART");

                try
                {
                    aProductHandler = new ProductInsert(this);
                }
                catch (Exception e)
                {
                    Exception InternalError = new Exception("InternalError: Building insert handler", e);
                    throw (InternalError);
                }

                try
                {
                    if (aProductDoc == null)
                    {
                        Exception InternalError = new Exception("DataError: Root object cannot be null");
                        throw (InternalError);
                    }
                    aProductHandler.Process(ref mt, null, aProductDoc);
                    GetDataBase().Commit();
                }
                catch (Exception e)
                {
                    try
                    {
                        GetDataBase().Rollback();
                    }
                    catch (Exception)
                    {}
                    Exception InternalError = new Exception("DataError: Error processing data", e);
                    throw (InternalError);
                }
            }

            finally
            {
                EndWebmethod();
            }

            ExitProc();

            return;
        }