コード例 #1
0
        private static IEdmModel GetModel(WebRouteConfiguration config)
        {
            ODataModelBuilder builder = config.CreateConventionModelBuilder();
            EntitySetConfiguration <ActionProduct> products = builder.EntitySet <ActionProduct>("Products");
            ActionConfiguration productsByCategory          = products.EntityType.Action("GetProductsByCategory");
            ActionConfiguration getSpecialProduct           = products.EntityType.Action("GetSpecialProduct");

            productsByCategory.ReturnsCollectionFromEntitySet <ActionProduct>(products);
            getSpecialProduct.ReturnsFromEntitySet <ActionProduct>(products);
            return(builder.GetEdmModel());
        }
コード例 #2
0
        public override Task <ODataConventionModelBuilder> Run(
            ODataConventionModelBuilder modelBuilder,
            CommercePipelineExecutionContext context)
        {
            Condition.Requires(modelBuilder).IsNotNull(this.Name + ": The argument cannot be null.");

            ActionConfiguration composerTemplatesByIdsActions = modelBuilder.Action("ComposerTemplatesByIds");

            composerTemplatesByIdsActions.CollectionParameter <string>("rawIds");
            composerTemplatesByIdsActions.ReturnsCollectionFromEntitySet <ComposerTemplate>("ComposerTemplates");

            return(Task.FromResult(modelBuilder));
        }
コード例 #3
0
ファイル: ODataConfig.cs プロジェクト: maurbone/DocSuitePA
        private static void MapCustomModules(ODataModelBuilder builder)
        {
            builder
            .EntitySet <MenuModel>("AUSLRE_BandiDiGaraMenu")
            .EntityType.HasKey(p => p.UniqueId);

            builder
            .EntitySet <ArchiveModel>("AUSLRE_BandiDiGaraArchives")
            .EntityType.HasKey(p => p.UniqueId);

            #region [ Functions ]
            FunctionConfiguration getMenu = builder
                                            .EntityType <MenuModel>().Collection
                                            .Function("GetMenu");

            getMenu.Namespace = "MenuModelService";
            getMenu.ReturnsCollectionFromEntitySet <MenuModel>("AUSLRE_BandiDiGaraMenu");

            ActionConfiguration countArchiveByGrid = builder
                                                     .EntityType <ArchiveModel>().Collection
                                                     .Action("CountArchiveByGrid");

            countArchiveByGrid.Namespace = "ArchiveModelService";
            countArchiveByGrid.ReturnsCollectionFromEntitySet <ArchiveModel>("AUSLRE_BandiDiGaraArchives");
            countArchiveByGrid.Parameter <ArchiveFinderModel>("finder");

            ActionConfiguration searchArchiveByGrid = builder
                                                      .EntityType <ArchiveModel>().Collection
                                                      .Action("SearchArchiveByGrid");

            searchArchiveByGrid.Namespace = "ArchiveModelService";
            searchArchiveByGrid.ReturnsCollectionFromEntitySet <ArchiveModel>("AUSLRE_BandiDiGaraArchives");
            searchArchiveByGrid.Parameter <ArchiveFinderModel>("finder");


            FunctionConfiguration getArchiveInfo = builder
                                                   .EntityType <ArchiveModel>().Collection
                                                   .Function("GetArchiveInfo");

            getArchiveInfo.Namespace = "ArchiveModelService";
            getArchiveInfo.Parameter <Guid>("uniqueId");
            getArchiveInfo.ReturnsCollectionFromEntitySet <ArchiveModel>("AUSLRE_BandiDiGaraArchives");
            #endregion

            #region [ Navigation Properties ]

            #endregion
        }
