public override Task <ODataConventionModelBuilder> Run(ODataConventionModelBuilder arg, CommercePipelineExecutionContext context) { ActionConfiguration pricebookDownload = arg.Action("PriceBookDownload"); pricebookDownload.Returns <FileResult>(); return(Task.FromResult(arg)); }
public void Can_SetActionTitle_OnBindable_Actions() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); EntitySetConfiguration <Movie> movies = builder.EntitySet <Movie>("Movies"); movies.EntityType.HasKey(m => m.ID); ActionConfiguration entityAction = movies.EntityType.Action("Checkout"); entityAction.Returns <int>(); entityAction.Title = "Check out"; ActionConfiguration collectionAction = movies.EntityType.Collection.Action("RemoveOld"); collectionAction.Returns <int>(); collectionAction.Title = "Remove Old Movies"; // Act IEdmModel model = builder.GetEdmModel(); IEdmOperation checkout = model.FindOperations("Default.Checkout").Single(); IEdmOperation removeOld = model.FindOperations("Default.RemoveOld").Single(); OperationTitleAnnotation checkoutTitle = model.GetOperationTitleAnnotation(checkout); OperationTitleAnnotation removeOldTitle = model.GetOperationTitleAnnotation(removeOld); // Assert Assert.NotNull(checkoutTitle); Assert.Equal("Check out", checkoutTitle.Title); Assert.NotNull(removeOldTitle); Assert.Equal("Remove Old Movies", removeOldTitle.Title); }
public static void Register(HttpConfiguration config) { // Web API configuration and services // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); builder.EntitySet <Product>("Products"); builder.EntitySet <Supplier>("Suppliers"); builder.EntitySet <ProductRating>("Ratings"); //new code: Add an action to the EDM, and define the parameter and return type ActionConfiguration rateProduct = builder.Entity <Product>().Action("RateProduct"); rateProduct.Parameter <int>("Rating"); rateProduct.Returns <double>(); var rateAllProducts = builder.Entity <Product>().Collection.Action("RateAllProducts"); rateAllProducts.CollectionParameter <int>("Ratings"); config.Routes.MapODataRoute("odata", "odata", builder.GetEdmModel()); }
private static IEdmModel GetModel() { ODataModelBuilder builder = new ODataConventionModelBuilder(); EntitySetConfiguration <ActionProduct> products = builder.EntitySet <ActionProduct>("Products"); ActionConfiguration extendsSupportDate = products.EntityType.Action("ExtendsSupportDate"); extendsSupportDate.Returns <ActionProduct>(); return(builder.GetEdmModel()); }
private static void AddUnboundActionsAndFunctions(ODataModelBuilder odataModelBuilder) { odataModelBuilder.Action("ResetDataSource"); ActionConfiguration udpateAddress = odataModelBuilder.Action("UpdateAddressAction"); udpateAddress.Parameter <Address>("Address"); udpateAddress.Parameter <int>("ID"); udpateAddress.Returns <Address>(); }
public void CanCreateActionWithPrimitiveReturnType() { // Arrange // Act ODataModelBuilder builder = new ODataModelBuilder(); ActionConfiguration action = new ActionConfiguration(builder, "CreateMessage"); action.Returns<string>(); // Assert Assert.NotNull(action.ReturnType); Assert.Equal("Edm.String", action.ReturnType.FullName); }
private static void AddBoundActionsAndFunctions(EntityTypeConfiguration <Account> account) { account.Function("GetAddressFunction").Returns <Address>(); account.Function("GetShipAddresses").ReturnsCollection <Address>(); account.Action("IncreaseAgeAction").Returns <AccountInfo>(); ActionConfiguration addShipAddress = account.Action("AddShipAddress"); addShipAddress.Parameter <Address>("address"); addShipAddress.Returns <int>();// Total ship addresses count. }
public void CanCreateActionWithPrimitiveReturnType() { // Arrange // Act ODataModelBuilder builder = new ODataModelBuilder(); ActionConfiguration action = builder.Action("CreateMessage"); action.Returns <string>(); // Assert Assert.NotNull(action.ReturnType); Assert.Equal("Edm.String", action.ReturnType.FullName); }
public static void Register(HttpConfiguration config) { ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); builder.EntitySet <Product>("Products"); builder.EntitySet <Supplier>("Suppliers"); builder.EntitySet <ProductRating>("Ratings"); ActionConfiguration rateProduct = builder.Entity <Product>().Action("RateProduct"); rateProduct.Parameter <int>("Rating"); rateProduct.Returns <double>(); config.Routes.MapODataRoute("odata", "odata", builder.GetEdmModel()); }
public static void Register(HttpConfiguration config) { ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); builder.EntitySet <Product>("Products"); builder.EntitySet <Supplier>("Suppliers"); builder.EntitySet <ProductRating>("Ratings"); // New code: Add an action to the EDM, and define the parameter and return type. ActionConfiguration rateProduct = builder.Entity > Product > ().Action("RateProduct"); rateProduct.Parameter <int>("Rating"); rateProduct.Returns <double>(); config.Routes.MapODataRoute("odata", "odata", builder.GetEdmModel()); }
/// <summary> /// Generates a model from a few seeds (i.e. the names and types of the entity sets) /// by applying conventions. /// </summary> /// <returns>An implicitly configured model</returns> static IEdmModel GetImplicitEdmModel() { ODataModelBuilder modelBuilder = new ODataConventionModelBuilder(); modelBuilder.EntitySet <Product>("Products"); modelBuilder.Entity <RatedProduct>().DerivesFrom <Product>(); modelBuilder.EntitySet <ProductFamily>("ProductFamilies"); modelBuilder.EntitySet <Supplier>("Suppliers"); ActionConfiguration createProduct = modelBuilder.Entity <ProductFamily>().Action("CreateProduct"); createProduct.Parameter <string>("Name"); createProduct.Returns <int>(); return(modelBuilder.GetEdmModel()); }
/// <summary> /// The execute. /// </summary> /// <param name="modelBuilder"> /// The argument. /// </param> /// <param name="context"> /// The context. /// </param> /// <returns> /// The <see cref="ODataConventionModelBuilder"/>. /// </returns> public override Task <ODataConventionModelBuilder> Run(ODataConventionModelBuilder modelBuilder, CommercePipelineExecutionContext context) { Condition.Requires(modelBuilder).IsNotNull($"{this.Name}: The argument cannot be null."); // Add the entities ActionConfiguration actionConfiguration1 = modelBuilder.Action("ExportPriceBooks"); actionConfiguration1.Parameter <string>("fileName"); actionConfiguration1.Parameter <string>("mode"); actionConfiguration1.Parameter <int>("maximumItemsPerFile"); actionConfiguration1.Returns <FileCallbackResult>(); ActionConfiguration actionConfiguration2 = modelBuilder.Action("ImportPriceBooks"); actionConfiguration2.Parameter <IFormFile>("importFile"); actionConfiguration2.Parameter <string>("mode"); actionConfiguration2.Parameter <int>("errorThreshold"); actionConfiguration2.ReturnsFromEntitySet <CommerceCommand>("Commands"); return(Task.FromResult(modelBuilder)); }
public void Cant_SetActionTile_OnNonBindableActions() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); ActionConfiguration action = builder.Action("MyAction"); action.Returns <int>(); action.Title = "My Action"; // Act IEdmModel model = builder.GetEdmModel(); IEdmOperationImport actionImport = model.EntityContainer.OperationImports().OfType <IEdmActionImport>().Single(); Assert.NotNull(actionImport); OperationTitleAnnotation actionTitleAnnotation = model.GetOperationTitleAnnotation(actionImport.Operation); // Assert Assert.Null(actionTitleAnnotation); }
public static void Register(HttpConfiguration config) { ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); builder.EntitySet <Product>("Products"); builder.EntitySet <Supplier>("Suppliers"); builder.EntitySet <ProductRating>("Ratings"); ActionConfiguration rateProduct = builder.Entity <Product>().Action("RateProduct"); rateProduct.Parameter <int>("Rating"); rateProduct.Returns <double>(); var model = builder.GetEdmModel(); HttpServer server = new HttpServer(config); config.Routes.MapODataServiceRoute("odata", "", model); config.EnableQuerySupport(); config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; }
public static IEdmModel GetModel() { ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); EntitySetConfiguration <Window> windows = builder.EntitySet <Window>("Windows"); EntityTypeConfiguration <Window> window = windows.EntityType; // Action that takes in a base complex type. ActionConfiguration actionConfiguration = window.Action("AddOptionalShape"); actionConfiguration.Parameter <Shape>("shape"); actionConfiguration.Returns <int>(); // The number of all optional shapes // Function that returns a base complex type var functionConfiguration = window.Function("GetTheLastOptionalShape"); functionConfiguration.Returns <Shape>(); builder.Namespace = typeof(Window).Namespace; return(builder.GetEdmModel()); }
private static IEdmModel GetEdmModel() { ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); builder.Namespace = "Demo"; builder.ContainerName = "DefaultContainer"; //register Route:/MongoDb1 builder.EntitySet <Models.MongoDbModel>("MongoDb1"); //register Route:/MongoDb2 builder.EntitySet <Models.MongoDbModel>("MongoDb2"); ActionConfiguration action = builder.EntityType <MongoDbModel>().Action("MongoDbAction"); action.Parameter <string>("filter"); action.Returns <string>(); var edmModel = builder.GetEdmModel(); return(edmModel); }
protected void RegisterCustomers(ODataConventionModelBuilder builder) { #region Customer builder.EntitySet <CustomerDto>("Customer"); var customer = builder.EntityType <CustomerDto>(); builder.ComplexType <AddressDto>(); ActionConfiguration addAddress = customer.Action("AddAddress"); addAddress.Parameter <AddressDto>("address"); addAddress.Returns <AddressDto>(); ActionConfiguration updateAddress = customer.Action("UpdateAddress"); updateAddress.Parameter <AddressDto>("address"); updateAddress.Returns <AddressDto>(); ActionConfiguration deleteAddress = customer.Action("DeleteAddress"); deleteAddress.Parameter <string>("addressId"); deleteAddress.Returns <bool>(); ActionConfiguration changePassword = customer.Action("SetPassword"); changePassword.Parameter <string>("password"); changePassword.Returns <bool>(); #endregion #region Customer Role model builder.EntitySet <CustomerRoleDto>("CustomerRole"); builder.EntityType <CustomerRoleDto>().Count().Filter().OrderBy().Page(); #endregion #region Vendors builder.EntitySet <VendorDto>("Vendor"); builder.EntityType <VendorDto>().Count().Filter().OrderBy().Page(); #endregion }
public static IEdmModel GetModel() { ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); EntitySetConfiguration <Employee> employees = builder.EntitySet <Employee>("Employees"); EntityTypeConfiguration <Employee> employee = employees.EntityType; // Action that adds a skill to the skill set. ActionConfiguration actionConfiguration = employee.Action("AddAccessLevel"); actionConfiguration.Parameter <string>("AccessLevel");// Now action parameters does not support Enum type, so use string instead. actionConfiguration.Returns <AccessLevel>(); // Function that tells whether an employee has the given AccessLevel var functionConfiguration = builder.Function("HasAccessLevel"); functionConfiguration.Parameter <int>("ID"); functionConfiguration.Parameter <AccessLevel>("AccessLevel"); functionConfiguration.Returns <bool>(); builder.Namespace = typeof(Employee).Namespace; return(builder.GetEdmModel()); }
public void CanCreateActionWithComplexReturnType() { // Arrange // Act ODataModelBuilder builder = new ODataModelBuilder(); ActionConfiguration createAddress = new ActionConfiguration(builder, "CreateAddress"); createAddress.Returns<Address>(); ActionConfiguration createAddresses = new ActionConfiguration(builder, "CreateAddresses"); createAddresses.ReturnsCollection<Address>(); // Assert IComplexTypeConfiguration address = createAddress.ReturnType as IComplexTypeConfiguration; Assert.NotNull(address); Assert.Equal(typeof(Address).FullName, address.FullName); Assert.Null(createAddress.EntitySet); ICollectionTypeConfiguration addresses = createAddresses.ReturnType as ICollectionTypeConfiguration; Assert.NotNull(addresses); Assert.Equal(string.Format("Collection({0})", typeof(Address).FullName), addresses.FullName); address = addresses.ElementType as IComplexTypeConfiguration; Assert.NotNull(address); Assert.Equal(typeof(Address).FullName, address.FullName); Assert.Null(createAddresses.EntitySet); }
protected void RegisterProduct(ODataConventionModelBuilder builder) { builder.EntitySet <ProductDto>("Product"); var product = builder.EntityType <ProductDto>(); product.Count().Filter().OrderBy().Page(); builder.ComplexType <ProductCategoryDto>(); builder.ComplexType <ProductCollectionDto>(); builder.ComplexType <ProductPictureDto>(); builder.ComplexType <ProductSpecificationAttributeDto>(); builder.ComplexType <ProductTierPriceDto>(); builder.ComplexType <ProductWarehouseInventoryDto>(); builder.ComplexType <ProductAttributeMappingDto>(); builder.ComplexType <ProductAttributeValueDto>(); builder.ComplexType <ProductAttributeCombinationDto>(); //update stock for product ActionConfiguration updateStock = product.Action("UpdateStock"); updateStock.Parameter <string>("WarehouseId"); updateStock.Parameter <int>("Stock").Required(); updateStock.Returns <bool>(); //insert/update/delete category #region Product category ActionConfiguration createCategory = product.Action("CreateProductCategory"); createCategory.Parameter <string>(nameof(ProductCategoryDto.CategoryId)).Required(); createCategory.Parameter <bool>(nameof(ProductCategoryDto.IsFeaturedProduct)); createCategory.Returns <bool>(); ActionConfiguration updateCategory = product.Action("UpdateProductCategory"); updateCategory.Parameter <string>(nameof(ProductCategoryDto.CategoryId)).Required(); updateCategory.Parameter <bool>(nameof(ProductCategoryDto.IsFeaturedProduct)); updateCategory.Returns <bool>(); ActionConfiguration deleteCategory = product.Action("DeleteProductCategory"); deleteCategory.Parameter <string>(nameof(ProductCategoryDto.CategoryId)).Required(); deleteCategory.Returns <bool>(); #endregion //insert/update/delete collection #region Product collection ActionConfiguration createCollection = product.Action("CreateProductCollection"); createCollection.Parameter <string>(nameof(ProductCollectionDto.CollectionId)).Required(); createCollection.Parameter <bool>(nameof(ProductCollectionDto.IsFeaturedProduct)); createCollection.Returns <bool>(); ActionConfiguration updateCollection = product.Action("UpdateProductCollection"); updateCollection.Parameter <string>(nameof(ProductCollectionDto.CollectionId)).Required(); updateCollection.Parameter <bool>(nameof(ProductCollectionDto.IsFeaturedProduct)); updateCollection.Returns <bool>(); ActionConfiguration deleteCollection = product.Action("DeleteProductCollection"); deleteCollection.Parameter <string>(nameof(ProductCollectionDto.CollectionId)).Required(); deleteCollection.Returns <bool>(); #endregion //insert/update/delete picture #region Product picture ActionConfiguration createPicture = product.Action("CreateProductPicture"); createPicture.Parameter <string>(nameof(ProductPictureDto.PictureId)).Required(); createPicture.Parameter <string>(nameof(ProductPictureDto.MimeType)).Required(); createPicture.Parameter <string>(nameof(ProductPictureDto.SeoFilename)).Required(); createPicture.Parameter <string>(nameof(ProductPictureDto.AltAttribute)).Required(); createPicture.Parameter <int>(nameof(ProductPictureDto.DisplayOrder)).Required(); createPicture.Parameter <string>(nameof(ProductPictureDto.TitleAttribute)).Required(); createPicture.Returns <bool>(); ActionConfiguration updatePicture = product.Action("UpdateProductPicture"); updatePicture.Parameter <string>(nameof(ProductPictureDto.PictureId)).Required(); updatePicture.Parameter <string>(nameof(ProductPictureDto.MimeType)).Required(); updatePicture.Parameter <string>(nameof(ProductPictureDto.SeoFilename)).Required(); updatePicture.Parameter <string>(nameof(ProductPictureDto.AltAttribute)).Required(); updatePicture.Parameter <int>(nameof(ProductPictureDto.DisplayOrder)).Required(); updatePicture.Parameter <string>(nameof(ProductPictureDto.TitleAttribute)).Required(); updatePicture.Returns <bool>(); ActionConfiguration deletePicture = product.Action("DeleteProductPicture"); deletePicture.Parameter <string>(nameof(ProductPictureDto.PictureId)).Required(); deletePicture.Returns <bool>(); #endregion #region Product specification ActionConfiguration createSpecification = product.Action("CreateProductSpecification"); createSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.Id)); createSpecification.Parameter <int>(nameof(ProductSpecificationAttributeDto.DisplayOrder)); createSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.CustomValue)); //createSpecification.Parameter<SpecificationAttributeType>(nameof(ProductSpecificationAttributeDto.AttributeType)).Required(); createSpecification.Parameter <bool>(nameof(ProductSpecificationAttributeDto.AllowFiltering)); createSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.SpecificationAttributeId)); createSpecification.Parameter <bool>(nameof(ProductSpecificationAttributeDto.ShowOnProductPage)); createSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.SpecificationAttributeOptionId)); createSpecification.Returns <bool>(); ActionConfiguration updateSpecification = product.Action("UpdateProductSpecification"); updateSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.Id)).Required(); updateSpecification.Parameter <int>(nameof(ProductSpecificationAttributeDto.DisplayOrder)); updateSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.CustomValue)); //updateSpecification.Parameter<SpecificationAttributeType>(nameof(ProductSpecificationAttributeDto.AttributeType)).Required(); updateSpecification.Parameter <bool>(nameof(ProductSpecificationAttributeDto.AllowFiltering)); updateSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.SpecificationAttributeId)).Required(); updateSpecification.Parameter <bool>(nameof(ProductSpecificationAttributeDto.ShowOnProductPage)); updateSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.SpecificationAttributeOptionId)); updateSpecification.Returns <bool>(); ActionConfiguration deleteSpecification = product.Action("DeleteProductSpecification"); deleteSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.Id)).Required(); deleteSpecification.Returns <bool>(); #endregion #region Product attribute mapping ActionConfiguration createProductAttributeMapping = product.Action("CreateProductAttributeMapping"); createProductAttributeMapping.Parameter <string>(nameof(ProductAttributeMappingDto.Id)); createProductAttributeMapping.Parameter <int>(nameof(ProductAttributeMappingDto.DisplayOrder)); createProductAttributeMapping.Parameter <AttributeControlType>(nameof(ProductAttributeMappingDto.AttributeControlTypeId)).Required(); createProductAttributeMapping.Parameter <string>(nameof(ProductAttributeMappingDto.DefaultValue)); createProductAttributeMapping.Parameter <bool>(nameof(ProductAttributeMappingDto.IsRequired)); createProductAttributeMapping.Parameter <string>(nameof(ProductAttributeMappingDto.TextPrompt)); createProductAttributeMapping.Parameter <string>(nameof(ProductAttributeMappingDto.ValidationFileAllowedExtensions)); createProductAttributeMapping.Parameter <int?>(nameof(ProductAttributeMappingDto.ValidationFileMaximumSize)); createProductAttributeMapping.Parameter <int?>(nameof(ProductAttributeMappingDto.ValidationMaxLength)); createProductAttributeMapping.Parameter <int?>(nameof(ProductAttributeMappingDto.ValidationMinLength)); createProductAttributeMapping.Parameter <List <ProductAttributeValueDto> >(nameof(ProductAttributeMappingDto.ProductAttributeValues)); createProductAttributeMapping.Returns <ProductAttributeMappingDto>(); ActionConfiguration updateProductAttributeMapping = product.Action("UpdateProductAttributeMapping"); updateProductAttributeMapping.Parameter <string>(nameof(ProductAttributeMappingDto.Id)).Required(); updateProductAttributeMapping.Parameter <int>(nameof(ProductAttributeMappingDto.DisplayOrder)); updateProductAttributeMapping.Parameter <AttributeControlType>(nameof(ProductAttributeMappingDto.AttributeControlTypeId)).Required(); updateProductAttributeMapping.Parameter <string>(nameof(ProductAttributeMappingDto.DefaultValue)); updateProductAttributeMapping.Parameter <bool>(nameof(ProductAttributeMappingDto.IsRequired)); updateProductAttributeMapping.Parameter <string>(nameof(ProductAttributeMappingDto.TextPrompt)); updateProductAttributeMapping.Parameter <string>(nameof(ProductAttributeMappingDto.ValidationFileAllowedExtensions)); updateProductAttributeMapping.Parameter <int?>(nameof(ProductAttributeMappingDto.ValidationFileMaximumSize)); updateProductAttributeMapping.Parameter <int?>(nameof(ProductAttributeMappingDto.ValidationMaxLength)); updateProductAttributeMapping.Parameter <int?>(nameof(ProductAttributeMappingDto.ValidationMinLength)); updateProductAttributeMapping.Parameter <List <ProductAttributeValueDto> >(nameof(ProductAttributeMappingDto.ProductAttributeValues)); updateProductAttributeMapping.Returns <ProductAttributeMappingDto>(); ActionConfiguration deleteProductAttributeMapping = product.Action("DeleteProductAttributeMapping"); deleteProductAttributeMapping.Parameter <string>(nameof(ProductSpecificationAttributeDto.Id)).Required(); deleteProductAttributeMapping.Returns <bool>(); #endregion //insert/update/delete tier price #region Product tierprice ActionConfiguration createTierPrice = product.Action("CreateProductTierPrice"); createTierPrice.Parameter <int>(nameof(ProductTierPriceDto.Quantity)); createTierPrice.Parameter <double>(nameof(ProductTierPriceDto.Price)); createTierPrice.Parameter <string>(nameof(ProductTierPriceDto.StoreId)); createTierPrice.Parameter <string>(nameof(ProductTierPriceDto.CustomerGroupId)); createTierPrice.Parameter <DateTime?>(nameof(ProductTierPriceDto.StartDateTimeUtc)); createTierPrice.Parameter <DateTime?>(nameof(ProductTierPriceDto.EndDateTimeUtc)); createTierPrice.Returns <bool>(); ActionConfiguration updateTierPrice = product.Action("UpdateProductTierPrice"); updateTierPrice.Parameter <string>(nameof(ProductTierPriceDto.Id)).Required(); updateTierPrice.Parameter <int>(nameof(ProductTierPriceDto.Quantity)); updateTierPrice.Parameter <double>(nameof(ProductTierPriceDto.Price)); updateTierPrice.Parameter <string>(nameof(ProductTierPriceDto.StoreId)); updateTierPrice.Parameter <string>(nameof(ProductTierPriceDto.CustomerGroupId)); updateTierPrice.Parameter <DateTime?>(nameof(ProductTierPriceDto.StartDateTimeUtc)); updateTierPrice.Parameter <DateTime?>(nameof(ProductTierPriceDto.EndDateTimeUtc)); updateTierPrice.Returns <bool>(); ActionConfiguration deleteTierPrice = product.Action("DeleteProductTierPrice"); deleteTierPrice.Parameter <string>(nameof(ProductTierPriceDto.Id)).Required(); deleteTierPrice.Returns <bool>(); #endregion }
protected void RegisterCustomers(ODataConventionModelBuilder builder) { #region Customer builder.EntitySet <CustomerDto>("Customer"); var customer = builder.EntityType <CustomerDto>(); builder.ComplexType <AddressDto>(); ActionConfiguration addAddress = customer.Action("AddAddress"); addAddress.Parameter <string>(nameof(AddressDto.Id)).Required(); addAddress.Parameter <string>(nameof(AddressDto.City)); addAddress.Parameter <string>(nameof(AddressDto.Email)); addAddress.Parameter <string>(nameof(AddressDto.Company)); addAddress.Parameter <string>(nameof(AddressDto.Address1)); addAddress.Parameter <string>(nameof(AddressDto.Address2)); addAddress.Parameter <string>(nameof(AddressDto.LastName)); addAddress.Parameter <string>(nameof(AddressDto.CountryId)); addAddress.Parameter <string>(nameof(AddressDto.FaxNumber)); addAddress.Parameter <string>(nameof(AddressDto.FirstName)); addAddress.Parameter <string>(nameof(AddressDto.VatNumber)); addAddress.Parameter <string>(nameof(AddressDto.PhoneNumber)); addAddress.Parameter <string>(nameof(AddressDto.CustomAttributes)); addAddress.Parameter <DateTimeOffset>(nameof(AddressDto.CreatedOnUtc)); addAddress.Parameter <string>(nameof(AddressDto.ZipPostalCode)); addAddress.Parameter <string>(nameof(AddressDto.StateProvinceId)); addAddress.Returns <AddressDto>(); ActionConfiguration updateAddress = customer.Action("UpdateAddress"); updateAddress.Parameter <string>(nameof(AddressDto.Id)).Required(); updateAddress.Parameter <string>(nameof(AddressDto.City)); updateAddress.Parameter <string>(nameof(AddressDto.Email)); updateAddress.Parameter <string>(nameof(AddressDto.Company)); updateAddress.Parameter <string>(nameof(AddressDto.Address1)); updateAddress.Parameter <string>(nameof(AddressDto.Address2)); updateAddress.Parameter <string>(nameof(AddressDto.LastName)); updateAddress.Parameter <string>(nameof(AddressDto.CountryId)); updateAddress.Parameter <string>(nameof(AddressDto.FaxNumber)); updateAddress.Parameter <string>(nameof(AddressDto.FirstName)); updateAddress.Parameter <string>(nameof(AddressDto.VatNumber)); updateAddress.Parameter <string>(nameof(AddressDto.PhoneNumber)); updateAddress.Parameter <string>(nameof(AddressDto.CustomAttributes)); updateAddress.Parameter <DateTimeOffset>(nameof(AddressDto.CreatedOnUtc)); updateAddress.Parameter <string>(nameof(AddressDto.ZipPostalCode)); updateAddress.Parameter <string>(nameof(AddressDto.StateProvinceId)); updateAddress.Returns <AddressDto>(); ActionConfiguration deleteAddress = customer.Action("DeleteAddress"); deleteAddress.Parameter <string>("addressId"); deleteAddress.Returns <bool>(); ActionConfiguration changePassword = customer.Action("SetPassword"); changePassword.Parameter <string>("password"); changePassword.Returns <bool>(); #endregion #region Customer group model builder.EntitySet <CustomerGroupDto>("CustomerGroup"); builder.EntityType <CustomerGroupDto>().Count().Filter().OrderBy().Page(); #endregion #region Vendors builder.EntitySet <VendorDto>("Vendor"); builder.EntityType <VendorDto>().Count().Filter().OrderBy().Page(); #endregion }
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()); }
// 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()); }
protected void RegisterProduct(ODataConventionModelBuilder builder) { builder.EntitySet <ProductDto>("Product"); var product = builder.EntityType <ProductDto>(); product.Count().Filter().OrderBy().Page(); builder.ComplexType <ProductCategoryDto>(); builder.ComplexType <ProductManufacturerDto>(); builder.ComplexType <ProductPictureDto>(); builder.ComplexType <ProductSpecificationAttributeDto>(); builder.ComplexType <ProductTierPriceDto>(); builder.ComplexType <ProductWarehouseInventoryDto>(); builder.ComplexType <ProductAttributeMappingDto>(); builder.ComplexType <ProductAttributeValueDto>(); builder.ComplexType <ProductAttributeCombinationDto>(); //update stock for product ActionConfiguration updateStock = product.Action("UpdateStock"); updateStock.Parameter <string>("WarehouseId"); updateStock.Parameter <int>("Stock").Required(); updateStock.Returns <bool>(); //insert/update/delete category #region Product category ActionConfiguration createCategory = product.Action("CreateProductCategory"); createCategory.Parameter <ProductCategoryDto>("productCategory"); createCategory.Returns <bool>(); ActionConfiguration updateCategory = product.Action("UpdateProductCategory"); updateCategory.Parameter <ProductCategoryDto>("productCategory"); updateCategory.Returns <bool>(); ActionConfiguration deleteCategory = product.Action("DeleteProductCategory"); deleteCategory.Parameter <string>("CategoryId").Required(); deleteCategory.Returns <bool>(); #endregion //insert/update/delete manufacturer #region Product manufacturer ActionConfiguration createManufacturer = product.Action("CreateProductManufacturer"); createManufacturer.Parameter <ProductManufacturerDto>("productManufacturer"); createManufacturer.Returns <bool>(); ActionConfiguration updateManufacturer = product.Action("UpdateProductManufacturer"); updateManufacturer.Parameter <ProductManufacturerDto>("productManufacturer"); updateManufacturer.Returns <bool>(); ActionConfiguration deleteManufacturer = product.Action("DeleteProductManufacturer"); deleteManufacturer.Parameter <string>("ManufacturerId").Required(); deleteManufacturer.Returns <bool>(); #endregion //insert/update/delete picture #region Product picture ActionConfiguration createPicture = product.Action("CreateProductPicture"); createPicture.Parameter <ProductPictureDto>("productPicture"); createPicture.Returns <bool>(); ActionConfiguration updatePicture = product.Action("UpdateProductPicture"); updatePicture.Parameter <ProductPictureDto>("productPicture"); updatePicture.Returns <bool>(); ActionConfiguration deletePicture = product.Action("DeleteProductPicture"); deletePicture.Parameter <string>("PictureId").Required(); deletePicture.Returns <bool>(); #endregion #region Product specification ActionConfiguration createSpecification = product.Action("CreateProductSpecification"); createSpecification.Parameter <ProductSpecificationAttributeDto>("productSpecification"); createSpecification.Returns <bool>(); ActionConfiguration updateSpecification = product.Action("UpdateProductSpecification"); updateSpecification.Parameter <ProductSpecificationAttributeDto>("productSpecification"); updateSpecification.Returns <bool>(); ActionConfiguration deleteSpecification = product.Action("DeleteProductSpecification"); deleteSpecification.Parameter <string>("Id").Required(); deleteSpecification.Returns <bool>(); #endregion }
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 }); }
protected void RegisterProduct(ODataConventionModelBuilder builder) { builder.EntitySet <ProductDto>("Product"); var product = builder.EntityType <ProductDto>(); product.Count().Filter().OrderBy().Page(); builder.ComplexType <ProductCategoryDto>(); builder.ComplexType <ProductManufacturerDto>(); builder.ComplexType <ProductPictureDto>(); builder.ComplexType <ProductSpecificationAttributeDto>(); builder.ComplexType <ProductTierPriceDto>(); builder.ComplexType <ProductWarehouseInventoryDto>(); builder.ComplexType <ProductAttributeMappingDto>(); builder.ComplexType <ProductAttributeValueDto>(); builder.ComplexType <ProductAttributeCombinationDto>(); //update stock for product ActionConfiguration updateStock = product.Action("UpdateStock"); updateStock.Parameter <string>("WarehouseId"); updateStock.Parameter <int>("Stock").Required(); updateStock.Returns <bool>(); //insert/update/delete category #region Product category ActionConfiguration createCategory = product.Action("CreateProductCategory"); createCategory.Parameter <string>(nameof(ProductCategoryDto.CategoryId)).Required(); createCategory.Parameter <bool>(nameof(ProductCategoryDto.IsFeaturedProduct)); createCategory.Returns <bool>(); ActionConfiguration updateCategory = product.Action("UpdateProductCategory"); updateCategory.Parameter <string>(nameof(ProductCategoryDto.CategoryId)).Required(); updateCategory.Parameter <bool>(nameof(ProductCategoryDto.IsFeaturedProduct)); updateCategory.Returns <bool>(); ActionConfiguration deleteCategory = product.Action("DeleteProductCategory"); deleteCategory.Parameter <string>(nameof(ProductCategoryDto.CategoryId)).Required(); deleteCategory.Returns <bool>(); #endregion //insert/update/delete manufacturer #region Product manufacturer ActionConfiguration createManufacturer = product.Action("CreateProductManufacturer"); createManufacturer.Parameter <string>(nameof(ProductManufacturerDto.ManufacturerId)).Required(); createManufacturer.Parameter <bool>(nameof(ProductManufacturerDto.IsFeaturedProduct)); createManufacturer.Returns <bool>(); ActionConfiguration updateManufacturer = product.Action("UpdateProductManufacturer"); updateManufacturer.Parameter <string>(nameof(ProductManufacturerDto.ManufacturerId)).Required(); updateManufacturer.Parameter <bool>(nameof(ProductManufacturerDto.IsFeaturedProduct)); updateManufacturer.Returns <bool>(); ActionConfiguration deleteManufacturer = product.Action("DeleteProductManufacturer"); deleteManufacturer.Parameter <string>(nameof(ProductManufacturerDto.ManufacturerId)).Required(); deleteManufacturer.Returns <bool>(); #endregion //insert/update/delete picture #region Product picture ActionConfiguration createPicture = product.Action("CreateProductPicture"); createPicture.Parameter <string>(nameof(ProductPictureDto.PictureId)).Required(); createPicture.Parameter <string>(nameof(ProductPictureDto.MimeType)).Required(); createPicture.Parameter <string>(nameof(ProductPictureDto.SeoFilename)).Required(); createPicture.Parameter <string>(nameof(ProductPictureDto.AltAttribute)).Required(); createPicture.Parameter <int>(nameof(ProductPictureDto.DisplayOrder)).Required(); createPicture.Parameter <string>(nameof(ProductPictureDto.TitleAttribute)).Required(); createPicture.Returns <bool>(); ActionConfiguration updatePicture = product.Action("UpdateProductPicture"); updatePicture.Parameter <string>(nameof(ProductPictureDto.PictureId)).Required(); updatePicture.Parameter <string>(nameof(ProductPictureDto.MimeType)).Required(); updatePicture.Parameter <string>(nameof(ProductPictureDto.SeoFilename)).Required(); updatePicture.Parameter <string>(nameof(ProductPictureDto.AltAttribute)).Required(); updatePicture.Parameter <int>(nameof(ProductPictureDto.DisplayOrder)).Required(); updatePicture.Parameter <string>(nameof(ProductPictureDto.TitleAttribute)).Required(); updatePicture.Returns <bool>(); ActionConfiguration deletePicture = product.Action("DeleteProductPicture"); deletePicture.Parameter <string>(nameof(ProductPictureDto.PictureId)).Required(); deletePicture.Returns <bool>(); #endregion #region Product specification ActionConfiguration createSpecification = product.Action("CreateProductSpecification"); createSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.Id)).Required(); createSpecification.Parameter <int>(nameof(ProductSpecificationAttributeDto.DisplayOrder)); createSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.CustomValue)); createSpecification.Parameter <SpecificationAttributeType>(nameof(ProductSpecificationAttributeDto.AttributeType)).Required(); createSpecification.Parameter <bool>(nameof(ProductSpecificationAttributeDto.AllowFiltering)); createSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.SpecificationAttributeId)); createSpecification.Parameter <bool>(nameof(ProductSpecificationAttributeDto.ShowOnProductPage)); createSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.SpecificationAttributeOptionId)); createSpecification.Returns <bool>(); ActionConfiguration updateSpecification = product.Action("UpdateProductSpecification"); updateSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.Id)).Required(); updateSpecification.Parameter <int>(nameof(ProductSpecificationAttributeDto.DisplayOrder)); updateSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.CustomValue)); updateSpecification.Parameter <SpecificationAttributeType>(nameof(ProductSpecificationAttributeDto.AttributeType)).Required(); updateSpecification.Parameter <bool>(nameof(ProductSpecificationAttributeDto.AllowFiltering)); updateSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.SpecificationAttributeId)).Required(); updateSpecification.Parameter <bool>(nameof(ProductSpecificationAttributeDto.ShowOnProductPage)); updateSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.SpecificationAttributeOptionId)); updateSpecification.Returns <bool>(); ActionConfiguration deleteSpecification = product.Action("DeleteProductSpecification"); deleteSpecification.Parameter <string>(nameof(ProductSpecificationAttributeDto.Id)).Required(); deleteSpecification.Returns <bool>(); #endregion //insert/update/delete tier price #region Product tierprice ActionConfiguration createTierPrice = product.Action("CreateProductTierPrice"); createTierPrice.Parameter <int>(nameof(ProductTierPriceDto.Quantity)); createTierPrice.Parameter <decimal>(nameof(ProductTierPriceDto.Price)); createTierPrice.Parameter <string>(nameof(ProductTierPriceDto.StoreId)); createTierPrice.Parameter <string>(nameof(ProductTierPriceDto.CustomerRoleId)); createTierPrice.Parameter <DateTime?>(nameof(ProductTierPriceDto.StartDateTimeUtc)); createTierPrice.Parameter <DateTime?>(nameof(ProductTierPriceDto.EndDateTimeUtc)); createTierPrice.Returns <bool>(); ActionConfiguration updateTierPrice = product.Action("UpdateProductTierPrice"); updateTierPrice.Parameter <string>(nameof(ProductTierPriceDto.Id)).Required(); updateTierPrice.Parameter <int>(nameof(ProductTierPriceDto.Quantity)); updateTierPrice.Parameter <decimal>(nameof(ProductTierPriceDto.Price)); updateTierPrice.Parameter <string>(nameof(ProductTierPriceDto.StoreId)); updateTierPrice.Parameter <string>(nameof(ProductTierPriceDto.CustomerRoleId)); updateTierPrice.Parameter <DateTime?>(nameof(ProductTierPriceDto.StartDateTimeUtc)); updateTierPrice.Parameter <DateTime?>(nameof(ProductTierPriceDto.EndDateTimeUtc)); updateTierPrice.Returns <bool>(); ActionConfiguration deleteTierPrice = product.Action("DeleteProductTierPrice"); deleteTierPrice.Parameter <string>(nameof(ProductTierPriceDto.Id)).Required(); deleteTierPrice.Returns <bool>(); #endregion }
/// <summary> /// Generates a model explicitly. /// </summary> /// <returns></returns> static IEdmModel GetExplicitEdmModel() { ODataModelBuilder modelBuilder = new ODataModelBuilder(); var products = modelBuilder.EntitySet <Product>("Products"); products.HasEditLink( entityContext => { object id; entityContext.EdmObject.TryGetPropertyValue("ID", out id); return(entityContext.Url.ODataLink( new EntitySetPathSegment(entityContext.EntitySet.Name), new KeyValuePathSegment(ODataUriUtils.ConvertToUriLiteral(id, ODataVersion.V3)))); }, followsConventions: true); var suppliers = modelBuilder.EntitySet <Supplier>("Suppliers"); suppliers.HasEditLink( entityContext => { object id; entityContext.EdmObject.TryGetPropertyValue("ID", out id); return(entityContext.Url.ODataLink( new EntitySetPathSegment(entityContext.EntitySet.Name), new KeyValuePathSegment(ODataUriUtils.ConvertToUriLiteral(id, ODataVersion.V3)))); }, followsConventions: true); var families = modelBuilder.EntitySet <ProductFamily>("ProductFamilies"); families.HasEditLink( entityContext => { object id; entityContext.EdmObject.TryGetPropertyValue("ID", out id); return(entityContext.Url.ODataLink( new EntitySetPathSegment(entityContext.EntitySet.Name), new KeyValuePathSegment(ODataUriUtils.ConvertToUriLiteral(id, ODataVersion.V3)))); }, followsConventions: true); var product = products.EntityType; product.HasKey(p => p.ID); product.Property(p => p.Name); product.Property(p => p.ReleaseDate); product.Property(p => p.SupportedUntil); modelBuilder.Entity <RatedProduct>().DerivesFrom <Product>().Property(rp => rp.Rating); var address = modelBuilder.ComplexType <Address>(); address.Property(a => a.City); address.Property(a => a.Country); address.Property(a => a.State); address.Property(a => a.Street); address.Property(a => a.ZipCode); var supplier = suppliers.EntityType; supplier.HasKey(s => s.ID); supplier.Property(s => s.Name); supplier.ComplexProperty(s => s.Address); var productFamily = families.EntityType; productFamily.HasKey(pf => pf.ID); productFamily.Property(pf => pf.Name); productFamily.Property(pf => pf.Description); // Create relationships and bindings in one go products.HasRequiredBinding(p => p.Family, families); families.HasManyBinding(pf => pf.Products, products); families.HasOptionalBinding(pf => pf.Supplier, suppliers); suppliers.HasManyBinding(s => s.ProductFamilies, families); // Create navigation Link builders products.HasNavigationPropertiesLink( product.NavigationProperties, (entityContext, navigationProperty) => { object id; entityContext.EdmObject.TryGetPropertyValue("ID", out id); return(new Uri(entityContext.Url.ODataLink( new EntitySetPathSegment(entityContext.EntitySet.Name), new KeyValuePathSegment(ODataUriUtils.ConvertToUriLiteral(id, ODataVersion.V3)), new NavigationPathSegment(navigationProperty.Name)))); }, followsConventions: true); families.HasNavigationPropertiesLink( productFamily.NavigationProperties, (entityContext, navigationProperty) => { object id; entityContext.EdmObject.TryGetPropertyValue("ID", out id); return(new Uri(entityContext.Url.ODataLink( new EntitySetPathSegment(entityContext.EntitySet.Name), new KeyValuePathSegment(ODataUriUtils.ConvertToUriLiteral(id, ODataVersion.V3)), new NavigationPathSegment(navigationProperty.Name)))); }, followsConventions: true); suppliers.HasNavigationPropertiesLink( supplier.NavigationProperties, (entityContext, navigationProperty) => { object id; entityContext.EdmObject.TryGetPropertyValue("ID", out id); return(new Uri(entityContext.Url.ODataLink( new EntitySetPathSegment(entityContext.EntitySet.Name), new KeyValuePathSegment(ODataUriUtils.ConvertToUriLiteral(id, ODataVersion.V3)), new NavigationPathSegment(navigationProperty.Name)))); }, followsConventions: true); ActionConfiguration createProduct = product.Action("CreateProduct"); createProduct.Parameter <string>("Name"); createProduct.Returns <int>(); return(modelBuilder.GetEdmModel()); }
public static IEdmModel GetEdmModel() { ODataModelBuilder builder = new ODataConventionModelBuilder(); var countryConfig = builder.EntitySet <Country>("Countries"); countryConfig.EntityType.HasKey <string>(e => e.Code); var districtConfig = builder.EntitySet <District>("Districts"); districtConfig.EntityType.HasKey <string>(e => e.Code); var municipalityConfig = builder.EntitySet <Municipality>("Municipalities"); municipalityConfig.EntityType.HasKey <string>(e => e.Code); var settlementsConfig = builder.EntitySet <Settlement>("Settlements"); settlementsConfig.EntityType.HasKey <string>(e => e.Code); var mayoraltiesConfig = builder.EntitySet <Mayoralty>("Mayoralties"); mayoraltiesConfig.EntityType.HasKey <string>(e => e.Code); var areasConfig = builder.EntitySet <Area>("Areas"); areasConfig.EntityType.HasKey <string>(e => e.Code); var directoratesConfig = builder.EntitySet <IAMADirectorate>("IAMADirectorates"); directoratesConfig.EntityType.HasKey <string>(e => e.Code); var directionsConfig = builder.EntitySet <Direction>("Directions"); directionsConfig.EntityType.HasKey <string>(e => e.Code); var animalTypesConfig = builder.EntitySet <AnimalType>("AnimalTypes"); animalTypesConfig.EntityType.HasKey <string>(e => e.Code); var animalCategoriesConfig = builder.EntitySet <AnimalCategory>("AnimalCategories"); animalCategoriesConfig.EntityType.HasKey <string>(e => e.Code); var animalPurposesConfig = builder.EntitySet <AnimalPurpose>("AnimalPurposes"); animalPurposesConfig.EntityType.HasKey <string>(e => e.Code); var animalRisingTechnologiesConfig = builder.EntitySet <AnimalRisingTechnology>("AnimalRisingTechnologies"); animalRisingTechnologiesConfig.EntityType.HasKey <string>(e => e.Code); var farmCapacitiesConfig = builder.EntitySet <FarmCapacity>("FarmCapacities"); farmCapacitiesConfig.EntityType.HasKey <string>(e => e.Code); var animalProductionTypesConfig = builder.EntitySet <AnimalProductionType>("AnimalProductionTypes"); animalProductionTypesConfig.EntityType.HasKey <string>(e => e.Code); var foodGroupsConfig = builder.EntitySet <FoodGroup>("FoodGroups"); foodGroupsConfig.EntityType.HasKey <string>(e => e.Code); var foodSubGroupsConfig = builder.EntitySet <FoodSubGroup>("FoodSubGroups"); foodSubGroupsConfig.EntityType.HasKey <string>(e => e.Code); var foodItemConfig = builder.EntitySet <FoodItem>("FoodItem"); foodItemConfig.EntityType.HasKey <string>(e => e.Name); var foodItemsConfig = builder.EntitySet <FoodItems>("FoodItems"); foodItemsConfig.EntityType.HasKey <string>(e => e.Name); var navalEducationalOrganizationsConfig = builder.EntitySet <NavalEducationalOrganization>("NavalEducationalOrganizations"); navalEducationalOrganizationsConfig.EntityType.HasKey <string>(e => e.Code); var navalCompetencyCoursesConfig = builder.EntitySet <NavalCompetencyCourse>("NavalCompetencyCourses"); navalCompetencyCoursesConfig.EntityType.HasKey <string>(e => e.Code); var certificateIssuingCitiesConfig = builder.EntitySet <CertificateIssuingCity>("CertificateIssuingCities"); certificateIssuingCitiesConfig.EntityType.HasKey <string>(e => e.Code); var seaWorkCompetencyGroupsConfig = builder.EntitySet <SeaWorkCompetencyGroup>("SeaWorkCompetencyGroups"); seaWorkCompetencyGroupsConfig.EntityType.HasKey <string>(e => e.Code); var seaWorkCompetenciesConfig = builder.EntitySet <SeaWorkCompetency>("SeaWorkCompetencies"); seaWorkCompetenciesConfig.EntityType.HasKey <string>(e => e.Name); var documentConfig = builder.EntitySet <Document>("Documents"); documentConfig.EntityType.HasKey <int>(e => e.Id); ActionConfiguration dicumentValidation = builder.Entity <Document>().Collection.Action("ValidateXML"); dicumentValidation.Parameter <string>("documentContent"); dicumentValidation.Returns <object>(); builder.Namespace = "TechnoLogica.Eservices.DocumentEditor.Infrastructure.DataPackages.Models"; // DON'T FORGET THIS! return(builder.GetEdmModel()); }