コード例 #4
0
        // Builds the EDM model for the OData service, including the OData action definitions.
        private static IEdmModel GetEdmModel()
        {
            var modelBuilder    = new ODataConventionModelBuilder();
            var moviesEntitySet = modelBuilder.EntitySet <Movie>("Movies");

            // Now add actions.
            // http://odata.github.io/WebApi/#02-03-model-builder-nonconvention

            // CheckOut
            // URI: ~/odata/Movies(1)/ODataActionSample.Models.CheckOut
            ActionConfiguration checkOutAction = modelBuilder.EntityType <Movie>().Action("CheckOut");

            checkOutAction.ReturnsFromEntitySet <Movie>("Movies");

            // ReturnMovie
            // URI: ~/odata/Movies(1)/ODataActionSample.Models.Return
            // Binds to a single entity; no parameters.
            ActionConfiguration returnAction = modelBuilder.EntityType <Movie>().Action("Return");

            returnAction.ReturnsFromEntitySet <Movie>("Movies");

            // CheckOutMany action
            // URI: ~/odata/Movies/ODataActionSample.Models.CheckOutMany
            // Binds to a collection of entities.  This action accepts a collection of parameters.
            ActionConfiguration checkOutManyAction = modelBuilder.EntityType <Movie>().Collection.Action("CheckOutMany");

            checkOutManyAction.CollectionParameter <int>("MovieIDs");
            checkOutManyAction.ReturnsCollectionFromEntitySet <Movie>("Movies");

            // CreateMovie action
            // URI: ~/odata/CreateMovie
            // Unbound action. It is invoked from the service root.
            ActionConfiguration createMovieAction = modelBuilder.Action("CreateMovie");

            createMovieAction.Parameter <string>("Title");
            createMovieAction.ReturnsFromEntitySet <Movie>("Movies");

            modelBuilder.Namespace = typeof(Movie).Namespace;
            return(modelBuilder.GetEdmModel());
        }
コード例 #5
0
        // Builds the EDM model for the OData service, including the OData action definitions.
        private static IEdmModel GetModel()
        {
            ODataModelBuilder modelBuilder = new ODataConventionModelBuilder();
            var moviesEntitySet            = modelBuilder.EntitySet <Movie>("Movies");

            moviesEntitySet.EntityType.Ignore(m => m.TimeStamp);    // Don't expose timestamp to clients

            // Now add actions to the EDM.

            // CheckOut
            // URI: ~/odata/Movies(1)/CheckOut
            // Transient action. It is not available when the item is already checked out.
            ActionConfiguration checkout = modelBuilder.Entity <Movie>().TransientAction("CheckOut");

            // Provide a function that returns a link to the action, when the action is available, or
            // returns null when the action is not available.
            checkout.HasActionLink(ctx =>
            {
                Movie movie = ctx.EntityInstance as Movie;

                // Note: In some cases, checking whether the action is available may be relatively expensive.
                // For example, it might require a DB lookup.

                // Avoid doing expensive checks inside a loop (i.e., when serializing a feed). Instead, simply
                // mark the action as available, by returning an action link.

                // The SkipExpensiveAvailabilityChecks flag says whether to skip expensive checks. If this flag
                // is true AND your availability check is expensive, skip the check and return a link.

                // In this sample, the check is not really expensive, but we honor the flag to show how it works.
                bool createLink = true;
                if (ctx.SkipExpensiveAvailabilityChecks)
                {
                    // Caller asked us to skip the availability check.
                    createLink = true;
                }
                else if (!movie.IsCheckedOut) // Here is the "expensive" check
                {
                    createLink = true;
                }

                if (createLink)
                {
                    // Return the URI of the action.
                    return(new Uri(ctx.Url.CreateODataLink(
                                       new EntitySetPathSegment(ctx.EntitySet),
                                       new KeyValuePathSegment(ODataUriUtils.ConvertToUriLiteral(movie.ID, ODataVersion.V3)),
                                       new ActionPathSegment(checkout.Name))));
                }
                else
                {
                    return(null);
                }
            }, followsConventions: true);   // "followsConventions" means the action follows OData conventions.
            checkout.ReturnsFromEntitySet <Movie>("Movies");

            // ReturnMovie
            // URI: ~/odata/Movies(1)/Return
            // Always bindable. If the movie is not checked out, the action is a no-op.
            // Binds to a single entity; no parameters.
            var returnAction = modelBuilder.Entity <Movie>().Action("Return");

            returnAction.ReturnsFromEntitySet <Movie>("Movies");

            // SetDueDate action
            // URI: ~/odata/Movies(1)/SetDueDate
            // Binds to a single entity; takes an action parameter.
            var setDueDate = modelBuilder.Entity <Movie>().Action("SetDueDate");

            setDueDate.Parameter <DateTime>("DueDate");
            setDueDate.ReturnsFromEntitySet <Movie>("Movies");

            // CheckOut action
            // URI: ~/odata/Movies/CheckOut
            // Shows how to bind to a collection, instead of a single entity.
            // This action also accepts $filter queries. For example:
            //     ~/odata/Movies/CheckOut?$filter=Year eq 2005
            var checkOutFromCollection = modelBuilder.Entity <Movie>().Collection.Action("CheckOut");

            checkOutFromCollection.ReturnsCollectionFromEntitySet <Movie>("Movies");

            // CheckOutMany action
            // URI: ~/odata/Movies/CheckOutMany
            // Shows an action that takes a collection parameter.
            ActionConfiguration checkoutMany = modelBuilder.Entity <Movie>().Collection.Action("CheckOutMany");

            checkoutMany.CollectionParameter <int>("MovieIDs");
            checkoutMany.ReturnsCollectionFromEntitySet <Movie>("Movies");

            // CreateMovie action
            // URI: ~/odata/CreateMovie
            // Non-bindable action. You invoke it from the service root.
            ActionConfiguration createMovie = modelBuilder.Action("CreateMovie");

            createMovie.Parameter <string>("Title");
            createMovie.ReturnsFromEntitySet <Movie>("Movies");

            return(modelBuilder.GetEdmModel());
        }
コード例 #6
0
        public void CanCreateActionWithEntityReturnType()
        {
            // Arrange
            // Act
            ODataModelBuilder builder = new ODataModelBuilder();

            ActionConfiguration createGoodCustomer = new ActionConfiguration(builder, "CreateGoodCustomer");
            createGoodCustomer.ReturnsFromEntitySet<Customer>("GoodCustomers");

            ActionConfiguration createBadCustomers = new ActionConfiguration(builder, "CreateBadCustomers");
            createBadCustomers.ReturnsCollectionFromEntitySet<Customer>("BadCustomers");

            // Assert
            IEntityTypeConfiguration customer = createGoodCustomer.ReturnType as IEntityTypeConfiguration;
            Assert.NotNull(customer);
            Assert.Equal(typeof(Customer).FullName, customer.FullName);
            IEntitySetConfiguration goodCustomers = builder.EntitySets.SingleOrDefault(s => s.Name == "GoodCustomers");
            Assert.NotNull(goodCustomers);
            Assert.Same(createGoodCustomer.EntitySet, goodCustomers);

            ICollectionTypeConfiguration customers = createBadCustomers.ReturnType as ICollectionTypeConfiguration;
            Assert.NotNull(customers);
            customer = customers.ElementType as IEntityTypeConfiguration;
            Assert.NotNull(customer);
            IEntitySetConfiguration badCustomers = builder.EntitySets.SingleOrDefault(s => s.Name == "BadCustomers");
            Assert.NotNull(badCustomers);
            Assert.Same(createBadCustomers.EntitySet, badCustomers);
        }
コード例 #7
0
        public static IEdmModel GetEdmModel(ODataConventionModelBuilder builder)
        {
            builder.EntitySet <ConventionCustomer>("ConventionCustomers");
            builder.EntitySet <ConventionOrder>("ConventionOrders");

            EnumTypeConfiguration <ConventionGender> enumType = builder.EnumType <ConventionGender>();

            enumType.Member(ConventionGender.Female);
            enumType.Member(ConventionGender.Male);
            #region functions

            FunctionConfiguration getAllCustomers = builder.Function("GetAllConventionCustomers");
            getAllCustomers.ReturnsCollectionFromEntitySet <ConventionCustomer>("ConventionCustomers");
            getAllCustomers.IsComposable = true;

            // Return all the customers whose name contains CustomerName
            FunctionConfiguration getAllCustomersOverload = builder.Function("GetAllConventionCustomers");
            getAllCustomersOverload.ReturnsCollectionFromEntitySet <ConventionCustomer>("ConventionCustomers");
            getAllCustomersOverload.Parameter <string>("CustomerName");
            getAllCustomersOverload.IsComposable = true;

            FunctionConfiguration getCustomersById = builder.Function("GetConventionCustomerById");
            getCustomersById.Parameter <int>("CustomerId");
            getCustomersById.ReturnsFromEntitySet <ConventionCustomer>("ConventionCustomers");
            getCustomersById.IsComposable = true;

            FunctionConfiguration getOrder = builder.Function("GetConventionOrderByCustomerIdAndOrderName");
            getOrder.Parameter <int>("CustomerId");
            getOrder.Parameter <string>("OrderName");
            getOrder.ReturnsFromEntitySet <ConventionOrder>("ConventionOrders");

            FunctionConfiguration getCustomerNameById = builder.Function("GetConventionCustomerNameById");
            getCustomerNameById.Parameter <int>("CustomerId");
            getCustomerNameById.Returns <string>();

            FunctionConfiguration getDefinedGenders = builder.Function("GetDefinedGenders");
            getDefinedGenders.ReturnsCollection <ConventionGender>()
            .IsComposable = true;

            FunctionConfiguration function = builder.Function("AdvancedFunction").Returns <bool>();
            function.CollectionParameter <int>("nums");
            function.CollectionParameter <ConventionGender>("genders");
            function.Parameter <ConventionAddress>("location");
            function.CollectionParameter <ConventionAddress>("addresses");
            function.EntityParameter <ConventionCustomer>("customer");
            function.CollectionEntityParameter <ConventionCustomer>("customers");

            #endregion

            #region actions

            ActionConfiguration resetDataSource = builder.Action("ResetDataSource");

            // bug: error message:  non-binding parameter type must be either Primitive, Complex, Collection of Primitive or a Collection of Complex.

            /*
             * ActionConfiguration createCustomer = builder.Action("CreateCustomer");
             * createCustomer.Parameter<ConventionCustomer>("Customer");
             * createCustomer.ReturnsFromEntitySet<ConventionCustomer>("ConventionCustomers");
             */

            ActionConfiguration udpateAddress = builder.Action("UpdateAddress");
            udpateAddress.Parameter <ConventionAddress>("Address");
            udpateAddress.Parameter <int>("ID");
            udpateAddress.ReturnsCollectionFromEntitySet <ConventionCustomer>("ConventionCustomers");

            ActionConfiguration action = builder.Action("AdvancedAction");
            action.CollectionParameter <int>("nums");
            action.CollectionParameter <ConventionGender>("genders");
            action.Parameter <ConventionAddress>("location");
            action.CollectionParameter <ConventionAddress>("addresses");
            action.EntityParameter <ConventionCustomer>("customer");
            action.CollectionEntityParameter <ConventionCustomer>("customers");

            #endregion

            var schemaNamespace = typeof(ConventionCustomer).Namespace;

            builder.Namespace = schemaNamespace;

            var edmModel  = builder.GetEdmModel();
            var container = edmModel.EntityContainer as EdmEntityContainer;

            #region function imports

            var entitySet = container.FindEntitySet("ConventionCustomers");
            var getCustomersByIdOfEdmFunction = edmModel.FindDeclaredOperations(schemaNamespace + ".GetConventionCustomerById").First() as EdmFunction;
            container.AddFunctionImport("GetConventionCustomerByIdImport", getCustomersByIdOfEdmFunction, new EdmPathExpression(entitySet.Name));

            var functionsOfGetAllConventionCustomers   = edmModel.FindDeclaredOperations(schemaNamespace + ".GetAllConventionCustomers");
            var getAllConventionCustomersOfEdmFunction = functionsOfGetAllConventionCustomers.FirstOrDefault(f => f.Parameters.Count() == 0) as EdmFunction;
            container.AddFunctionImport("GetAllConventionCustomersImport", getAllConventionCustomersOfEdmFunction, new EdmPathExpression(entitySet.Name));

            // TODO delete this overload after bug 1640 is fixed: It can not find the correct overload function if the the function is exposed as a function import.
            var getAllConventionCustomersOverloadOfEdmFunction = functionsOfGetAllConventionCustomers.FirstOrDefault(f => f.Parameters.Count() > 0) as EdmFunction;
            container.AddFunctionImport("GetAllConventionCustomersImport", getAllConventionCustomersOverloadOfEdmFunction, new EdmPathExpression(entitySet.Name));

            var entitySet1 = container.FindEntitySet("ConventionOrders");
            var GetConventionOrderByCustomerIdAndOrderNameOfEdmFunction = edmModel.FindDeclaredOperations(schemaNamespace + ".GetConventionOrderByCustomerIdAndOrderName").First() as EdmFunction;
            container.AddFunctionImport("GetConventionOrderByCustomerIdAndOrderNameImport", GetConventionOrderByCustomerIdAndOrderNameOfEdmFunction, new EdmPathExpression(entitySet1.Name));

            var getConventionCustomerNameByIdOfEdmFunction = edmModel.FindDeclaredOperations(schemaNamespace + ".GetConventionCustomerNameById").First() as EdmFunction;
            container.AddFunctionImport("GetConventionCustomerNameByIdImport", getConventionCustomerNameByIdOfEdmFunction, null);

            #endregion

            #region action imports

            var resetDataSourceOfEdmAction = edmModel.FindDeclaredOperations(schemaNamespace + ".ResetDataSource").FirstOrDefault() as EdmAction;
            container.AddActionImport("ResetDataSourceImport", resetDataSourceOfEdmAction);

            // TODO: it is a potential issue that entity can not be used as an un-bound parameter.

            /*
             * var createCustomerOfEdmAction = edmModel.FindDeclaredOperations(schemaNamespace + ".CreateCustomer").FirstOrDefault() as EdmAction;
             * container.AddActionImport("CreateCustomerImport", createCustomerOfEdmAction);
             */
            var updateAddressOfEdmAction = edmModel.FindDeclaredOperations(schemaNamespace + ".UpdateAddress").FirstOrDefault() as EdmAction;
            container.AddActionImport("UpdateAddressImport", updateAddressOfEdmAction, new EdmPathExpression(entitySet.Name));

            #endregion

            return(edmModel);
        }
        // Builds the EDM model for the OData service, including the OData action definitions.
        private static IEdmModel GetEdmModel()
        {
            var modelBuilder = new ODataConventionModelBuilder();

            modelBuilder.EntitySet <Vedio>("Vedios");

            ActionConfiguration returnAcAction = modelBuilder.Action("ReturnAc");

            returnAcAction.Parameter <int>("key");
            returnAcAction.ReturnsFromEntitySet <Vedio>("Vedios");

            FunctionConfiguration checkOutAction = modelBuilder.Function("CheckOut");

            checkOutAction.Parameter <int>("key");
            checkOutAction.ReturnsFromEntitySet <Vedio>("Vedios");

            ActionConfiguration createMovieAction = modelBuilder.Action("CreateVedio");

            createMovieAction.Parameter <Vedio>("vedio");
            createMovieAction.ReturnsFromEntitySet <Vedio>("Vedios");

            ActionConfiguration ListAcAction = modelBuilder.Action("ListAc");

            ListAcAction.Parameter <Window>("windows");
            ListAcAction.Returns <int>();

            ActionConfiguration checkOutManyAction = modelBuilder.Action("CheckOutMany");

            checkOutManyAction.CollectionParameter <int>("MovieIDs");
            checkOutManyAction.ReturnsCollectionFromEntitySet <Vedio>("Vedios");

            //######################################################################################################//
            modelBuilder.EntitySet <QueryResult>("QueryResults");

            FunctionConfiguration GetRunningTasks = modelBuilder.Function("GetRunningTasks");

            GetRunningTasks.Parameter <QueryEntity>("query");
            GetRunningTasks.ReturnsCollectionFromEntitySet <QueryResult>("QueryResults");

            FunctionConfiguration GetReadyTasks = modelBuilder.Function("GetReadyTasks");

            GetReadyTasks.Parameter <QueryEntity>("query");
            GetReadyTasks.ReturnsCollectionFromEntitySet <QueryResult>("QueryResults");

            //######################################################################################################//

            ActionConfiguration StartProcess = modelBuilder.Action("StartProcess");

            StartProcess.Parameter <WfRunner>("WfRunner");
            StartProcess.Returns <int>();

            ActionConfiguration RunProcess = modelBuilder.Action("RunProcess");

            RunProcess.Parameter <WfRunner>("WfRunner");
            RunProcess.Returns <string>();

            ActionConfiguration WithdrawProcess = modelBuilder.Action("WithdrawProcess");

            WithdrawProcess.Parameter <WfRunner>("WfRunner");
            WithdrawProcess.Returns <string>();

            ActionConfiguration SendBackProcess = modelBuilder.Action("SendBackProcess");

            SendBackProcess.Parameter <WfRunner>("WfRunner");
            SendBackProcess.Returns <string>();

            ActionConfiguration JumpProcess = modelBuilder.Action("JumpProcess");

            JumpProcess.Parameter <WfRunner>("WfRunner");
            JumpProcess.Returns <string>();

            ActionConfiguration ReverseProcess = modelBuilder.Action("ReverseProcess");

            ReverseProcess.Parameter <WfRunner>("WfRunner");
            ReverseProcess.Returns <string>();

            ActionConfiguration DiscardProcess = modelBuilder.Action("DiscardProcess");

            DiscardProcess.Parameter <WfRunner>("WfRunner");
            DiscardProcess.Returns <string>();

            modelBuilder.Namespace = "WF";
            return(modelBuilder.GetEdmModel());
        }
コード例 #9
0
ファイル: WebApiConfig.cs プロジェクト: Ocumian/AEOnline
        public static void Register(HttpConfiguration config)
        {
            // Configuración y servicios de API web

            // Rutas de API web
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );



            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();

            builder.EntitySet <Alerta>("Alertas");
            builder.EntitySet <GrupoFlota>("GrupoFlota");
            builder.EntitySet <HistorialCargaCombustible>("HistorialesCargaCombustible");
            builder.EntitySet <HistorialIncidente>("HistorialesIncidente");
            builder.EntitySet <HistorialMantencion>("HistorialesMantencion");
            builder.EntitySet <Proveedor>("Proveedores");
            builder.EntitySet <Recordatorio>("Recordatorio");
            builder.EntitySet <Servicio>("Servicios");
            builder.EntitySet <TipoVehiculo>("TipoVehiculo");
            builder.EntitySet <Usuario>("Usuarios");
            builder.EntitySet <Flota>("Flotas");
            builder.EntitySet <Auto>("Autos");
            builder.EntitySet <Operador>("Operadores");
            builder.EntitySet <UsuarioFlota>("UsuarioFlotas");
            builder.EntitySet <HistorialDiario>("HistorialesDiarios");
            builder.EntitySet <HistorialVelocidad>("HistorialVelocidades");
            builder.EntitySet <HistorialPosicion>("HistorialPosiciones");
            builder.EntitySet <HistorialEnergia>("HistorialesEnergia");
            builder.EntitySet <MantencionServicio>("MantencionServicios");

            #region Actions testeos

            ActionConfiguration obtCalle = builder.Entity <Usuario>().Collection.Action("NombreCalle");
            obtCalle.Parameter <double>("lat");
            obtCalle.Parameter <double>("lng");
            obtCalle.Returns <string>();

            ActionConfiguration obtDireccion = builder.Entity <Usuario>().Collection.Action("ObtenerDireccion");
            obtDireccion.Parameter <double>("latInicio");
            obtDireccion.Parameter <double>("lngInicio");
            obtDireccion.Parameter <double>("latFinal");
            obtDireccion.Parameter <double>("lngFinal");
            obtDireccion.Returns <GDirections>();

            ActionConfiguration fechaHoy = builder.Entity <Auto>().Collection.Action("FechaHoy");
            fechaHoy.Returns <DateTime>();

            ActionConfiguration distanciaPuntos = builder.Entity <Auto>().Collection.Action("DistanciaPuntos");
            distanciaPuntos.Parameter <double>("latInicio");
            distanciaPuntos.Parameter <double>("lngInicio");
            distanciaPuntos.Parameter <double>("latFinal");
            distanciaPuntos.Parameter <double>("lngFinal");
            distanciaPuntos.Returns <double>();

            #endregion


            #region Actions Usuario

            ActionConfiguration crearCuentaUsuario = builder.Entity <Usuario>().Collection.Action("CrearCuentaUsuario");
            crearCuentaUsuario.Returns <RespuestaOdata>();
            crearCuentaUsuario.Parameter <string>("Nombre");
            crearCuentaUsuario.Parameter <string>("Email");
            crearCuentaUsuario.Parameter <string>("Password");

            ActionConfiguration inicioSesion = builder.Entity <Usuario>().Collection.Action("IniciarSesion");
            inicioSesion.Returns <RespuestaOdata>();
            inicioSesion.Parameter <string>("Email");
            inicioSesion.Parameter <string>("Password");

            ActionConfiguration proveedorsActivos = builder.Entity <Usuario>().Collection.Action("ProveedoresActuales");
            proveedorsActivos.ReturnsCollectionFromEntitySet <Proveedor>("Proveedores");
            proveedorsActivos.Parameter <int>("IdAuto");

            ActionConfiguration cargarCombustible = builder.Entity <Usuario>().Collection.Action("CargarCombustible");
            cargarCombustible.Returns <RespuestaOdata>();
            cargarCombustible.Parameter <int>("IdAuto");
            cargarCombustible.Parameter <string>("FechaHora");
            cargarCombustible.Parameter <bool>("EstanqueLleno");
            cargarCombustible.Parameter <float>("CantidadLitros");
            cargarCombustible.Parameter <int>("CostoUnitario");
            cargarCombustible.Parameter <int>("Kilometraje");
            cargarCombustible.Parameter <int>("IdProveedor");
            cargarCombustible.Parameter <string>("RutProveedor");
            cargarCombustible.Parameter <int>("NumeroBoleta");

            #endregion

            #region Actions AUTO

            ActionConfiguration fechaEjemplo = builder.Entity <Auto>().Collection.Action("FechaEjemplo");
            fechaEjemplo.Returns <string>();
            fechaEjemplo.Parameter <string>("Fecha");

            ActionConfiguration asignarPatente = builder.Entity <Auto>().Collection.Action("AsignarPatente");
            asignarPatente.Returns <RespuestaOdata>();
            asignarPatente.Parameter <string>("NuevaPatente");
            asignarPatente.Parameter <string>("Email");
            asignarPatente.Parameter <string>("Password");


            ActionConfiguration actualizarVelocidadListaDX = builder.Entity <Auto>().Collection.Action("ActualizarVelocidadListaDX");
            actualizarVelocidadListaDX.Returns <string>();
            actualizarVelocidadListaDX.Parameter <int>("Id");
            actualizarVelocidadListaDX.CollectionParameter <RegistroHistorial>("Registros");


            ActionConfiguration actualizarEnergia = builder.Entity <Auto>().Collection.Action("ActualizarEnergia");
            actualizarEnergia.Returns <IHttpActionResult>();
            actualizarEnergia.Parameter <int>("Id");
            actualizarEnergia.Parameter <string>("HoraRegistro");
            actualizarEnergia.Parameter <string>("HoraInicio");
            actualizarEnergia.Parameter <string>("HoraFinal");
            actualizarEnergia.Parameter <string>("HoraMenor");
            actualizarEnergia.Parameter <string>("HoraMayor");
            actualizarEnergia.Parameter <string>("HoraMitad");
            actualizarEnergia.Parameter <float>("ValorInicio");
            actualizarEnergia.Parameter <float>("ValorFinal");
            actualizarEnergia.Parameter <float>("ValorMenor");
            actualizarEnergia.Parameter <float>("ValorMayor");
            actualizarEnergia.Parameter <float>("ValorMitad");

            ActionConfiguration actualizarPosicionDX = builder.Entity <Auto>().Collection.Action("ActualizarPosicionListaDX");
            actualizarPosicionDX.Returns <string>();
            actualizarPosicionDX.Parameter <int>("Id");
            actualizarPosicionDX.CollectionParameter <Posicion>("ListaPosiciones");

            ActionConfiguration actualizarPosicionDXZ = builder.Entity <Auto>().Collection.Action("ActualizarPosicionListaDXZ");
            actualizarPosicionDXZ.Returns <string>();
            actualizarPosicionDXZ.Parameter <int>("Id");
            actualizarPosicionDXZ.CollectionParameter <Posicion>("ListaPosiciones");

            ActionConfiguration actualizarPosicionDXZgps = builder.Entity <Auto>().Collection.Action("ActualizarPosicionListaDXZGPS");
            actualizarPosicionDXZgps.Returns <string>();
            actualizarPosicionDXZgps.Parameter <int>("Id");
            actualizarPosicionDXZgps.CollectionParameter <Posicion>("ListaPosiciones");

            ActionConfiguration obtenerHistorialVel = builder.Entity <Auto>().Collection.Action("ObtenerHistorialesVelocidad");
            obtenerHistorialVel.ReturnsCollectionFromEntitySet <HistorialVelocidad>("HistorialVelocidades");
            obtenerHistorialVel.Parameter <int>("Id");
            obtenerHistorialVel.Parameter <string>("Fecha");

            ActionConfiguration obtenerHistorialPos = builder.Entity <Auto>().Collection.Action("ObtenerHistorialesPosicion");
            obtenerHistorialPos.ReturnsCollectionFromEntitySet <HistorialPosicion>("HistorialPosiciones");
            obtenerHistorialPos.Parameter <int>("Id");
            obtenerHistorialPos.Parameter <string>("FechaInicio");
            obtenerHistorialPos.Parameter <string>("FechaFinal");

            #endregion



            config.Routes.MapODataServiceRoute("odata", "odata", builder.GetEdmModel());
        }
コード例 #10
0
        public static void Register(HttpConfiguration config)
        {
            IList <IODataRoutingConvention> routingConventions = ODataRoutingConventions.CreateDefault();

            routingConventions.Insert(0, new CountODataRoutingConvention());


            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();

            builder.EntitySet <ApparatusType>("ApparatusTypes");
            builder.EntitySet <App>("Apps");

            builder.EntitySet <AppParam>("AppParams");
            builder.EntitySet <ProjectPart>("ProjectParts");
            builder.EntitySet <Remark>("Remarks");
            builder.EntitySet <TaskApp>("TaskApps");
            builder.EntitySet <MessureValue>("MessureValues");
            builder.EntitySet <CalculateValue>("CalculateValues");
            builder.EntitySet <Formula>("Formulae");

            ActionConfiguration rateProduct = builder.Entity <App>().Action("RateProduct");

            rateProduct.Parameter <int>("Rating");
            rateProduct.Returns <int>();


            ActionConfiguration actionRateAll = builder.Entity <App>().Collection.Action("RateAllProducts");

            actionRateAll.Parameter <int>("Rating");
            actionRateAll.Returns <int>();


            ActionConfiguration actionCheckExistData = builder.Entity <App>().Action("CheckExistData");

            actionCheckExistData.Parameter <DateTimeOffset>("date");
            actionCheckExistData.Returns <bool>();

            ActionConfiguration actionGetCalcValues = builder.Entity <App>().Collection.Action("GetCalcValues");

            actionGetCalcValues.Parameter <int>("topNum");
            actionGetCalcValues.Parameter <DateTimeOffset?>("startDate");
            actionGetCalcValues.Parameter <DateTimeOffset?>("endDate");
            actionGetCalcValues.CollectionParameter <Guid>("appids");
            actionGetCalcValues.ReturnsCollectionFromEntitySet <CalculateValue>("CalculateValues");


            ActionConfiguration actionGetMesValues = builder.Entity <App>().Collection.Action("GetMesValues");

            actionGetMesValues.Parameter <int>("topNum");
            actionGetMesValues.Parameter <DateTimeOffset?>("startDate");
            actionGetMesValues.Parameter <DateTimeOffset?>("endDate");
            actionGetMesValues.CollectionParameter <Guid>("appids");
            actionGetMesValues.ReturnsCollectionFromEntitySet <MessureValue>("MessureValues");


            ActionConfiguration actionGetRemarks = builder.Entity <App>().Collection.Action("GetRemarks");

            actionGetRemarks.Parameter <int>("topNum");
            actionGetRemarks.Parameter <DateTimeOffset?>("startDate");
            actionGetRemarks.Parameter <DateTimeOffset?>("endDate");
            actionGetRemarks.CollectionParameter <Guid>("appids");
            actionGetRemarks.ReturnsCollectionFromEntitySet <Remark>("Remarks");



            ActionConfiguration actionSearcyAppByName = builder.Entity <App>().Collection.Action("SearcyAppByName");

            actionSearcyAppByName.Parameter <string>("match");
            actionSearcyAppByName.ReturnsCollectionFromEntitySet <App>("Apps");

            ActionConfiguration actionSearcyAppCalcName = builder.Entity <App>().Collection.Action("SearcyAppCalcName");

            actionSearcyAppCalcName.Parameter <string>("match");
            actionSearcyAppCalcName.ReturnsCollectionFromEntitySet <App>("Apps");

            ActionConfiguration actionGetChildAppCalcName = builder.Entity <App>().Collection.Action("GetChildAppCalcName");

            actionGetChildAppCalcName.Parameter <string>("appCalcName");
            actionGetChildAppCalcName.Parameter <DateTimeOffset>("date");
            actionGetChildAppCalcName.ReturnsCollection <string>();


            ActionConfiguration actionGetAllFormulaeByAppID = builder.Entity <App>().Action("GetAllFormulaeByAppID");

            actionGetAllFormulaeByAppID.ReturnsCollectionFromEntitySet <Formula>("Formulae");


            ActionConfiguration actionUpdateAppsProject = builder.Entity <ProjectPart>().Action("UpdateAppsProject");

            actionUpdateAppsProject.CollectionParameter <Guid>("appids");
            actionUpdateAppsProject.Returns <bool>();


            ActionConfiguration actionUpdateAppsProjectByNames = builder.Entity <ProjectPart>().Action("UpdateAppsProjectByNames");

            actionUpdateAppsProjectByNames.CollectionParameter <string>("names");
            actionUpdateAppsProjectByNames.Returns <bool>();

            config.Routes.MapODataRoute("odata", "odata", builder.GetEdmModel(), new CountODataPathHandler(), routingConventions,
                                        new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer));



            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional });
        }