├── .gitignore ├── README.md ├── proto ├── ordermgmt.proto └── partialfoods.proto └── src └── PartialFoods.Services.OrderManagementServer ├── Dockerfile ├── Entities ├── IOrderRepository.cs ├── Order.cs ├── OrderActivity.cs ├── OrderRepository.cs └── OrdersContext.cs ├── KafkaActivitiesConsumer.cs ├── KafkaOrdersConsumer.cs ├── Migrations ├── 20171007153926_CreateDatabase.Designer.cs ├── 20171007153926_CreateDatabase.cs ├── 20171015152123_AddActivities.Designer.cs ├── 20171015152123_AddActivities.cs ├── 20171015152351_RenameActivityToActivityType.Designer.cs ├── 20171015152351_RenameActivityToActivityType.cs └── OrdersContextModelSnapshot.cs ├── OrderAcceptedEvent.cs ├── OrderAcceptedEventProcessor.cs ├── OrderCanceledEvent.cs ├── OrderCanceledEventProcessor.cs ├── OrderManagementImpl.cs ├── PartialFoods.Services.OrderManagementServer.csproj ├── Program.cs ├── RPC ├── Ordermgmt.cs ├── OrdermgmtGrpc.cs ├── Partialfoods.cs └── PartialfoodsGrpc.cs ├── appsettings.json └── makeprotos.sh /.gitignore: -------------------------------------------------------------------------------- 1 | project.lock.json 2 | *~ 3 | \#* 4 | bin 5 | obj 6 | .vscode/ 7 | 8 | # User-specific files 9 | *.suo 10 | *.user 11 | *.userosscache 12 | *.sln.docstates 13 | *.vscode/ 14 | # User-specific files (MonoDevelop/Xamarin Studio) 15 | *.userprefs 16 | 17 | # Build results 18 | [Dd]ebug/ 19 | [Dd]ebugPublic/ 20 | [Rr]elease/ 21 | [Rr]eleases/ 22 | x64/ 23 | x86/ 24 | build/ 25 | publish/ 26 | bld/ 27 | [Bb]in/ 28 | [Oo]bj/ 29 | *.dll 30 | *.pdb 31 | 32 | # Visual Studo 2015 cache/options directory 33 | .vs/ 34 | 35 | # MSTest test Results 36 | [Tt]est[Rr]esult*/ 37 | [Bb]uild[Ll]og.* 38 | 39 | # NUNIT 40 | *.VisualState.xml 41 | TestResult.xml 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Order Management 2 | -------------------------------------------------------------------------------- /proto/ordermgmt.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package PartialFoods.Services; 4 | 5 | import "partialfoods.proto"; 6 | 7 | service OrderManagement { 8 | rpc GetOrder(GetOrderRequest) returns (GetOrderResponse); 9 | rpc OrderExists(GetOrderRequest) returns (OrderExistsResponse); 10 | } 11 | 12 | message GetOrderRequest { 13 | string OrderID = 1; 14 | } 15 | 16 | message GetOrderResponse { 17 | string OrderID = 1; 18 | uint64 CreatedOn = 2; // UTC milliseconds of time terminal created transaction 19 | string UserID = 3; // User ID of the order owner 20 | uint32 TaxRate = 4; // Percentage rate of tax, whole numbers because reasons 21 | 22 | ShippingInfo ShippingInfo = 5; // Information on where order is to be shipped 23 | repeated LineItem LineItems = 6; // Individual line items on a transaction 24 | 25 | OrderStatus Status = 7; 26 | } 27 | 28 | message OrderExistsResponse { 29 | string OrderID = 1; 30 | bool Exists = 2; 31 | } 32 | 33 | enum OrderStatus { 34 | UNKNOWN = 0; 35 | OPEN = 1; 36 | CANCELED = 2; 37 | } -------------------------------------------------------------------------------- /proto/partialfoods.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package PartialFoods.Services; 4 | 5 | service OrderCommand { 6 | rpc SubmitOrder(OrderRequest) returns (OrderResponse); 7 | rpc CancelOrder(CancelOrderRequest) returns (CancelOrderResponse); 8 | } 9 | 10 | message OrderRequest { 11 | uint64 CreatedOn = 1; // UTC milliseconds of time terminal created transaction 12 | string UserID = 2; // User ID of the order owner 13 | uint32 TaxRate = 3; // Percentage rate of tax, whole numbers because reasons 14 | 15 | ShippingInfo ShippingInfo = 4; // Information on where order is to be shipped 16 | repeated LineItem LineItems = 5; // Individual line items on a transaction 17 | } 18 | 19 | message ShippingInfo { 20 | string Addressee = 1; 21 | repeated string AddressLines = 2; 22 | string City = 3; 23 | string ZipCode = 4; 24 | string StateCode = 5; 25 | } 26 | 27 | message LineItem { 28 | string SKU = 1; // Stock Keeping Unit of inventory item being purchased 29 | uint32 UnitPrice = 2; // Price for a single item 30 | uint32 Quantity = 3; // Quantity of items purchased 31 | } 32 | 33 | message OrderResponse { 34 | string OrderID = 1; // UUID of the order 35 | bool Accepted = 2; // Indicates whether the transaction was accepted 36 | } 37 | 38 | message CancelOrderRequest { 39 | string OrderID = 1; 40 | string UserID = 2; 41 | } 42 | 43 | message CancelOrderResponse { 44 | string OrderID = 1; 45 | bool Canceled = 2; 46 | string ConfirmationCode = 3; 47 | } 48 | -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/Dockerfile: -------------------------------------------------------------------------------- 1 | # WARNING: each time you run this the build image produces a 'spare' 1.93GB docker image 2 | # clean out your docker images periodically after running this 3 | FROM microsoft/dotnet:2.0.5-sdk-2.1.4 as publish 4 | WORKDIR /publish 5 | COPY PartialFoods.Services.OrderManagementServer.csproj . 6 | RUN dotnet restore 7 | COPY . . 8 | RUN dotnet publish --output ./out 9 | 10 | FROM microsoft/dotnet:2.0.5-runtime 11 | WORKDIR /app 12 | COPY --from=publish /publish/out . 13 | ADD appsettings.json /app 14 | ENTRYPOINT ["dotnet", "PartialFoods.Services.OrderManagementServer.dll"] -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/Entities/IOrderRepository.cs: -------------------------------------------------------------------------------- 1 | namespace PartialFoods.Services.OrderManagementServer.Entities 2 | { 3 | public interface IOrderRepository 4 | { 5 | Order Add(Order order); 6 | Order GetOrder(string orderID); 7 | OrderActivity AddActivity(OrderActivity activity); 8 | 9 | bool OrderExists(string orderID); 10 | } 11 | } -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/Entities/Order.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace PartialFoods.Services.OrderManagementServer.Entities 4 | { 5 | public class Order 6 | { 7 | public string OrderID { get; set; } 8 | public long CreatedOn { get; set; } 9 | public string UserID { get; set; } 10 | public ICollection LineItems { get; set; } = new List(); 11 | public ICollection Activities { get; set; } = new List(); 12 | 13 | public int TaxRate { get; set; } 14 | } 15 | 16 | public class LineItem 17 | { 18 | public string OrderID { get; set; } 19 | public string SKU { get; set; } 20 | public int Quantity { get; set; } 21 | public int UnitPrice { get; set; } 22 | } 23 | } -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/Entities/OrderActivity.cs: -------------------------------------------------------------------------------- 1 | namespace PartialFoods.Services.OrderManagementServer.Entities 2 | { 3 | public class OrderActivity 4 | { 5 | public string OrderID { get; set; } 6 | public ActivityType ActivityType { get; set; } 7 | public string UserID { get; set; } 8 | public long OccuredOn { get; set; } 9 | public string ActivityID { get; set; } 10 | } 11 | 12 | public enum ActivityType 13 | { 14 | Canceled = 1, 15 | Unknown = 0 16 | } 17 | } -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/Entities/OrderRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Microsoft.EntityFrameworkCore; 4 | 5 | namespace PartialFoods.Services.OrderManagementServer.Entities 6 | { 7 | public class OrderRepository : IOrderRepository 8 | { 9 | private OrdersContext context; 10 | 11 | public OrderRepository(OrdersContext context) 12 | { 13 | this.context = context; 14 | } 15 | 16 | public OrderActivity AddActivity(OrderActivity activity) 17 | { 18 | try 19 | { 20 | context.Activities.Add(activity); 21 | context.SaveChanges(); 22 | return activity; 23 | } 24 | catch (Exception ex) 25 | { 26 | Console.WriteLine(ex.StackTrace); 27 | Console.WriteLine($"Failed to add order activity: {ex.ToString()}"); 28 | return null; 29 | } 30 | } 31 | 32 | public bool OrderExists(string orderID) 33 | { 34 | try 35 | { 36 | var existing = context.Orders.FirstOrDefault(o => o.OrderID == orderID); 37 | return existing != null; 38 | } 39 | catch (Exception ex) 40 | { 41 | Console.WriteLine(ex.StackTrace); 42 | Console.WriteLine($"Failed to check order existence: {ex.ToString()}"); 43 | return false; 44 | } 45 | } 46 | public Order GetOrder(string orderID) 47 | { 48 | Console.WriteLine($"Fetching order {orderID}"); 49 | try 50 | { 51 | var existing = context.Orders 52 | .Include(o => o.LineItems) 53 | .Include(o => o.Activities) 54 | .FirstOrDefault(o => o.OrderID == orderID); 55 | return existing; 56 | } 57 | catch (Exception ex) 58 | { 59 | Console.WriteLine(ex.StackTrace); 60 | Console.WriteLine($"Failed to query order {ex.ToString()}"); 61 | return null; 62 | } 63 | } 64 | 65 | public Order Add(Order order) 66 | { 67 | Console.WriteLine($"Adding order {order.OrderID} to repository."); 68 | try 69 | { 70 | var existing = context.Orders.FirstOrDefault(o => o.OrderID == order.OrderID); 71 | if (existing != null) 72 | { 73 | Console.WriteLine($"Bypassing add for order {order.OrderID} - already exists."); 74 | return order; 75 | } 76 | context.Add(order); 77 | context.SaveChanges(); 78 | return order; 79 | } 80 | catch (Exception ex) 81 | { 82 | Console.WriteLine(ex.StackTrace); 83 | Console.WriteLine($"Failed to save changes in db context: {ex.ToString()}"); 84 | return null; 85 | } 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/Entities/OrdersContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | 3 | namespace PartialFoods.Services.OrderManagementServer.Entities 4 | { 5 | public class OrdersContext : DbContext 6 | { 7 | private string connStr; 8 | 9 | public OrdersContext(string connectionString) : base() 10 | { 11 | connStr = connectionString; 12 | } 13 | 14 | public DbSet Orders { get; set; } 15 | public DbSet OrderItems { get; set; } 16 | 17 | public DbSet Activities { get; set; } 18 | 19 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 20 | { 21 | optionsBuilder.UseNpgsql(connStr); 22 | } 23 | 24 | protected override void OnModelCreating(ModelBuilder builder) 25 | { 26 | builder.Entity() 27 | .HasKey(o => o.OrderID); 28 | 29 | builder.Entity() 30 | .HasKey(li => new { li.OrderID, li.SKU }); 31 | 32 | builder.Entity() 33 | .HasKey(a => new { a.OrderID, a.ActivityID }); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/KafkaActivitiesConsumer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using Confluent.Kafka; 6 | using Confluent.Kafka.Serialization; 7 | using Newtonsoft.Json; 8 | 9 | namespace PartialFoods.Services.OrderManagementServer 10 | { 11 | public class KafkaActivitiesConsumer 12 | { 13 | private string topic; 14 | private Dictionary config; 15 | private OrderCanceledEventProcessor eventProcessor; 16 | 17 | public KafkaActivitiesConsumer(string topic, Dictionary config, OrderCanceledEventProcessor eventProcessor) 18 | { 19 | this.topic = topic; 20 | this.config = config; 21 | this.eventProcessor = eventProcessor; 22 | } 23 | 24 | public void Consume() 25 | { 26 | Task.Run(() => 27 | { 28 | Console.WriteLine($"Starting Kafka subscription to {topic}"); 29 | using (var consumer = new Consumer(config, null, new StringDeserializer(Encoding.UTF8))) 30 | { 31 | consumer.OnError += (_, error) => 32 | Console.WriteLine($"Error: {error}"); 33 | 34 | consumer.OnConsumeError += (_, error) => 35 | Console.WriteLine($"Consume Error: {error}"); 36 | 37 | // consumer.Assign(new List { new TopicPartitionOffset(topic, 0, 0) }); 38 | consumer.Subscribe(new[] { topic }); 39 | 40 | while (true) 41 | { 42 | Message msg; 43 | if (consumer.Consume(out msg, TimeSpan.FromSeconds(1))) 44 | { 45 | Console.WriteLine($"Topic: {msg.Topic} Partition: {msg.Partition} Offset: {msg.Offset} {msg.Value}"); 46 | string rawJson = msg.Value; 47 | try 48 | { 49 | OrderCanceledEvent evt = JsonConvert.DeserializeObject(rawJson); 50 | eventProcessor.HandleOrderCanceledEvent(evt); 51 | var committedOffsets = consumer.CommitAsync(msg).Result; 52 | if (committedOffsets.Error.HasError) 53 | { 54 | Console.WriteLine($"Failed to commit offsets : {committedOffsets.Error.Reason}"); 55 | } 56 | } 57 | catch (Exception ex) 58 | { 59 | Console.WriteLine(ex.StackTrace); 60 | Console.WriteLine($"Failed to handle order activity event : ${ex.ToString()}"); 61 | } 62 | } 63 | } 64 | } 65 | }); 66 | 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/KafkaOrdersConsumer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using Confluent.Kafka; 6 | using Confluent.Kafka.Serialization; 7 | using Newtonsoft.Json; 8 | 9 | namespace PartialFoods.Services.OrderManagementServer 10 | { 11 | public class KafkaOrdersConsumer 12 | { 13 | private string topic; 14 | private Dictionary config; 15 | private OrderAcceptedEventProcessor eventProcessor; 16 | 17 | public KafkaOrdersConsumer(string topic, Dictionary config, OrderAcceptedEventProcessor eventProcessor) 18 | { 19 | this.topic = topic; 20 | this.config = config; 21 | this.eventProcessor = eventProcessor; 22 | } 23 | 24 | public void Consume() 25 | { 26 | Task.Run(() => 27 | { 28 | Console.WriteLine($"Starting Kafka subscription to {topic}"); 29 | using (var consumer = new Consumer(config, null, new StringDeserializer(Encoding.UTF8))) 30 | { 31 | 32 | consumer.OnError += (_, error) => 33 | Console.WriteLine($"Orders Error: {error}"); 34 | 35 | consumer.OnConsumeError += (_, error) => 36 | Console.WriteLine($"Orders Consume Error: {error}"); 37 | 38 | consumer.OnMessage += (_, msg) => 39 | Console.WriteLine($"Orders message available: {msg}"); 40 | 41 | consumer.Subscribe(new[] { topic }); 42 | consumer.Assign(new List { new TopicPartitionOffset(topic, 0, 0) }); 43 | //consumer.Seek(new TopicPartitionOffset(topic, 0, 0)); 44 | while (true) 45 | { 46 | Message msg; 47 | if (consumer.Consume(out msg, TimeSpan.FromSeconds(1))) 48 | { 49 | Console.WriteLine($"Topic: {msg.Topic} Partition: {msg.Partition} Offset: {msg.Offset} {msg.Value}"); 50 | string rawJson = msg.Value; 51 | try 52 | { 53 | OrderAcceptedEvent evt = JsonConvert.DeserializeObject(rawJson); 54 | eventProcessor.HandleOrderAcceptedEvent(evt); 55 | var committedOffsets = consumer.CommitAsync(msg).Result; 56 | if (committedOffsets.Error.HasError) 57 | { 58 | Console.WriteLine($"Failed to commit offsets : {committedOffsets.Error.Reason}"); 59 | } 60 | } 61 | catch (Exception ex) 62 | { 63 | Console.WriteLine(ex.StackTrace); 64 | Console.WriteLine($"Failed to handle order accepted event : ${ex.ToString()}"); 65 | } 66 | } 67 | } 68 | } 69 | }); 70 | 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/Migrations/20171007153926_CreateDatabase.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using Microsoft.EntityFrameworkCore.Metadata; 5 | using Microsoft.EntityFrameworkCore.Migrations; 6 | using Microsoft.EntityFrameworkCore.Storage; 7 | using Microsoft.EntityFrameworkCore.Storage.Internal; 8 | using PartialFoods.Services.OrderManagementServer.Entities; 9 | using System; 10 | 11 | namespace PartialFoods.Services.OrderManagementServer.Migrations 12 | { 13 | [DbContext(typeof(OrdersContext))] 14 | [Migration("20171007153926_CreateDatabase")] 15 | partial class CreateDatabase 16 | { 17 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 18 | { 19 | #pragma warning disable 612, 618 20 | modelBuilder 21 | .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) 22 | .HasAnnotation("ProductVersion", "2.0.0-rtm-26452"); 23 | 24 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.LineItem", b => 25 | { 26 | b.Property("OrderID"); 27 | 28 | b.Property("SKU"); 29 | 30 | b.Property("Quantity"); 31 | 32 | b.Property("UnitPrice"); 33 | 34 | b.HasKey("OrderID", "SKU"); 35 | 36 | b.ToTable("OrderItems"); 37 | }); 38 | 39 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.Order", b => 40 | { 41 | b.Property("OrderID") 42 | .ValueGeneratedOnAdd(); 43 | 44 | b.Property("CreatedOn"); 45 | 46 | b.Property("TaxRate"); 47 | 48 | b.Property("UserID"); 49 | 50 | b.HasKey("OrderID"); 51 | 52 | b.ToTable("Orders"); 53 | }); 54 | 55 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.LineItem", b => 56 | { 57 | b.HasOne("PartialFoods.Services.OrderManagementServer.Entities.Order") 58 | .WithMany("LineItems") 59 | .HasForeignKey("OrderID") 60 | .OnDelete(DeleteBehavior.Cascade); 61 | }); 62 | #pragma warning restore 612, 618 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/Migrations/20171007153926_CreateDatabase.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace PartialFoods.Services.OrderManagementServer.Migrations 6 | { 7 | public partial class CreateDatabase : Migration 8 | { 9 | protected override void Up(MigrationBuilder migrationBuilder) 10 | { 11 | migrationBuilder.CreateTable( 12 | name: "Orders", 13 | columns: table => new 14 | { 15 | OrderID = table.Column(type: "text", nullable: false), 16 | CreatedOn = table.Column(type: "int8", nullable: false), 17 | TaxRate = table.Column(type: "int4", nullable: false), 18 | UserID = table.Column(type: "text", nullable: true) 19 | }, 20 | constraints: table => 21 | { 22 | table.PrimaryKey("PK_Orders", x => x.OrderID); 23 | }); 24 | 25 | migrationBuilder.CreateTable( 26 | name: "OrderItems", 27 | columns: table => new 28 | { 29 | OrderID = table.Column(type: "text", nullable: false), 30 | SKU = table.Column(type: "text", nullable: false), 31 | Quantity = table.Column(type: "int4", nullable: false), 32 | UnitPrice = table.Column(type: "int4", nullable: false) 33 | }, 34 | constraints: table => 35 | { 36 | table.PrimaryKey("PK_OrderItems", x => new { x.OrderID, x.SKU }); 37 | table.ForeignKey( 38 | name: "FK_OrderItems_Orders_OrderID", 39 | column: x => x.OrderID, 40 | principalTable: "Orders", 41 | principalColumn: "OrderID", 42 | onDelete: ReferentialAction.Cascade); 43 | }); 44 | } 45 | 46 | protected override void Down(MigrationBuilder migrationBuilder) 47 | { 48 | migrationBuilder.DropTable( 49 | name: "OrderItems"); 50 | 51 | migrationBuilder.DropTable( 52 | name: "Orders"); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/Migrations/20171015152123_AddActivities.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using Microsoft.EntityFrameworkCore.Metadata; 5 | using Microsoft.EntityFrameworkCore.Migrations; 6 | using Microsoft.EntityFrameworkCore.Storage; 7 | using Microsoft.EntityFrameworkCore.Storage.Internal; 8 | using PartialFoods.Services.OrderManagementServer.Entities; 9 | using System; 10 | 11 | namespace PartialFoods.Services.OrderManagementServer.Migrations 12 | { 13 | [DbContext(typeof(OrdersContext))] 14 | [Migration("20171015152123_AddActivities")] 15 | partial class AddActivities 16 | { 17 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 18 | { 19 | #pragma warning disable 612, 618 20 | modelBuilder 21 | .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) 22 | .HasAnnotation("ProductVersion", "2.0.0-rtm-26452"); 23 | 24 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.LineItem", b => 25 | { 26 | b.Property("OrderID"); 27 | 28 | b.Property("SKU"); 29 | 30 | b.Property("Quantity"); 31 | 32 | b.Property("UnitPrice"); 33 | 34 | b.HasKey("OrderID", "SKU"); 35 | 36 | b.ToTable("OrderItems"); 37 | }); 38 | 39 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.Order", b => 40 | { 41 | b.Property("OrderID") 42 | .ValueGeneratedOnAdd(); 43 | 44 | b.Property("CreatedOn"); 45 | 46 | b.Property("TaxRate"); 47 | 48 | b.Property("UserID"); 49 | 50 | b.HasKey("OrderID"); 51 | 52 | b.ToTable("Orders"); 53 | }); 54 | 55 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.OrderActivity", b => 56 | { 57 | b.Property("OrderID"); 58 | 59 | b.Property("ActivityID"); 60 | 61 | b.Property("Activity"); 62 | 63 | b.Property("OccuredOn"); 64 | 65 | b.Property("UserID"); 66 | 67 | b.HasKey("OrderID", "ActivityID"); 68 | 69 | b.ToTable("Activities"); 70 | }); 71 | 72 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.LineItem", b => 73 | { 74 | b.HasOne("PartialFoods.Services.OrderManagementServer.Entities.Order") 75 | .WithMany("LineItems") 76 | .HasForeignKey("OrderID") 77 | .OnDelete(DeleteBehavior.Cascade); 78 | }); 79 | 80 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.OrderActivity", b => 81 | { 82 | b.HasOne("PartialFoods.Services.OrderManagementServer.Entities.Order") 83 | .WithMany("Activities") 84 | .HasForeignKey("OrderID") 85 | .OnDelete(DeleteBehavior.Cascade); 86 | }); 87 | #pragma warning restore 612, 618 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/Migrations/20171015152123_AddActivities.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace PartialFoods.Services.OrderManagementServer.Migrations 6 | { 7 | public partial class AddActivities : Migration 8 | { 9 | protected override void Up(MigrationBuilder migrationBuilder) 10 | { 11 | migrationBuilder.CreateTable( 12 | name: "Activities", 13 | columns: table => new 14 | { 15 | OrderID = table.Column(type: "text", nullable: false), 16 | ActivityID = table.Column(type: "text", nullable: false), 17 | Activity = table.Column(type: "int4", nullable: false), 18 | OccuredOn = table.Column(type: "int8", nullable: false), 19 | UserID = table.Column(type: "text", nullable: true) 20 | }, 21 | constraints: table => 22 | { 23 | table.PrimaryKey("PK_Activities", x => new { x.OrderID, x.ActivityID }); 24 | table.ForeignKey( 25 | name: "FK_Activities_Orders_OrderID", 26 | column: x => x.OrderID, 27 | principalTable: "Orders", 28 | principalColumn: "OrderID", 29 | onDelete: ReferentialAction.Cascade); 30 | }); 31 | } 32 | 33 | protected override void Down(MigrationBuilder migrationBuilder) 34 | { 35 | migrationBuilder.DropTable( 36 | name: "Activities"); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/Migrations/20171015152351_RenameActivityToActivityType.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using Microsoft.EntityFrameworkCore.Metadata; 5 | using Microsoft.EntityFrameworkCore.Migrations; 6 | using Microsoft.EntityFrameworkCore.Storage; 7 | using Microsoft.EntityFrameworkCore.Storage.Internal; 8 | using PartialFoods.Services.OrderManagementServer.Entities; 9 | using System; 10 | 11 | namespace PartialFoods.Services.OrderManagementServer.Migrations 12 | { 13 | [DbContext(typeof(OrdersContext))] 14 | [Migration("20171015152351_RenameActivityToActivityType")] 15 | partial class RenameActivityToActivityType 16 | { 17 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 18 | { 19 | #pragma warning disable 612, 618 20 | modelBuilder 21 | .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) 22 | .HasAnnotation("ProductVersion", "2.0.0-rtm-26452"); 23 | 24 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.LineItem", b => 25 | { 26 | b.Property("OrderID"); 27 | 28 | b.Property("SKU"); 29 | 30 | b.Property("Quantity"); 31 | 32 | b.Property("UnitPrice"); 33 | 34 | b.HasKey("OrderID", "SKU"); 35 | 36 | b.ToTable("OrderItems"); 37 | }); 38 | 39 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.Order", b => 40 | { 41 | b.Property("OrderID") 42 | .ValueGeneratedOnAdd(); 43 | 44 | b.Property("CreatedOn"); 45 | 46 | b.Property("TaxRate"); 47 | 48 | b.Property("UserID"); 49 | 50 | b.HasKey("OrderID"); 51 | 52 | b.ToTable("Orders"); 53 | }); 54 | 55 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.OrderActivity", b => 56 | { 57 | b.Property("OrderID"); 58 | 59 | b.Property("ActivityID"); 60 | 61 | b.Property("ActivityType"); 62 | 63 | b.Property("OccuredOn"); 64 | 65 | b.Property("UserID"); 66 | 67 | b.HasKey("OrderID", "ActivityID"); 68 | 69 | b.ToTable("Activities"); 70 | }); 71 | 72 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.LineItem", b => 73 | { 74 | b.HasOne("PartialFoods.Services.OrderManagementServer.Entities.Order") 75 | .WithMany("LineItems") 76 | .HasForeignKey("OrderID") 77 | .OnDelete(DeleteBehavior.Cascade); 78 | }); 79 | 80 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.OrderActivity", b => 81 | { 82 | b.HasOne("PartialFoods.Services.OrderManagementServer.Entities.Order") 83 | .WithMany("Activities") 84 | .HasForeignKey("OrderID") 85 | .OnDelete(DeleteBehavior.Cascade); 86 | }); 87 | #pragma warning restore 612, 618 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/Migrations/20171015152351_RenameActivityToActivityType.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | using System; 3 | using System.Collections.Generic; 4 | 5 | namespace PartialFoods.Services.OrderManagementServer.Migrations 6 | { 7 | public partial class RenameActivityToActivityType : Migration 8 | { 9 | protected override void Up(MigrationBuilder migrationBuilder) 10 | { 11 | migrationBuilder.DropColumn( 12 | name: "Activity", 13 | table: "Activities"); 14 | 15 | migrationBuilder.AddColumn( 16 | name: "ActivityType", 17 | table: "Activities", 18 | type: "int4", 19 | nullable: false, 20 | defaultValue: 0); 21 | } 22 | 23 | protected override void Down(MigrationBuilder migrationBuilder) 24 | { 25 | migrationBuilder.DropColumn( 26 | name: "ActivityType", 27 | table: "Activities"); 28 | 29 | migrationBuilder.AddColumn( 30 | name: "Activity", 31 | table: "Activities", 32 | nullable: false, 33 | defaultValue: 0); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/Migrations/OrdersContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | // 2 | using Microsoft.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore.Infrastructure; 4 | using Microsoft.EntityFrameworkCore.Metadata; 5 | using Microsoft.EntityFrameworkCore.Migrations; 6 | using Microsoft.EntityFrameworkCore.Storage; 7 | using Microsoft.EntityFrameworkCore.Storage.Internal; 8 | using PartialFoods.Services.OrderManagementServer.Entities; 9 | using System; 10 | 11 | namespace PartialFoods.Services.OrderManagementServer.Migrations 12 | { 13 | [DbContext(typeof(OrdersContext))] 14 | partial class OrdersContextModelSnapshot : ModelSnapshot 15 | { 16 | protected override void BuildModel(ModelBuilder modelBuilder) 17 | { 18 | #pragma warning disable 612, 618 19 | modelBuilder 20 | .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) 21 | .HasAnnotation("ProductVersion", "2.0.0-rtm-26452"); 22 | 23 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.LineItem", b => 24 | { 25 | b.Property("OrderID"); 26 | 27 | b.Property("SKU"); 28 | 29 | b.Property("Quantity"); 30 | 31 | b.Property("UnitPrice"); 32 | 33 | b.HasKey("OrderID", "SKU"); 34 | 35 | b.ToTable("OrderItems"); 36 | }); 37 | 38 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.Order", b => 39 | { 40 | b.Property("OrderID") 41 | .ValueGeneratedOnAdd(); 42 | 43 | b.Property("CreatedOn"); 44 | 45 | b.Property("TaxRate"); 46 | 47 | b.Property("UserID"); 48 | 49 | b.HasKey("OrderID"); 50 | 51 | b.ToTable("Orders"); 52 | }); 53 | 54 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.OrderActivity", b => 55 | { 56 | b.Property("OrderID"); 57 | 58 | b.Property("ActivityID"); 59 | 60 | b.Property("ActivityType"); 61 | 62 | b.Property("OccuredOn"); 63 | 64 | b.Property("UserID"); 65 | 66 | b.HasKey("OrderID", "ActivityID"); 67 | 68 | b.ToTable("Activities"); 69 | }); 70 | 71 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.LineItem", b => 72 | { 73 | b.HasOne("PartialFoods.Services.OrderManagementServer.Entities.Order") 74 | .WithMany("LineItems") 75 | .HasForeignKey("OrderID") 76 | .OnDelete(DeleteBehavior.Cascade); 77 | }); 78 | 79 | modelBuilder.Entity("PartialFoods.Services.OrderManagementServer.Entities.OrderActivity", b => 80 | { 81 | b.HasOne("PartialFoods.Services.OrderManagementServer.Entities.Order") 82 | .WithMany("Activities") 83 | .HasForeignKey("OrderID") 84 | .OnDelete(DeleteBehavior.Cascade); 85 | }); 86 | #pragma warning restore 612, 618 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/OrderAcceptedEvent.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Newtonsoft.Json; 3 | 4 | namespace PartialFoods.Services.OrderManagementServer 5 | { 6 | public class OrderAcceptedEvent 7 | { 8 | [JsonProperty("order_id")] 9 | public string OrderID; 10 | 11 | [JsonProperty("created_on")] 12 | public ulong CreatedOn; 13 | 14 | [JsonProperty("user_id")] 15 | public string UserID; 16 | 17 | [JsonProperty("tax_rate")] 18 | public uint TaxRate; 19 | 20 | [JsonProperty("line_items")] 21 | public ICollection LineItems; 22 | } 23 | 24 | public class EventLineItem 25 | { 26 | [JsonProperty("sku")] 27 | public string SKU; 28 | 29 | [JsonProperty("unit_price")] 30 | public uint UnitPrice; 31 | 32 | [JsonProperty("quantity")] 33 | public uint Quantity; 34 | } 35 | } -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/OrderAcceptedEventProcessor.cs: -------------------------------------------------------------------------------- 1 | using PartialFoods.Services.OrderManagementServer.Entities; 2 | using System.Linq; 3 | using System; 4 | 5 | namespace PartialFoods.Services.OrderManagementServer 6 | { 7 | public class OrderAcceptedEventProcessor 8 | { 9 | private IOrderRepository orderRepository; 10 | 11 | public OrderAcceptedEventProcessor(IOrderRepository repository) 12 | { 13 | this.orderRepository = repository; 14 | } 15 | 16 | public bool HandleOrderAcceptedEvent(OrderAcceptedEvent evt) 17 | { 18 | Console.WriteLine("Handling order accepted event."); 19 | Order result = orderRepository.Add(new Order 20 | { 21 | OrderID = evt.OrderID, 22 | CreatedOn = (long)evt.CreatedOn, 23 | TaxRate = (int)evt.TaxRate, 24 | UserID = evt.UserID, 25 | LineItems = (from itm in evt.LineItems 26 | select new PartialFoods.Services.OrderManagementServer.Entities.LineItem 27 | { 28 | SKU = itm.SKU, 29 | OrderID = evt.OrderID, 30 | Quantity = (int)itm.Quantity, 31 | UnitPrice = (int)itm.UnitPrice 32 | }).ToArray() 33 | }); 34 | 35 | return (result != null); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/OrderCanceledEvent.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | 3 | namespace PartialFoods.Services.OrderManagementServer 4 | { 5 | public class OrderCanceledEvent 6 | { 7 | [JsonProperty("created_on")] 8 | public ulong CreatedOn { get; set; } 9 | 10 | [JsonProperty("order_id")] 11 | public string OrderID { get; set; } 12 | 13 | [JsonProperty("user_id")] 14 | public string UserID { get; set; } 15 | 16 | [JsonProperty("event_id")] 17 | public string EventID { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/OrderCanceledEventProcessor.cs: -------------------------------------------------------------------------------- 1 | using PartialFoods.Services.OrderManagementServer.Entities; 2 | using System; 3 | using System.Linq; 4 | 5 | namespace PartialFoods.Services.OrderManagementServer 6 | { 7 | public class OrderCanceledEventProcessor 8 | { 9 | private IOrderRepository orderRepository; 10 | 11 | public OrderCanceledEventProcessor(IOrderRepository orderRepository) 12 | { 13 | this.orderRepository = orderRepository; 14 | } 15 | 16 | public bool HandleOrderCanceledEvent(OrderCanceledEvent orderCanceledEvent) 17 | { 18 | Console.WriteLine("Handling order canceled event"); 19 | 20 | var result = this.orderRepository.AddActivity(new OrderActivity 21 | { 22 | OccuredOn = (long)orderCanceledEvent.CreatedOn, 23 | ActivityID = orderCanceledEvent.EventID, 24 | UserID = orderCanceledEvent.UserID, 25 | OrderID = orderCanceledEvent.OrderID, 26 | ActivityType = ActivityType.Canceled 27 | }); 28 | return (result != null); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/OrderManagementImpl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | using PartialFoods.Services; 5 | using Grpc.Core.Utils; 6 | using grpc = global::Grpc.Core; 7 | using PartialFoods.Services.OrderManagementServer.Entities; 8 | 9 | namespace PartialFoods.Services.OrderManagementServer 10 | { 11 | public class OrderManagementImpl : OrderManagement.OrderManagementBase 12 | { 13 | private IOrderRepository repository; 14 | 15 | public OrderManagementImpl(IOrderRepository repository) 16 | { 17 | this.repository = repository; 18 | } 19 | 20 | public override Task OrderExists(GetOrderRequest request, grpc::ServerCallContext context) 21 | { 22 | bool exists = repository.OrderExists(request.OrderID); 23 | var resp = new OrderExistsResponse 24 | { 25 | Exists = exists, 26 | OrderID = request.OrderID 27 | }; 28 | return Task.FromResult(resp); 29 | } 30 | public override Task GetOrder(GetOrderRequest request, grpc::ServerCallContext context) 31 | { 32 | GetOrderResponse response = new GetOrderResponse(); 33 | 34 | Order order = repository.GetOrder(request.OrderID); 35 | if (order != null) 36 | { 37 | response.OrderID = order.OrderID; 38 | response.CreatedOn = (ulong)order.CreatedOn; 39 | response.TaxRate = (uint)order.TaxRate; 40 | foreach (var li in order.LineItems) 41 | { 42 | response.LineItems.Add(new LineItem 43 | { 44 | SKU = li.SKU, 45 | Quantity = (uint)li.Quantity, 46 | UnitPrice = (uint)li.UnitPrice, 47 | }); 48 | } 49 | var status = OrderStatus.Open; 50 | if (order.Activities.FirstOrDefault(a => a.ActivityType == ActivityType.Canceled) != null) 51 | { 52 | status = OrderStatus.Canceled; 53 | } 54 | response.Status = status; 55 | } 56 | 57 | return Task.FromResult(response); 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/PartialFoods.Services.OrderManagementServer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Exe 4 | netcoreapp2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Grpc.Core; 4 | using System.Linq; 5 | using System.Collections.Generic; 6 | using Confluent.Kafka; 7 | using Confluent.Kafka.Serialization; 8 | using System.Text; 9 | using PartialFoods.Services.OrderManagementServer.Entities; 10 | using Microsoft.Extensions.Configuration; 11 | using Microsoft.Extensions.Logging; 12 | using System.IO; 13 | using System.Threading; 14 | using Grpc.Reflection; 15 | using Grpc.Reflection.V1Alpha; 16 | 17 | namespace PartialFoods.Services.OrderManagementServer 18 | { 19 | class Program 20 | { 21 | public static IConfigurationRoot Configuration { get; set; } 22 | 23 | private static ManualResetEvent mre = new ManualResetEvent(false); 24 | 25 | static void Main(string[] args) 26 | { 27 | var builder = new ConfigurationBuilder() 28 | .SetBasePath(Directory.GetCurrentDirectory()) 29 | .AddJsonFile("appsettings.json") 30 | .AddEnvironmentVariables(); 31 | 32 | 33 | Configuration = builder.Build(); 34 | 35 | Microsoft.Extensions.Logging.ILoggerFactory loggerFactory = new LoggerFactory() 36 | .AddConsole() 37 | .AddDebug(); 38 | 39 | ILogger logger = loggerFactory.CreateLogger(); 40 | 41 | string brokerList = Configuration["kafkaclient:brokerlist"]; 42 | const string topic = "orders"; 43 | const string canceledTopic = "canceledorders"; 44 | 45 | var config = new Dictionary 46 | { 47 | { "group.id", "order-management" }, 48 | { "enable.auto.commit", false }, 49 | { "bootstrap.servers", brokerList } 50 | }; 51 | 52 | var context = new OrdersContext(Configuration["postgres:connectionstring"]); 53 | var repo = new OrderRepository(context); 54 | var eventProcessor = new OrderAcceptedEventProcessor(repo); 55 | var canceledProcessor = new OrderCanceledEventProcessor(repo); 56 | 57 | var orderConsumer = new KafkaOrdersConsumer(topic, config, eventProcessor); 58 | var activityConsumer = new KafkaActivitiesConsumer(canceledTopic, config, canceledProcessor); 59 | orderConsumer.Consume(); 60 | activityConsumer.Consume(); 61 | 62 | var port = int.Parse(Configuration["service:port"]); 63 | 64 | var refImpl = new ReflectionServiceImpl( 65 | ServerReflection.Descriptor, OrderManagement.Descriptor); 66 | Server server = new Server 67 | { 68 | Services = { OrderManagement.BindService(new OrderManagementImpl(repo)), 69 | ServerReflection.BindService(refImpl) }, 70 | Ports = { new ServerPort("localhost", port, ServerCredentials.Insecure) } 71 | }; 72 | server.Start(); 73 | logger.LogInformation("Order management gRPC service listening on port " + port); 74 | 75 | mre.WaitOne(); 76 | 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/RPC/Ordermgmt.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: ordermgmt.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace PartialFoods.Services { 11 | 12 | /// Holder for reflection information generated from ordermgmt.proto 13 | public static partial class OrdermgmtReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for ordermgmt.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static OrdermgmtReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "Cg9vcmRlcm1nbXQucHJvdG8SFVBhcnRpYWxGb29kcy5TZXJ2aWNlcxoScGFy", 26 | "dGlhbGZvb2RzLnByb3RvIiIKD0dldE9yZGVyUmVxdWVzdBIPCgdPcmRlcklE", 27 | "GAEgASgJIvoBChBHZXRPcmRlclJlc3BvbnNlEg8KB09yZGVySUQYASABKAkS", 28 | "EQoJQ3JlYXRlZE9uGAIgASgEEg4KBlVzZXJJRBgDIAEoCRIPCgdUYXhSYXRl", 29 | "GAQgASgNEjkKDFNoaXBwaW5nSW5mbxgFIAEoCzIjLlBhcnRpYWxGb29kcy5T", 30 | "ZXJ2aWNlcy5TaGlwcGluZ0luZm8SMgoJTGluZUl0ZW1zGAYgAygLMh8uUGFy", 31 | "dGlhbEZvb2RzLlNlcnZpY2VzLkxpbmVJdGVtEjIKBlN0YXR1cxgHIAEoDjIi", 32 | "LlBhcnRpYWxGb29kcy5TZXJ2aWNlcy5PcmRlclN0YXR1cyI2ChNPcmRlckV4", 33 | "aXN0c1Jlc3BvbnNlEg8KB09yZGVySUQYASABKAkSDgoGRXhpc3RzGAIgASgI", 34 | "KjIKC09yZGVyU3RhdHVzEgsKB1VOS05PV04QABIICgRPUEVOEAESDAoIQ0FO", 35 | "Q0VMRUQQAjLRAQoPT3JkZXJNYW5hZ2VtZW50ElsKCEdldE9yZGVyEiYuUGFy", 36 | "dGlhbEZvb2RzLlNlcnZpY2VzLkdldE9yZGVyUmVxdWVzdBonLlBhcnRpYWxG", 37 | "b29kcy5TZXJ2aWNlcy5HZXRPcmRlclJlc3BvbnNlEmEKC09yZGVyRXhpc3Rz", 38 | "EiYuUGFydGlhbEZvb2RzLlNlcnZpY2VzLkdldE9yZGVyUmVxdWVzdBoqLlBh", 39 | "cnRpYWxGb29kcy5TZXJ2aWNlcy5PcmRlckV4aXN0c1Jlc3BvbnNlYgZwcm90", 40 | "bzM=")); 41 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 42 | new pbr::FileDescriptor[] { global::PartialFoods.Services.PartialfoodsReflection.Descriptor, }, 43 | new pbr::GeneratedClrTypeInfo(new[] {typeof(global::PartialFoods.Services.OrderStatus), }, new pbr::GeneratedClrTypeInfo[] { 44 | new pbr::GeneratedClrTypeInfo(typeof(global::PartialFoods.Services.GetOrderRequest), global::PartialFoods.Services.GetOrderRequest.Parser, new[]{ "OrderID" }, null, null, null), 45 | new pbr::GeneratedClrTypeInfo(typeof(global::PartialFoods.Services.GetOrderResponse), global::PartialFoods.Services.GetOrderResponse.Parser, new[]{ "OrderID", "CreatedOn", "UserID", "TaxRate", "ShippingInfo", "LineItems", "Status" }, null, null, null), 46 | new pbr::GeneratedClrTypeInfo(typeof(global::PartialFoods.Services.OrderExistsResponse), global::PartialFoods.Services.OrderExistsResponse.Parser, new[]{ "OrderID", "Exists" }, null, null, null) 47 | })); 48 | } 49 | #endregion 50 | 51 | } 52 | #region Enums 53 | public enum OrderStatus { 54 | [pbr::OriginalName("UNKNOWN")] Unknown = 0, 55 | [pbr::OriginalName("OPEN")] Open = 1, 56 | [pbr::OriginalName("CANCELED")] Canceled = 2, 57 | } 58 | 59 | #endregion 60 | 61 | #region Messages 62 | public sealed partial class GetOrderRequest : pb::IMessage { 63 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new GetOrderRequest()); 64 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 65 | public static pb::MessageParser Parser { get { return _parser; } } 66 | 67 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 68 | public static pbr::MessageDescriptor Descriptor { 69 | get { return global::PartialFoods.Services.OrdermgmtReflection.Descriptor.MessageTypes[0]; } 70 | } 71 | 72 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 73 | pbr::MessageDescriptor pb::IMessage.Descriptor { 74 | get { return Descriptor; } 75 | } 76 | 77 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 78 | public GetOrderRequest() { 79 | OnConstruction(); 80 | } 81 | 82 | partial void OnConstruction(); 83 | 84 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 85 | public GetOrderRequest(GetOrderRequest other) : this() { 86 | orderID_ = other.orderID_; 87 | } 88 | 89 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 90 | public GetOrderRequest Clone() { 91 | return new GetOrderRequest(this); 92 | } 93 | 94 | /// Field number for the "OrderID" field. 95 | public const int OrderIDFieldNumber = 1; 96 | private string orderID_ = ""; 97 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 98 | public string OrderID { 99 | get { return orderID_; } 100 | set { 101 | orderID_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 102 | } 103 | } 104 | 105 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 106 | public override bool Equals(object other) { 107 | return Equals(other as GetOrderRequest); 108 | } 109 | 110 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 111 | public bool Equals(GetOrderRequest other) { 112 | if (ReferenceEquals(other, null)) { 113 | return false; 114 | } 115 | if (ReferenceEquals(other, this)) { 116 | return true; 117 | } 118 | if (OrderID != other.OrderID) return false; 119 | return true; 120 | } 121 | 122 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 123 | public override int GetHashCode() { 124 | int hash = 1; 125 | if (OrderID.Length != 0) hash ^= OrderID.GetHashCode(); 126 | return hash; 127 | } 128 | 129 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 130 | public override string ToString() { 131 | return pb::JsonFormatter.ToDiagnosticString(this); 132 | } 133 | 134 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 135 | public void WriteTo(pb::CodedOutputStream output) { 136 | if (OrderID.Length != 0) { 137 | output.WriteRawTag(10); 138 | output.WriteString(OrderID); 139 | } 140 | } 141 | 142 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 143 | public int CalculateSize() { 144 | int size = 0; 145 | if (OrderID.Length != 0) { 146 | size += 1 + pb::CodedOutputStream.ComputeStringSize(OrderID); 147 | } 148 | return size; 149 | } 150 | 151 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 152 | public void MergeFrom(GetOrderRequest other) { 153 | if (other == null) { 154 | return; 155 | } 156 | if (other.OrderID.Length != 0) { 157 | OrderID = other.OrderID; 158 | } 159 | } 160 | 161 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 162 | public void MergeFrom(pb::CodedInputStream input) { 163 | uint tag; 164 | while ((tag = input.ReadTag()) != 0) { 165 | switch(tag) { 166 | default: 167 | input.SkipLastField(); 168 | break; 169 | case 10: { 170 | OrderID = input.ReadString(); 171 | break; 172 | } 173 | } 174 | } 175 | } 176 | 177 | } 178 | 179 | public sealed partial class GetOrderResponse : pb::IMessage { 180 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new GetOrderResponse()); 181 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 182 | public static pb::MessageParser Parser { get { return _parser; } } 183 | 184 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 185 | public static pbr::MessageDescriptor Descriptor { 186 | get { return global::PartialFoods.Services.OrdermgmtReflection.Descriptor.MessageTypes[1]; } 187 | } 188 | 189 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 190 | pbr::MessageDescriptor pb::IMessage.Descriptor { 191 | get { return Descriptor; } 192 | } 193 | 194 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 195 | public GetOrderResponse() { 196 | OnConstruction(); 197 | } 198 | 199 | partial void OnConstruction(); 200 | 201 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 202 | public GetOrderResponse(GetOrderResponse other) : this() { 203 | orderID_ = other.orderID_; 204 | createdOn_ = other.createdOn_; 205 | userID_ = other.userID_; 206 | taxRate_ = other.taxRate_; 207 | ShippingInfo = other.shippingInfo_ != null ? other.ShippingInfo.Clone() : null; 208 | lineItems_ = other.lineItems_.Clone(); 209 | status_ = other.status_; 210 | } 211 | 212 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 213 | public GetOrderResponse Clone() { 214 | return new GetOrderResponse(this); 215 | } 216 | 217 | /// Field number for the "OrderID" field. 218 | public const int OrderIDFieldNumber = 1; 219 | private string orderID_ = ""; 220 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 221 | public string OrderID { 222 | get { return orderID_; } 223 | set { 224 | orderID_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 225 | } 226 | } 227 | 228 | /// Field number for the "CreatedOn" field. 229 | public const int CreatedOnFieldNumber = 2; 230 | private ulong createdOn_; 231 | /// 232 | /// UTC milliseconds of time terminal created transaction 233 | /// 234 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 235 | public ulong CreatedOn { 236 | get { return createdOn_; } 237 | set { 238 | createdOn_ = value; 239 | } 240 | } 241 | 242 | /// Field number for the "UserID" field. 243 | public const int UserIDFieldNumber = 3; 244 | private string userID_ = ""; 245 | /// 246 | /// User ID of the order owner 247 | /// 248 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 249 | public string UserID { 250 | get { return userID_; } 251 | set { 252 | userID_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 253 | } 254 | } 255 | 256 | /// Field number for the "TaxRate" field. 257 | public const int TaxRateFieldNumber = 4; 258 | private uint taxRate_; 259 | /// 260 | /// Percentage rate of tax, whole numbers because reasons 261 | /// 262 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 263 | public uint TaxRate { 264 | get { return taxRate_; } 265 | set { 266 | taxRate_ = value; 267 | } 268 | } 269 | 270 | /// Field number for the "ShippingInfo" field. 271 | public const int ShippingInfoFieldNumber = 5; 272 | private global::PartialFoods.Services.ShippingInfo shippingInfo_; 273 | /// 274 | /// Information on where order is to be shipped 275 | /// 276 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 277 | public global::PartialFoods.Services.ShippingInfo ShippingInfo { 278 | get { return shippingInfo_; } 279 | set { 280 | shippingInfo_ = value; 281 | } 282 | } 283 | 284 | /// Field number for the "LineItems" field. 285 | public const int LineItemsFieldNumber = 6; 286 | private static readonly pb::FieldCodec _repeated_lineItems_codec 287 | = pb::FieldCodec.ForMessage(50, global::PartialFoods.Services.LineItem.Parser); 288 | private readonly pbc::RepeatedField lineItems_ = new pbc::RepeatedField(); 289 | /// 290 | /// Individual line items on a transaction 291 | /// 292 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 293 | public pbc::RepeatedField LineItems { 294 | get { return lineItems_; } 295 | } 296 | 297 | /// Field number for the "Status" field. 298 | public const int StatusFieldNumber = 7; 299 | private global::PartialFoods.Services.OrderStatus status_ = 0; 300 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 301 | public global::PartialFoods.Services.OrderStatus Status { 302 | get { return status_; } 303 | set { 304 | status_ = value; 305 | } 306 | } 307 | 308 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 309 | public override bool Equals(object other) { 310 | return Equals(other as GetOrderResponse); 311 | } 312 | 313 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 314 | public bool Equals(GetOrderResponse other) { 315 | if (ReferenceEquals(other, null)) { 316 | return false; 317 | } 318 | if (ReferenceEquals(other, this)) { 319 | return true; 320 | } 321 | if (OrderID != other.OrderID) return false; 322 | if (CreatedOn != other.CreatedOn) return false; 323 | if (UserID != other.UserID) return false; 324 | if (TaxRate != other.TaxRate) return false; 325 | if (!object.Equals(ShippingInfo, other.ShippingInfo)) return false; 326 | if(!lineItems_.Equals(other.lineItems_)) return false; 327 | if (Status != other.Status) return false; 328 | return true; 329 | } 330 | 331 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 332 | public override int GetHashCode() { 333 | int hash = 1; 334 | if (OrderID.Length != 0) hash ^= OrderID.GetHashCode(); 335 | if (CreatedOn != 0UL) hash ^= CreatedOn.GetHashCode(); 336 | if (UserID.Length != 0) hash ^= UserID.GetHashCode(); 337 | if (TaxRate != 0) hash ^= TaxRate.GetHashCode(); 338 | if (shippingInfo_ != null) hash ^= ShippingInfo.GetHashCode(); 339 | hash ^= lineItems_.GetHashCode(); 340 | if (Status != 0) hash ^= Status.GetHashCode(); 341 | return hash; 342 | } 343 | 344 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 345 | public override string ToString() { 346 | return pb::JsonFormatter.ToDiagnosticString(this); 347 | } 348 | 349 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 350 | public void WriteTo(pb::CodedOutputStream output) { 351 | if (OrderID.Length != 0) { 352 | output.WriteRawTag(10); 353 | output.WriteString(OrderID); 354 | } 355 | if (CreatedOn != 0UL) { 356 | output.WriteRawTag(16); 357 | output.WriteUInt64(CreatedOn); 358 | } 359 | if (UserID.Length != 0) { 360 | output.WriteRawTag(26); 361 | output.WriteString(UserID); 362 | } 363 | if (TaxRate != 0) { 364 | output.WriteRawTag(32); 365 | output.WriteUInt32(TaxRate); 366 | } 367 | if (shippingInfo_ != null) { 368 | output.WriteRawTag(42); 369 | output.WriteMessage(ShippingInfo); 370 | } 371 | lineItems_.WriteTo(output, _repeated_lineItems_codec); 372 | if (Status != 0) { 373 | output.WriteRawTag(56); 374 | output.WriteEnum((int) Status); 375 | } 376 | } 377 | 378 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 379 | public int CalculateSize() { 380 | int size = 0; 381 | if (OrderID.Length != 0) { 382 | size += 1 + pb::CodedOutputStream.ComputeStringSize(OrderID); 383 | } 384 | if (CreatedOn != 0UL) { 385 | size += 1 + pb::CodedOutputStream.ComputeUInt64Size(CreatedOn); 386 | } 387 | if (UserID.Length != 0) { 388 | size += 1 + pb::CodedOutputStream.ComputeStringSize(UserID); 389 | } 390 | if (TaxRate != 0) { 391 | size += 1 + pb::CodedOutputStream.ComputeUInt32Size(TaxRate); 392 | } 393 | if (shippingInfo_ != null) { 394 | size += 1 + pb::CodedOutputStream.ComputeMessageSize(ShippingInfo); 395 | } 396 | size += lineItems_.CalculateSize(_repeated_lineItems_codec); 397 | if (Status != 0) { 398 | size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Status); 399 | } 400 | return size; 401 | } 402 | 403 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 404 | public void MergeFrom(GetOrderResponse other) { 405 | if (other == null) { 406 | return; 407 | } 408 | if (other.OrderID.Length != 0) { 409 | OrderID = other.OrderID; 410 | } 411 | if (other.CreatedOn != 0UL) { 412 | CreatedOn = other.CreatedOn; 413 | } 414 | if (other.UserID.Length != 0) { 415 | UserID = other.UserID; 416 | } 417 | if (other.TaxRate != 0) { 418 | TaxRate = other.TaxRate; 419 | } 420 | if (other.shippingInfo_ != null) { 421 | if (shippingInfo_ == null) { 422 | shippingInfo_ = new global::PartialFoods.Services.ShippingInfo(); 423 | } 424 | ShippingInfo.MergeFrom(other.ShippingInfo); 425 | } 426 | lineItems_.Add(other.lineItems_); 427 | if (other.Status != 0) { 428 | Status = other.Status; 429 | } 430 | } 431 | 432 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 433 | public void MergeFrom(pb::CodedInputStream input) { 434 | uint tag; 435 | while ((tag = input.ReadTag()) != 0) { 436 | switch(tag) { 437 | default: 438 | input.SkipLastField(); 439 | break; 440 | case 10: { 441 | OrderID = input.ReadString(); 442 | break; 443 | } 444 | case 16: { 445 | CreatedOn = input.ReadUInt64(); 446 | break; 447 | } 448 | case 26: { 449 | UserID = input.ReadString(); 450 | break; 451 | } 452 | case 32: { 453 | TaxRate = input.ReadUInt32(); 454 | break; 455 | } 456 | case 42: { 457 | if (shippingInfo_ == null) { 458 | shippingInfo_ = new global::PartialFoods.Services.ShippingInfo(); 459 | } 460 | input.ReadMessage(shippingInfo_); 461 | break; 462 | } 463 | case 50: { 464 | lineItems_.AddEntriesFrom(input, _repeated_lineItems_codec); 465 | break; 466 | } 467 | case 56: { 468 | status_ = (global::PartialFoods.Services.OrderStatus) input.ReadEnum(); 469 | break; 470 | } 471 | } 472 | } 473 | } 474 | 475 | } 476 | 477 | public sealed partial class OrderExistsResponse : pb::IMessage { 478 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OrderExistsResponse()); 479 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 480 | public static pb::MessageParser Parser { get { return _parser; } } 481 | 482 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 483 | public static pbr::MessageDescriptor Descriptor { 484 | get { return global::PartialFoods.Services.OrdermgmtReflection.Descriptor.MessageTypes[2]; } 485 | } 486 | 487 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 488 | pbr::MessageDescriptor pb::IMessage.Descriptor { 489 | get { return Descriptor; } 490 | } 491 | 492 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 493 | public OrderExistsResponse() { 494 | OnConstruction(); 495 | } 496 | 497 | partial void OnConstruction(); 498 | 499 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 500 | public OrderExistsResponse(OrderExistsResponse other) : this() { 501 | orderID_ = other.orderID_; 502 | exists_ = other.exists_; 503 | } 504 | 505 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 506 | public OrderExistsResponse Clone() { 507 | return new OrderExistsResponse(this); 508 | } 509 | 510 | /// Field number for the "OrderID" field. 511 | public const int OrderIDFieldNumber = 1; 512 | private string orderID_ = ""; 513 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 514 | public string OrderID { 515 | get { return orderID_; } 516 | set { 517 | orderID_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 518 | } 519 | } 520 | 521 | /// Field number for the "Exists" field. 522 | public const int ExistsFieldNumber = 2; 523 | private bool exists_; 524 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 525 | public bool Exists { 526 | get { return exists_; } 527 | set { 528 | exists_ = value; 529 | } 530 | } 531 | 532 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 533 | public override bool Equals(object other) { 534 | return Equals(other as OrderExistsResponse); 535 | } 536 | 537 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 538 | public bool Equals(OrderExistsResponse other) { 539 | if (ReferenceEquals(other, null)) { 540 | return false; 541 | } 542 | if (ReferenceEquals(other, this)) { 543 | return true; 544 | } 545 | if (OrderID != other.OrderID) return false; 546 | if (Exists != other.Exists) return false; 547 | return true; 548 | } 549 | 550 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 551 | public override int GetHashCode() { 552 | int hash = 1; 553 | if (OrderID.Length != 0) hash ^= OrderID.GetHashCode(); 554 | if (Exists != false) hash ^= Exists.GetHashCode(); 555 | return hash; 556 | } 557 | 558 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 559 | public override string ToString() { 560 | return pb::JsonFormatter.ToDiagnosticString(this); 561 | } 562 | 563 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 564 | public void WriteTo(pb::CodedOutputStream output) { 565 | if (OrderID.Length != 0) { 566 | output.WriteRawTag(10); 567 | output.WriteString(OrderID); 568 | } 569 | if (Exists != false) { 570 | output.WriteRawTag(16); 571 | output.WriteBool(Exists); 572 | } 573 | } 574 | 575 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 576 | public int CalculateSize() { 577 | int size = 0; 578 | if (OrderID.Length != 0) { 579 | size += 1 + pb::CodedOutputStream.ComputeStringSize(OrderID); 580 | } 581 | if (Exists != false) { 582 | size += 1 + 1; 583 | } 584 | return size; 585 | } 586 | 587 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 588 | public void MergeFrom(OrderExistsResponse other) { 589 | if (other == null) { 590 | return; 591 | } 592 | if (other.OrderID.Length != 0) { 593 | OrderID = other.OrderID; 594 | } 595 | if (other.Exists != false) { 596 | Exists = other.Exists; 597 | } 598 | } 599 | 600 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 601 | public void MergeFrom(pb::CodedInputStream input) { 602 | uint tag; 603 | while ((tag = input.ReadTag()) != 0) { 604 | switch(tag) { 605 | default: 606 | input.SkipLastField(); 607 | break; 608 | case 10: { 609 | OrderID = input.ReadString(); 610 | break; 611 | } 612 | case 16: { 613 | Exists = input.ReadBool(); 614 | break; 615 | } 616 | } 617 | } 618 | } 619 | 620 | } 621 | 622 | #endregion 623 | 624 | } 625 | 626 | #endregion Designer generated code 627 | -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/RPC/OrdermgmtGrpc.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: ordermgmt.proto 3 | #pragma warning disable 1591 4 | #region Designer generated code 5 | 6 | using System; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | using grpc = global::Grpc.Core; 10 | 11 | namespace PartialFoods.Services { 12 | public static partial class OrderManagement 13 | { 14 | static readonly string __ServiceName = "PartialFoods.Services.OrderManagement"; 15 | 16 | static readonly grpc::Marshaller __Marshaller_GetOrderRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::PartialFoods.Services.GetOrderRequest.Parser.ParseFrom); 17 | static readonly grpc::Marshaller __Marshaller_GetOrderResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::PartialFoods.Services.GetOrderResponse.Parser.ParseFrom); 18 | static readonly grpc::Marshaller __Marshaller_OrderExistsResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::PartialFoods.Services.OrderExistsResponse.Parser.ParseFrom); 19 | 20 | static readonly grpc::Method __Method_GetOrder = new grpc::Method( 21 | grpc::MethodType.Unary, 22 | __ServiceName, 23 | "GetOrder", 24 | __Marshaller_GetOrderRequest, 25 | __Marshaller_GetOrderResponse); 26 | 27 | static readonly grpc::Method __Method_OrderExists = new grpc::Method( 28 | grpc::MethodType.Unary, 29 | __ServiceName, 30 | "OrderExists", 31 | __Marshaller_GetOrderRequest, 32 | __Marshaller_OrderExistsResponse); 33 | 34 | /// Service descriptor 35 | public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor 36 | { 37 | get { return global::PartialFoods.Services.OrdermgmtReflection.Descriptor.Services[0]; } 38 | } 39 | 40 | /// Base class for server-side implementations of OrderManagement 41 | public abstract partial class OrderManagementBase 42 | { 43 | public virtual global::System.Threading.Tasks.Task GetOrder(global::PartialFoods.Services.GetOrderRequest request, grpc::ServerCallContext context) 44 | { 45 | throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); 46 | } 47 | 48 | public virtual global::System.Threading.Tasks.Task OrderExists(global::PartialFoods.Services.GetOrderRequest request, grpc::ServerCallContext context) 49 | { 50 | throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); 51 | } 52 | 53 | } 54 | 55 | /// Client for OrderManagement 56 | public partial class OrderManagementClient : grpc::ClientBase 57 | { 58 | /// Creates a new client for OrderManagement 59 | /// The channel to use to make remote calls. 60 | public OrderManagementClient(grpc::Channel channel) : base(channel) 61 | { 62 | } 63 | /// Creates a new client for OrderManagement that uses a custom CallInvoker. 64 | /// The callInvoker to use to make remote calls. 65 | public OrderManagementClient(grpc::CallInvoker callInvoker) : base(callInvoker) 66 | { 67 | } 68 | /// Protected parameterless constructor to allow creation of test doubles. 69 | protected OrderManagementClient() : base() 70 | { 71 | } 72 | /// Protected constructor to allow creation of configured clients. 73 | /// The client configuration. 74 | protected OrderManagementClient(ClientBaseConfiguration configuration) : base(configuration) 75 | { 76 | } 77 | 78 | public virtual global::PartialFoods.Services.GetOrderResponse GetOrder(global::PartialFoods.Services.GetOrderRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) 79 | { 80 | return GetOrder(request, new grpc::CallOptions(headers, deadline, cancellationToken)); 81 | } 82 | public virtual global::PartialFoods.Services.GetOrderResponse GetOrder(global::PartialFoods.Services.GetOrderRequest request, grpc::CallOptions options) 83 | { 84 | return CallInvoker.BlockingUnaryCall(__Method_GetOrder, null, options, request); 85 | } 86 | public virtual grpc::AsyncUnaryCall GetOrderAsync(global::PartialFoods.Services.GetOrderRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) 87 | { 88 | return GetOrderAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); 89 | } 90 | public virtual grpc::AsyncUnaryCall GetOrderAsync(global::PartialFoods.Services.GetOrderRequest request, grpc::CallOptions options) 91 | { 92 | return CallInvoker.AsyncUnaryCall(__Method_GetOrder, null, options, request); 93 | } 94 | public virtual global::PartialFoods.Services.OrderExistsResponse OrderExists(global::PartialFoods.Services.GetOrderRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) 95 | { 96 | return OrderExists(request, new grpc::CallOptions(headers, deadline, cancellationToken)); 97 | } 98 | public virtual global::PartialFoods.Services.OrderExistsResponse OrderExists(global::PartialFoods.Services.GetOrderRequest request, grpc::CallOptions options) 99 | { 100 | return CallInvoker.BlockingUnaryCall(__Method_OrderExists, null, options, request); 101 | } 102 | public virtual grpc::AsyncUnaryCall OrderExistsAsync(global::PartialFoods.Services.GetOrderRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) 103 | { 104 | return OrderExistsAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); 105 | } 106 | public virtual grpc::AsyncUnaryCall OrderExistsAsync(global::PartialFoods.Services.GetOrderRequest request, grpc::CallOptions options) 107 | { 108 | return CallInvoker.AsyncUnaryCall(__Method_OrderExists, null, options, request); 109 | } 110 | /// Creates a new instance of client from given ClientBaseConfiguration. 111 | protected override OrderManagementClient NewInstance(ClientBaseConfiguration configuration) 112 | { 113 | return new OrderManagementClient(configuration); 114 | } 115 | } 116 | 117 | /// Creates service definition that can be registered with a server 118 | /// An object implementing the server-side handling logic. 119 | public static grpc::ServerServiceDefinition BindService(OrderManagementBase serviceImpl) 120 | { 121 | return grpc::ServerServiceDefinition.CreateBuilder() 122 | .AddMethod(__Method_GetOrder, serviceImpl.GetOrder) 123 | .AddMethod(__Method_OrderExists, serviceImpl.OrderExists).Build(); 124 | } 125 | 126 | } 127 | } 128 | #endregion 129 | -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/RPC/Partialfoods.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: partialfoods.proto 3 | #pragma warning disable 1591, 0612, 3021 4 | #region Designer generated code 5 | 6 | using pb = global::Google.Protobuf; 7 | using pbc = global::Google.Protobuf.Collections; 8 | using pbr = global::Google.Protobuf.Reflection; 9 | using scg = global::System.Collections.Generic; 10 | namespace PartialFoods.Services { 11 | 12 | /// Holder for reflection information generated from partialfoods.proto 13 | public static partial class PartialfoodsReflection { 14 | 15 | #region Descriptor 16 | /// File descriptor for partialfoods.proto 17 | public static pbr::FileDescriptor Descriptor { 18 | get { return descriptor; } 19 | } 20 | private static pbr::FileDescriptor descriptor; 21 | 22 | static PartialfoodsReflection() { 23 | byte[] descriptorData = global::System.Convert.FromBase64String( 24 | string.Concat( 25 | "ChJwYXJ0aWFsZm9vZHMucHJvdG8SFVBhcnRpYWxGb29kcy5TZXJ2aWNlcyKx", 26 | "AQoMT3JkZXJSZXF1ZXN0EhEKCUNyZWF0ZWRPbhgBIAEoBBIOCgZVc2VySUQY", 27 | "AiABKAkSDwoHVGF4UmF0ZRgDIAEoDRI5CgxTaGlwcGluZ0luZm8YBCABKAsy", 28 | "Iy5QYXJ0aWFsRm9vZHMuU2VydmljZXMuU2hpcHBpbmdJbmZvEjIKCUxpbmVJ", 29 | "dGVtcxgFIAMoCzIfLlBhcnRpYWxGb29kcy5TZXJ2aWNlcy5MaW5lSXRlbSJp", 30 | "CgxTaGlwcGluZ0luZm8SEQoJQWRkcmVzc2VlGAEgASgJEhQKDEFkZHJlc3NM", 31 | "aW5lcxgCIAMoCRIMCgRDaXR5GAMgASgJEg8KB1ppcENvZGUYBCABKAkSEQoJ", 32 | "U3RhdGVDb2RlGAUgASgJIjwKCExpbmVJdGVtEgsKA1NLVRgBIAEoCRIRCglV", 33 | "bml0UHJpY2UYAiABKA0SEAoIUXVhbnRpdHkYAyABKA0iMgoNT3JkZXJSZXNw", 34 | "b25zZRIPCgdPcmRlcklEGAEgASgJEhAKCEFjY2VwdGVkGAIgASgIIjUKEkNh", 35 | "bmNlbE9yZGVyUmVxdWVzdBIPCgdPcmRlcklEGAEgASgJEg4KBlVzZXJJRBgC", 36 | "IAEoCSJSChNDYW5jZWxPcmRlclJlc3BvbnNlEg8KB09yZGVySUQYASABKAkS", 37 | "EAoIQ2FuY2VsZWQYAiABKAgSGAoQQ29uZmlybWF0aW9uQ29kZRgDIAEoCTLO", 38 | "AQoMT3JkZXJDb21tYW5kElgKC1N1Ym1pdE9yZGVyEiMuUGFydGlhbEZvb2Rz", 39 | "LlNlcnZpY2VzLk9yZGVyUmVxdWVzdBokLlBhcnRpYWxGb29kcy5TZXJ2aWNl", 40 | "cy5PcmRlclJlc3BvbnNlEmQKC0NhbmNlbE9yZGVyEikuUGFydGlhbEZvb2Rz", 41 | "LlNlcnZpY2VzLkNhbmNlbE9yZGVyUmVxdWVzdBoqLlBhcnRpYWxGb29kcy5T", 42 | "ZXJ2aWNlcy5DYW5jZWxPcmRlclJlc3BvbnNlYgZwcm90bzM=")); 43 | descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, 44 | new pbr::FileDescriptor[] { }, 45 | new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { 46 | new pbr::GeneratedClrTypeInfo(typeof(global::PartialFoods.Services.OrderRequest), global::PartialFoods.Services.OrderRequest.Parser, new[]{ "CreatedOn", "UserID", "TaxRate", "ShippingInfo", "LineItems" }, null, null, null), 47 | new pbr::GeneratedClrTypeInfo(typeof(global::PartialFoods.Services.ShippingInfo), global::PartialFoods.Services.ShippingInfo.Parser, new[]{ "Addressee", "AddressLines", "City", "ZipCode", "StateCode" }, null, null, null), 48 | new pbr::GeneratedClrTypeInfo(typeof(global::PartialFoods.Services.LineItem), global::PartialFoods.Services.LineItem.Parser, new[]{ "SKU", "UnitPrice", "Quantity" }, null, null, null), 49 | new pbr::GeneratedClrTypeInfo(typeof(global::PartialFoods.Services.OrderResponse), global::PartialFoods.Services.OrderResponse.Parser, new[]{ "OrderID", "Accepted" }, null, null, null), 50 | new pbr::GeneratedClrTypeInfo(typeof(global::PartialFoods.Services.CancelOrderRequest), global::PartialFoods.Services.CancelOrderRequest.Parser, new[]{ "OrderID", "UserID" }, null, null, null), 51 | new pbr::GeneratedClrTypeInfo(typeof(global::PartialFoods.Services.CancelOrderResponse), global::PartialFoods.Services.CancelOrderResponse.Parser, new[]{ "OrderID", "Canceled", "ConfirmationCode" }, null, null, null) 52 | })); 53 | } 54 | #endregion 55 | 56 | } 57 | #region Messages 58 | public sealed partial class OrderRequest : pb::IMessage { 59 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OrderRequest()); 60 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 61 | public static pb::MessageParser Parser { get { return _parser; } } 62 | 63 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 64 | public static pbr::MessageDescriptor Descriptor { 65 | get { return global::PartialFoods.Services.PartialfoodsReflection.Descriptor.MessageTypes[0]; } 66 | } 67 | 68 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 69 | pbr::MessageDescriptor pb::IMessage.Descriptor { 70 | get { return Descriptor; } 71 | } 72 | 73 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 74 | public OrderRequest() { 75 | OnConstruction(); 76 | } 77 | 78 | partial void OnConstruction(); 79 | 80 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 81 | public OrderRequest(OrderRequest other) : this() { 82 | createdOn_ = other.createdOn_; 83 | userID_ = other.userID_; 84 | taxRate_ = other.taxRate_; 85 | ShippingInfo = other.shippingInfo_ != null ? other.ShippingInfo.Clone() : null; 86 | lineItems_ = other.lineItems_.Clone(); 87 | } 88 | 89 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 90 | public OrderRequest Clone() { 91 | return new OrderRequest(this); 92 | } 93 | 94 | /// Field number for the "CreatedOn" field. 95 | public const int CreatedOnFieldNumber = 1; 96 | private ulong createdOn_; 97 | /// 98 | /// UTC milliseconds of time terminal created transaction 99 | /// 100 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 101 | public ulong CreatedOn { 102 | get { return createdOn_; } 103 | set { 104 | createdOn_ = value; 105 | } 106 | } 107 | 108 | /// Field number for the "UserID" field. 109 | public const int UserIDFieldNumber = 2; 110 | private string userID_ = ""; 111 | /// 112 | /// User ID of the order owner 113 | /// 114 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 115 | public string UserID { 116 | get { return userID_; } 117 | set { 118 | userID_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 119 | } 120 | } 121 | 122 | /// Field number for the "TaxRate" field. 123 | public const int TaxRateFieldNumber = 3; 124 | private uint taxRate_; 125 | /// 126 | /// Percentage rate of tax, whole numbers because reasons 127 | /// 128 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 129 | public uint TaxRate { 130 | get { return taxRate_; } 131 | set { 132 | taxRate_ = value; 133 | } 134 | } 135 | 136 | /// Field number for the "ShippingInfo" field. 137 | public const int ShippingInfoFieldNumber = 4; 138 | private global::PartialFoods.Services.ShippingInfo shippingInfo_; 139 | /// 140 | /// Information on where order is to be shipped 141 | /// 142 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 143 | public global::PartialFoods.Services.ShippingInfo ShippingInfo { 144 | get { return shippingInfo_; } 145 | set { 146 | shippingInfo_ = value; 147 | } 148 | } 149 | 150 | /// Field number for the "LineItems" field. 151 | public const int LineItemsFieldNumber = 5; 152 | private static readonly pb::FieldCodec _repeated_lineItems_codec 153 | = pb::FieldCodec.ForMessage(42, global::PartialFoods.Services.LineItem.Parser); 154 | private readonly pbc::RepeatedField lineItems_ = new pbc::RepeatedField(); 155 | /// 156 | /// Individual line items on a transaction 157 | /// 158 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 159 | public pbc::RepeatedField LineItems { 160 | get { return lineItems_; } 161 | } 162 | 163 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 164 | public override bool Equals(object other) { 165 | return Equals(other as OrderRequest); 166 | } 167 | 168 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 169 | public bool Equals(OrderRequest other) { 170 | if (ReferenceEquals(other, null)) { 171 | return false; 172 | } 173 | if (ReferenceEquals(other, this)) { 174 | return true; 175 | } 176 | if (CreatedOn != other.CreatedOn) return false; 177 | if (UserID != other.UserID) return false; 178 | if (TaxRate != other.TaxRate) return false; 179 | if (!object.Equals(ShippingInfo, other.ShippingInfo)) return false; 180 | if(!lineItems_.Equals(other.lineItems_)) return false; 181 | return true; 182 | } 183 | 184 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 185 | public override int GetHashCode() { 186 | int hash = 1; 187 | if (CreatedOn != 0UL) hash ^= CreatedOn.GetHashCode(); 188 | if (UserID.Length != 0) hash ^= UserID.GetHashCode(); 189 | if (TaxRate != 0) hash ^= TaxRate.GetHashCode(); 190 | if (shippingInfo_ != null) hash ^= ShippingInfo.GetHashCode(); 191 | hash ^= lineItems_.GetHashCode(); 192 | return hash; 193 | } 194 | 195 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 196 | public override string ToString() { 197 | return pb::JsonFormatter.ToDiagnosticString(this); 198 | } 199 | 200 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 201 | public void WriteTo(pb::CodedOutputStream output) { 202 | if (CreatedOn != 0UL) { 203 | output.WriteRawTag(8); 204 | output.WriteUInt64(CreatedOn); 205 | } 206 | if (UserID.Length != 0) { 207 | output.WriteRawTag(18); 208 | output.WriteString(UserID); 209 | } 210 | if (TaxRate != 0) { 211 | output.WriteRawTag(24); 212 | output.WriteUInt32(TaxRate); 213 | } 214 | if (shippingInfo_ != null) { 215 | output.WriteRawTag(34); 216 | output.WriteMessage(ShippingInfo); 217 | } 218 | lineItems_.WriteTo(output, _repeated_lineItems_codec); 219 | } 220 | 221 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 222 | public int CalculateSize() { 223 | int size = 0; 224 | if (CreatedOn != 0UL) { 225 | size += 1 + pb::CodedOutputStream.ComputeUInt64Size(CreatedOn); 226 | } 227 | if (UserID.Length != 0) { 228 | size += 1 + pb::CodedOutputStream.ComputeStringSize(UserID); 229 | } 230 | if (TaxRate != 0) { 231 | size += 1 + pb::CodedOutputStream.ComputeUInt32Size(TaxRate); 232 | } 233 | if (shippingInfo_ != null) { 234 | size += 1 + pb::CodedOutputStream.ComputeMessageSize(ShippingInfo); 235 | } 236 | size += lineItems_.CalculateSize(_repeated_lineItems_codec); 237 | return size; 238 | } 239 | 240 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 241 | public void MergeFrom(OrderRequest other) { 242 | if (other == null) { 243 | return; 244 | } 245 | if (other.CreatedOn != 0UL) { 246 | CreatedOn = other.CreatedOn; 247 | } 248 | if (other.UserID.Length != 0) { 249 | UserID = other.UserID; 250 | } 251 | if (other.TaxRate != 0) { 252 | TaxRate = other.TaxRate; 253 | } 254 | if (other.shippingInfo_ != null) { 255 | if (shippingInfo_ == null) { 256 | shippingInfo_ = new global::PartialFoods.Services.ShippingInfo(); 257 | } 258 | ShippingInfo.MergeFrom(other.ShippingInfo); 259 | } 260 | lineItems_.Add(other.lineItems_); 261 | } 262 | 263 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 264 | public void MergeFrom(pb::CodedInputStream input) { 265 | uint tag; 266 | while ((tag = input.ReadTag()) != 0) { 267 | switch(tag) { 268 | default: 269 | input.SkipLastField(); 270 | break; 271 | case 8: { 272 | CreatedOn = input.ReadUInt64(); 273 | break; 274 | } 275 | case 18: { 276 | UserID = input.ReadString(); 277 | break; 278 | } 279 | case 24: { 280 | TaxRate = input.ReadUInt32(); 281 | break; 282 | } 283 | case 34: { 284 | if (shippingInfo_ == null) { 285 | shippingInfo_ = new global::PartialFoods.Services.ShippingInfo(); 286 | } 287 | input.ReadMessage(shippingInfo_); 288 | break; 289 | } 290 | case 42: { 291 | lineItems_.AddEntriesFrom(input, _repeated_lineItems_codec); 292 | break; 293 | } 294 | } 295 | } 296 | } 297 | 298 | } 299 | 300 | public sealed partial class ShippingInfo : pb::IMessage { 301 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ShippingInfo()); 302 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 303 | public static pb::MessageParser Parser { get { return _parser; } } 304 | 305 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 306 | public static pbr::MessageDescriptor Descriptor { 307 | get { return global::PartialFoods.Services.PartialfoodsReflection.Descriptor.MessageTypes[1]; } 308 | } 309 | 310 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 311 | pbr::MessageDescriptor pb::IMessage.Descriptor { 312 | get { return Descriptor; } 313 | } 314 | 315 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 316 | public ShippingInfo() { 317 | OnConstruction(); 318 | } 319 | 320 | partial void OnConstruction(); 321 | 322 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 323 | public ShippingInfo(ShippingInfo other) : this() { 324 | addressee_ = other.addressee_; 325 | addressLines_ = other.addressLines_.Clone(); 326 | city_ = other.city_; 327 | zipCode_ = other.zipCode_; 328 | stateCode_ = other.stateCode_; 329 | } 330 | 331 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 332 | public ShippingInfo Clone() { 333 | return new ShippingInfo(this); 334 | } 335 | 336 | /// Field number for the "Addressee" field. 337 | public const int AddresseeFieldNumber = 1; 338 | private string addressee_ = ""; 339 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 340 | public string Addressee { 341 | get { return addressee_; } 342 | set { 343 | addressee_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 344 | } 345 | } 346 | 347 | /// Field number for the "AddressLines" field. 348 | public const int AddressLinesFieldNumber = 2; 349 | private static readonly pb::FieldCodec _repeated_addressLines_codec 350 | = pb::FieldCodec.ForString(18); 351 | private readonly pbc::RepeatedField addressLines_ = new pbc::RepeatedField(); 352 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 353 | public pbc::RepeatedField AddressLines { 354 | get { return addressLines_; } 355 | } 356 | 357 | /// Field number for the "City" field. 358 | public const int CityFieldNumber = 3; 359 | private string city_ = ""; 360 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 361 | public string City { 362 | get { return city_; } 363 | set { 364 | city_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 365 | } 366 | } 367 | 368 | /// Field number for the "ZipCode" field. 369 | public const int ZipCodeFieldNumber = 4; 370 | private string zipCode_ = ""; 371 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 372 | public string ZipCode { 373 | get { return zipCode_; } 374 | set { 375 | zipCode_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 376 | } 377 | } 378 | 379 | /// Field number for the "StateCode" field. 380 | public const int StateCodeFieldNumber = 5; 381 | private string stateCode_ = ""; 382 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 383 | public string StateCode { 384 | get { return stateCode_; } 385 | set { 386 | stateCode_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 387 | } 388 | } 389 | 390 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 391 | public override bool Equals(object other) { 392 | return Equals(other as ShippingInfo); 393 | } 394 | 395 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 396 | public bool Equals(ShippingInfo other) { 397 | if (ReferenceEquals(other, null)) { 398 | return false; 399 | } 400 | if (ReferenceEquals(other, this)) { 401 | return true; 402 | } 403 | if (Addressee != other.Addressee) return false; 404 | if(!addressLines_.Equals(other.addressLines_)) return false; 405 | if (City != other.City) return false; 406 | if (ZipCode != other.ZipCode) return false; 407 | if (StateCode != other.StateCode) return false; 408 | return true; 409 | } 410 | 411 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 412 | public override int GetHashCode() { 413 | int hash = 1; 414 | if (Addressee.Length != 0) hash ^= Addressee.GetHashCode(); 415 | hash ^= addressLines_.GetHashCode(); 416 | if (City.Length != 0) hash ^= City.GetHashCode(); 417 | if (ZipCode.Length != 0) hash ^= ZipCode.GetHashCode(); 418 | if (StateCode.Length != 0) hash ^= StateCode.GetHashCode(); 419 | return hash; 420 | } 421 | 422 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 423 | public override string ToString() { 424 | return pb::JsonFormatter.ToDiagnosticString(this); 425 | } 426 | 427 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 428 | public void WriteTo(pb::CodedOutputStream output) { 429 | if (Addressee.Length != 0) { 430 | output.WriteRawTag(10); 431 | output.WriteString(Addressee); 432 | } 433 | addressLines_.WriteTo(output, _repeated_addressLines_codec); 434 | if (City.Length != 0) { 435 | output.WriteRawTag(26); 436 | output.WriteString(City); 437 | } 438 | if (ZipCode.Length != 0) { 439 | output.WriteRawTag(34); 440 | output.WriteString(ZipCode); 441 | } 442 | if (StateCode.Length != 0) { 443 | output.WriteRawTag(42); 444 | output.WriteString(StateCode); 445 | } 446 | } 447 | 448 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 449 | public int CalculateSize() { 450 | int size = 0; 451 | if (Addressee.Length != 0) { 452 | size += 1 + pb::CodedOutputStream.ComputeStringSize(Addressee); 453 | } 454 | size += addressLines_.CalculateSize(_repeated_addressLines_codec); 455 | if (City.Length != 0) { 456 | size += 1 + pb::CodedOutputStream.ComputeStringSize(City); 457 | } 458 | if (ZipCode.Length != 0) { 459 | size += 1 + pb::CodedOutputStream.ComputeStringSize(ZipCode); 460 | } 461 | if (StateCode.Length != 0) { 462 | size += 1 + pb::CodedOutputStream.ComputeStringSize(StateCode); 463 | } 464 | return size; 465 | } 466 | 467 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 468 | public void MergeFrom(ShippingInfo other) { 469 | if (other == null) { 470 | return; 471 | } 472 | if (other.Addressee.Length != 0) { 473 | Addressee = other.Addressee; 474 | } 475 | addressLines_.Add(other.addressLines_); 476 | if (other.City.Length != 0) { 477 | City = other.City; 478 | } 479 | if (other.ZipCode.Length != 0) { 480 | ZipCode = other.ZipCode; 481 | } 482 | if (other.StateCode.Length != 0) { 483 | StateCode = other.StateCode; 484 | } 485 | } 486 | 487 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 488 | public void MergeFrom(pb::CodedInputStream input) { 489 | uint tag; 490 | while ((tag = input.ReadTag()) != 0) { 491 | switch(tag) { 492 | default: 493 | input.SkipLastField(); 494 | break; 495 | case 10: { 496 | Addressee = input.ReadString(); 497 | break; 498 | } 499 | case 18: { 500 | addressLines_.AddEntriesFrom(input, _repeated_addressLines_codec); 501 | break; 502 | } 503 | case 26: { 504 | City = input.ReadString(); 505 | break; 506 | } 507 | case 34: { 508 | ZipCode = input.ReadString(); 509 | break; 510 | } 511 | case 42: { 512 | StateCode = input.ReadString(); 513 | break; 514 | } 515 | } 516 | } 517 | } 518 | 519 | } 520 | 521 | public sealed partial class LineItem : pb::IMessage { 522 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new LineItem()); 523 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 524 | public static pb::MessageParser Parser { get { return _parser; } } 525 | 526 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 527 | public static pbr::MessageDescriptor Descriptor { 528 | get { return global::PartialFoods.Services.PartialfoodsReflection.Descriptor.MessageTypes[2]; } 529 | } 530 | 531 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 532 | pbr::MessageDescriptor pb::IMessage.Descriptor { 533 | get { return Descriptor; } 534 | } 535 | 536 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 537 | public LineItem() { 538 | OnConstruction(); 539 | } 540 | 541 | partial void OnConstruction(); 542 | 543 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 544 | public LineItem(LineItem other) : this() { 545 | sKU_ = other.sKU_; 546 | unitPrice_ = other.unitPrice_; 547 | quantity_ = other.quantity_; 548 | } 549 | 550 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 551 | public LineItem Clone() { 552 | return new LineItem(this); 553 | } 554 | 555 | /// Field number for the "SKU" field. 556 | public const int SKUFieldNumber = 1; 557 | private string sKU_ = ""; 558 | /// 559 | /// Stock Keeping Unit of inventory item being purchased 560 | /// 561 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 562 | public string SKU { 563 | get { return sKU_; } 564 | set { 565 | sKU_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 566 | } 567 | } 568 | 569 | /// Field number for the "UnitPrice" field. 570 | public const int UnitPriceFieldNumber = 2; 571 | private uint unitPrice_; 572 | /// 573 | /// Price for a single item 574 | /// 575 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 576 | public uint UnitPrice { 577 | get { return unitPrice_; } 578 | set { 579 | unitPrice_ = value; 580 | } 581 | } 582 | 583 | /// Field number for the "Quantity" field. 584 | public const int QuantityFieldNumber = 3; 585 | private uint quantity_; 586 | /// 587 | /// Quantity of items purchased 588 | /// 589 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 590 | public uint Quantity { 591 | get { return quantity_; } 592 | set { 593 | quantity_ = value; 594 | } 595 | } 596 | 597 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 598 | public override bool Equals(object other) { 599 | return Equals(other as LineItem); 600 | } 601 | 602 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 603 | public bool Equals(LineItem other) { 604 | if (ReferenceEquals(other, null)) { 605 | return false; 606 | } 607 | if (ReferenceEquals(other, this)) { 608 | return true; 609 | } 610 | if (SKU != other.SKU) return false; 611 | if (UnitPrice != other.UnitPrice) return false; 612 | if (Quantity != other.Quantity) return false; 613 | return true; 614 | } 615 | 616 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 617 | public override int GetHashCode() { 618 | int hash = 1; 619 | if (SKU.Length != 0) hash ^= SKU.GetHashCode(); 620 | if (UnitPrice != 0) hash ^= UnitPrice.GetHashCode(); 621 | if (Quantity != 0) hash ^= Quantity.GetHashCode(); 622 | return hash; 623 | } 624 | 625 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 626 | public override string ToString() { 627 | return pb::JsonFormatter.ToDiagnosticString(this); 628 | } 629 | 630 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 631 | public void WriteTo(pb::CodedOutputStream output) { 632 | if (SKU.Length != 0) { 633 | output.WriteRawTag(10); 634 | output.WriteString(SKU); 635 | } 636 | if (UnitPrice != 0) { 637 | output.WriteRawTag(16); 638 | output.WriteUInt32(UnitPrice); 639 | } 640 | if (Quantity != 0) { 641 | output.WriteRawTag(24); 642 | output.WriteUInt32(Quantity); 643 | } 644 | } 645 | 646 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 647 | public int CalculateSize() { 648 | int size = 0; 649 | if (SKU.Length != 0) { 650 | size += 1 + pb::CodedOutputStream.ComputeStringSize(SKU); 651 | } 652 | if (UnitPrice != 0) { 653 | size += 1 + pb::CodedOutputStream.ComputeUInt32Size(UnitPrice); 654 | } 655 | if (Quantity != 0) { 656 | size += 1 + pb::CodedOutputStream.ComputeUInt32Size(Quantity); 657 | } 658 | return size; 659 | } 660 | 661 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 662 | public void MergeFrom(LineItem other) { 663 | if (other == null) { 664 | return; 665 | } 666 | if (other.SKU.Length != 0) { 667 | SKU = other.SKU; 668 | } 669 | if (other.UnitPrice != 0) { 670 | UnitPrice = other.UnitPrice; 671 | } 672 | if (other.Quantity != 0) { 673 | Quantity = other.Quantity; 674 | } 675 | } 676 | 677 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 678 | public void MergeFrom(pb::CodedInputStream input) { 679 | uint tag; 680 | while ((tag = input.ReadTag()) != 0) { 681 | switch(tag) { 682 | default: 683 | input.SkipLastField(); 684 | break; 685 | case 10: { 686 | SKU = input.ReadString(); 687 | break; 688 | } 689 | case 16: { 690 | UnitPrice = input.ReadUInt32(); 691 | break; 692 | } 693 | case 24: { 694 | Quantity = input.ReadUInt32(); 695 | break; 696 | } 697 | } 698 | } 699 | } 700 | 701 | } 702 | 703 | public sealed partial class OrderResponse : pb::IMessage { 704 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new OrderResponse()); 705 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 706 | public static pb::MessageParser Parser { get { return _parser; } } 707 | 708 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 709 | public static pbr::MessageDescriptor Descriptor { 710 | get { return global::PartialFoods.Services.PartialfoodsReflection.Descriptor.MessageTypes[3]; } 711 | } 712 | 713 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 714 | pbr::MessageDescriptor pb::IMessage.Descriptor { 715 | get { return Descriptor; } 716 | } 717 | 718 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 719 | public OrderResponse() { 720 | OnConstruction(); 721 | } 722 | 723 | partial void OnConstruction(); 724 | 725 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 726 | public OrderResponse(OrderResponse other) : this() { 727 | orderID_ = other.orderID_; 728 | accepted_ = other.accepted_; 729 | } 730 | 731 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 732 | public OrderResponse Clone() { 733 | return new OrderResponse(this); 734 | } 735 | 736 | /// Field number for the "OrderID" field. 737 | public const int OrderIDFieldNumber = 1; 738 | private string orderID_ = ""; 739 | /// 740 | /// UUID of the order 741 | /// 742 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 743 | public string OrderID { 744 | get { return orderID_; } 745 | set { 746 | orderID_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 747 | } 748 | } 749 | 750 | /// Field number for the "Accepted" field. 751 | public const int AcceptedFieldNumber = 2; 752 | private bool accepted_; 753 | /// 754 | /// Indicates whether the transaction was accepted 755 | /// 756 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 757 | public bool Accepted { 758 | get { return accepted_; } 759 | set { 760 | accepted_ = value; 761 | } 762 | } 763 | 764 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 765 | public override bool Equals(object other) { 766 | return Equals(other as OrderResponse); 767 | } 768 | 769 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 770 | public bool Equals(OrderResponse other) { 771 | if (ReferenceEquals(other, null)) { 772 | return false; 773 | } 774 | if (ReferenceEquals(other, this)) { 775 | return true; 776 | } 777 | if (OrderID != other.OrderID) return false; 778 | if (Accepted != other.Accepted) return false; 779 | return true; 780 | } 781 | 782 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 783 | public override int GetHashCode() { 784 | int hash = 1; 785 | if (OrderID.Length != 0) hash ^= OrderID.GetHashCode(); 786 | if (Accepted != false) hash ^= Accepted.GetHashCode(); 787 | return hash; 788 | } 789 | 790 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 791 | public override string ToString() { 792 | return pb::JsonFormatter.ToDiagnosticString(this); 793 | } 794 | 795 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 796 | public void WriteTo(pb::CodedOutputStream output) { 797 | if (OrderID.Length != 0) { 798 | output.WriteRawTag(10); 799 | output.WriteString(OrderID); 800 | } 801 | if (Accepted != false) { 802 | output.WriteRawTag(16); 803 | output.WriteBool(Accepted); 804 | } 805 | } 806 | 807 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 808 | public int CalculateSize() { 809 | int size = 0; 810 | if (OrderID.Length != 0) { 811 | size += 1 + pb::CodedOutputStream.ComputeStringSize(OrderID); 812 | } 813 | if (Accepted != false) { 814 | size += 1 + 1; 815 | } 816 | return size; 817 | } 818 | 819 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 820 | public void MergeFrom(OrderResponse other) { 821 | if (other == null) { 822 | return; 823 | } 824 | if (other.OrderID.Length != 0) { 825 | OrderID = other.OrderID; 826 | } 827 | if (other.Accepted != false) { 828 | Accepted = other.Accepted; 829 | } 830 | } 831 | 832 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 833 | public void MergeFrom(pb::CodedInputStream input) { 834 | uint tag; 835 | while ((tag = input.ReadTag()) != 0) { 836 | switch(tag) { 837 | default: 838 | input.SkipLastField(); 839 | break; 840 | case 10: { 841 | OrderID = input.ReadString(); 842 | break; 843 | } 844 | case 16: { 845 | Accepted = input.ReadBool(); 846 | break; 847 | } 848 | } 849 | } 850 | } 851 | 852 | } 853 | 854 | public sealed partial class CancelOrderRequest : pb::IMessage { 855 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CancelOrderRequest()); 856 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 857 | public static pb::MessageParser Parser { get { return _parser; } } 858 | 859 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 860 | public static pbr::MessageDescriptor Descriptor { 861 | get { return global::PartialFoods.Services.PartialfoodsReflection.Descriptor.MessageTypes[4]; } 862 | } 863 | 864 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 865 | pbr::MessageDescriptor pb::IMessage.Descriptor { 866 | get { return Descriptor; } 867 | } 868 | 869 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 870 | public CancelOrderRequest() { 871 | OnConstruction(); 872 | } 873 | 874 | partial void OnConstruction(); 875 | 876 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 877 | public CancelOrderRequest(CancelOrderRequest other) : this() { 878 | orderID_ = other.orderID_; 879 | userID_ = other.userID_; 880 | } 881 | 882 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 883 | public CancelOrderRequest Clone() { 884 | return new CancelOrderRequest(this); 885 | } 886 | 887 | /// Field number for the "OrderID" field. 888 | public const int OrderIDFieldNumber = 1; 889 | private string orderID_ = ""; 890 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 891 | public string OrderID { 892 | get { return orderID_; } 893 | set { 894 | orderID_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 895 | } 896 | } 897 | 898 | /// Field number for the "UserID" field. 899 | public const int UserIDFieldNumber = 2; 900 | private string userID_ = ""; 901 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 902 | public string UserID { 903 | get { return userID_; } 904 | set { 905 | userID_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 906 | } 907 | } 908 | 909 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 910 | public override bool Equals(object other) { 911 | return Equals(other as CancelOrderRequest); 912 | } 913 | 914 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 915 | public bool Equals(CancelOrderRequest other) { 916 | if (ReferenceEquals(other, null)) { 917 | return false; 918 | } 919 | if (ReferenceEquals(other, this)) { 920 | return true; 921 | } 922 | if (OrderID != other.OrderID) return false; 923 | if (UserID != other.UserID) return false; 924 | return true; 925 | } 926 | 927 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 928 | public override int GetHashCode() { 929 | int hash = 1; 930 | if (OrderID.Length != 0) hash ^= OrderID.GetHashCode(); 931 | if (UserID.Length != 0) hash ^= UserID.GetHashCode(); 932 | return hash; 933 | } 934 | 935 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 936 | public override string ToString() { 937 | return pb::JsonFormatter.ToDiagnosticString(this); 938 | } 939 | 940 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 941 | public void WriteTo(pb::CodedOutputStream output) { 942 | if (OrderID.Length != 0) { 943 | output.WriteRawTag(10); 944 | output.WriteString(OrderID); 945 | } 946 | if (UserID.Length != 0) { 947 | output.WriteRawTag(18); 948 | output.WriteString(UserID); 949 | } 950 | } 951 | 952 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 953 | public int CalculateSize() { 954 | int size = 0; 955 | if (OrderID.Length != 0) { 956 | size += 1 + pb::CodedOutputStream.ComputeStringSize(OrderID); 957 | } 958 | if (UserID.Length != 0) { 959 | size += 1 + pb::CodedOutputStream.ComputeStringSize(UserID); 960 | } 961 | return size; 962 | } 963 | 964 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 965 | public void MergeFrom(CancelOrderRequest other) { 966 | if (other == null) { 967 | return; 968 | } 969 | if (other.OrderID.Length != 0) { 970 | OrderID = other.OrderID; 971 | } 972 | if (other.UserID.Length != 0) { 973 | UserID = other.UserID; 974 | } 975 | } 976 | 977 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 978 | public void MergeFrom(pb::CodedInputStream input) { 979 | uint tag; 980 | while ((tag = input.ReadTag()) != 0) { 981 | switch(tag) { 982 | default: 983 | input.SkipLastField(); 984 | break; 985 | case 10: { 986 | OrderID = input.ReadString(); 987 | break; 988 | } 989 | case 18: { 990 | UserID = input.ReadString(); 991 | break; 992 | } 993 | } 994 | } 995 | } 996 | 997 | } 998 | 999 | public sealed partial class CancelOrderResponse : pb::IMessage { 1000 | private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new CancelOrderResponse()); 1001 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 1002 | public static pb::MessageParser Parser { get { return _parser; } } 1003 | 1004 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 1005 | public static pbr::MessageDescriptor Descriptor { 1006 | get { return global::PartialFoods.Services.PartialfoodsReflection.Descriptor.MessageTypes[5]; } 1007 | } 1008 | 1009 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 1010 | pbr::MessageDescriptor pb::IMessage.Descriptor { 1011 | get { return Descriptor; } 1012 | } 1013 | 1014 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 1015 | public CancelOrderResponse() { 1016 | OnConstruction(); 1017 | } 1018 | 1019 | partial void OnConstruction(); 1020 | 1021 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 1022 | public CancelOrderResponse(CancelOrderResponse other) : this() { 1023 | orderID_ = other.orderID_; 1024 | canceled_ = other.canceled_; 1025 | confirmationCode_ = other.confirmationCode_; 1026 | } 1027 | 1028 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 1029 | public CancelOrderResponse Clone() { 1030 | return new CancelOrderResponse(this); 1031 | } 1032 | 1033 | /// Field number for the "OrderID" field. 1034 | public const int OrderIDFieldNumber = 1; 1035 | private string orderID_ = ""; 1036 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 1037 | public string OrderID { 1038 | get { return orderID_; } 1039 | set { 1040 | orderID_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 1041 | } 1042 | } 1043 | 1044 | /// Field number for the "Canceled" field. 1045 | public const int CanceledFieldNumber = 2; 1046 | private bool canceled_; 1047 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 1048 | public bool Canceled { 1049 | get { return canceled_; } 1050 | set { 1051 | canceled_ = value; 1052 | } 1053 | } 1054 | 1055 | /// Field number for the "ConfirmationCode" field. 1056 | public const int ConfirmationCodeFieldNumber = 3; 1057 | private string confirmationCode_ = ""; 1058 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 1059 | public string ConfirmationCode { 1060 | get { return confirmationCode_; } 1061 | set { 1062 | confirmationCode_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); 1063 | } 1064 | } 1065 | 1066 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 1067 | public override bool Equals(object other) { 1068 | return Equals(other as CancelOrderResponse); 1069 | } 1070 | 1071 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 1072 | public bool Equals(CancelOrderResponse other) { 1073 | if (ReferenceEquals(other, null)) { 1074 | return false; 1075 | } 1076 | if (ReferenceEquals(other, this)) { 1077 | return true; 1078 | } 1079 | if (OrderID != other.OrderID) return false; 1080 | if (Canceled != other.Canceled) return false; 1081 | if (ConfirmationCode != other.ConfirmationCode) return false; 1082 | return true; 1083 | } 1084 | 1085 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 1086 | public override int GetHashCode() { 1087 | int hash = 1; 1088 | if (OrderID.Length != 0) hash ^= OrderID.GetHashCode(); 1089 | if (Canceled != false) hash ^= Canceled.GetHashCode(); 1090 | if (ConfirmationCode.Length != 0) hash ^= ConfirmationCode.GetHashCode(); 1091 | return hash; 1092 | } 1093 | 1094 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 1095 | public override string ToString() { 1096 | return pb::JsonFormatter.ToDiagnosticString(this); 1097 | } 1098 | 1099 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 1100 | public void WriteTo(pb::CodedOutputStream output) { 1101 | if (OrderID.Length != 0) { 1102 | output.WriteRawTag(10); 1103 | output.WriteString(OrderID); 1104 | } 1105 | if (Canceled != false) { 1106 | output.WriteRawTag(16); 1107 | output.WriteBool(Canceled); 1108 | } 1109 | if (ConfirmationCode.Length != 0) { 1110 | output.WriteRawTag(26); 1111 | output.WriteString(ConfirmationCode); 1112 | } 1113 | } 1114 | 1115 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 1116 | public int CalculateSize() { 1117 | int size = 0; 1118 | if (OrderID.Length != 0) { 1119 | size += 1 + pb::CodedOutputStream.ComputeStringSize(OrderID); 1120 | } 1121 | if (Canceled != false) { 1122 | size += 1 + 1; 1123 | } 1124 | if (ConfirmationCode.Length != 0) { 1125 | size += 1 + pb::CodedOutputStream.ComputeStringSize(ConfirmationCode); 1126 | } 1127 | return size; 1128 | } 1129 | 1130 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 1131 | public void MergeFrom(CancelOrderResponse other) { 1132 | if (other == null) { 1133 | return; 1134 | } 1135 | if (other.OrderID.Length != 0) { 1136 | OrderID = other.OrderID; 1137 | } 1138 | if (other.Canceled != false) { 1139 | Canceled = other.Canceled; 1140 | } 1141 | if (other.ConfirmationCode.Length != 0) { 1142 | ConfirmationCode = other.ConfirmationCode; 1143 | } 1144 | } 1145 | 1146 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute] 1147 | public void MergeFrom(pb::CodedInputStream input) { 1148 | uint tag; 1149 | while ((tag = input.ReadTag()) != 0) { 1150 | switch(tag) { 1151 | default: 1152 | input.SkipLastField(); 1153 | break; 1154 | case 10: { 1155 | OrderID = input.ReadString(); 1156 | break; 1157 | } 1158 | case 16: { 1159 | Canceled = input.ReadBool(); 1160 | break; 1161 | } 1162 | case 26: { 1163 | ConfirmationCode = input.ReadString(); 1164 | break; 1165 | } 1166 | } 1167 | } 1168 | } 1169 | 1170 | } 1171 | 1172 | #endregion 1173 | 1174 | } 1175 | 1176 | #endregion Designer generated code 1177 | -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/RPC/PartialfoodsGrpc.cs: -------------------------------------------------------------------------------- 1 | // Generated by the protocol buffer compiler. DO NOT EDIT! 2 | // source: partialfoods.proto 3 | #pragma warning disable 1591 4 | #region Designer generated code 5 | 6 | using System; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | using grpc = global::Grpc.Core; 10 | 11 | namespace PartialFoods.Services { 12 | public static partial class OrderCommand 13 | { 14 | static readonly string __ServiceName = "PartialFoods.Services.OrderCommand"; 15 | 16 | static readonly grpc::Marshaller __Marshaller_OrderRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::PartialFoods.Services.OrderRequest.Parser.ParseFrom); 17 | static readonly grpc::Marshaller __Marshaller_OrderResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::PartialFoods.Services.OrderResponse.Parser.ParseFrom); 18 | static readonly grpc::Marshaller __Marshaller_CancelOrderRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::PartialFoods.Services.CancelOrderRequest.Parser.ParseFrom); 19 | static readonly grpc::Marshaller __Marshaller_CancelOrderResponse = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::PartialFoods.Services.CancelOrderResponse.Parser.ParseFrom); 20 | 21 | static readonly grpc::Method __Method_SubmitOrder = new grpc::Method( 22 | grpc::MethodType.Unary, 23 | __ServiceName, 24 | "SubmitOrder", 25 | __Marshaller_OrderRequest, 26 | __Marshaller_OrderResponse); 27 | 28 | static readonly grpc::Method __Method_CancelOrder = new grpc::Method( 29 | grpc::MethodType.Unary, 30 | __ServiceName, 31 | "CancelOrder", 32 | __Marshaller_CancelOrderRequest, 33 | __Marshaller_CancelOrderResponse); 34 | 35 | /// Service descriptor 36 | public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor 37 | { 38 | get { return global::PartialFoods.Services.PartialfoodsReflection.Descriptor.Services[0]; } 39 | } 40 | 41 | /// Base class for server-side implementations of OrderCommand 42 | public abstract partial class OrderCommandBase 43 | { 44 | public virtual global::System.Threading.Tasks.Task SubmitOrder(global::PartialFoods.Services.OrderRequest request, grpc::ServerCallContext context) 45 | { 46 | throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); 47 | } 48 | 49 | public virtual global::System.Threading.Tasks.Task CancelOrder(global::PartialFoods.Services.CancelOrderRequest request, grpc::ServerCallContext context) 50 | { 51 | throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); 52 | } 53 | 54 | } 55 | 56 | /// Client for OrderCommand 57 | public partial class OrderCommandClient : grpc::ClientBase 58 | { 59 | /// Creates a new client for OrderCommand 60 | /// The channel to use to make remote calls. 61 | public OrderCommandClient(grpc::Channel channel) : base(channel) 62 | { 63 | } 64 | /// Creates a new client for OrderCommand that uses a custom CallInvoker. 65 | /// The callInvoker to use to make remote calls. 66 | public OrderCommandClient(grpc::CallInvoker callInvoker) : base(callInvoker) 67 | { 68 | } 69 | /// Protected parameterless constructor to allow creation of test doubles. 70 | protected OrderCommandClient() : base() 71 | { 72 | } 73 | /// Protected constructor to allow creation of configured clients. 74 | /// The client configuration. 75 | protected OrderCommandClient(ClientBaseConfiguration configuration) : base(configuration) 76 | { 77 | } 78 | 79 | public virtual global::PartialFoods.Services.OrderResponse SubmitOrder(global::PartialFoods.Services.OrderRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) 80 | { 81 | return SubmitOrder(request, new grpc::CallOptions(headers, deadline, cancellationToken)); 82 | } 83 | public virtual global::PartialFoods.Services.OrderResponse SubmitOrder(global::PartialFoods.Services.OrderRequest request, grpc::CallOptions options) 84 | { 85 | return CallInvoker.BlockingUnaryCall(__Method_SubmitOrder, null, options, request); 86 | } 87 | public virtual grpc::AsyncUnaryCall SubmitOrderAsync(global::PartialFoods.Services.OrderRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) 88 | { 89 | return SubmitOrderAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); 90 | } 91 | public virtual grpc::AsyncUnaryCall SubmitOrderAsync(global::PartialFoods.Services.OrderRequest request, grpc::CallOptions options) 92 | { 93 | return CallInvoker.AsyncUnaryCall(__Method_SubmitOrder, null, options, request); 94 | } 95 | public virtual global::PartialFoods.Services.CancelOrderResponse CancelOrder(global::PartialFoods.Services.CancelOrderRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) 96 | { 97 | return CancelOrder(request, new grpc::CallOptions(headers, deadline, cancellationToken)); 98 | } 99 | public virtual global::PartialFoods.Services.CancelOrderResponse CancelOrder(global::PartialFoods.Services.CancelOrderRequest request, grpc::CallOptions options) 100 | { 101 | return CallInvoker.BlockingUnaryCall(__Method_CancelOrder, null, options, request); 102 | } 103 | public virtual grpc::AsyncUnaryCall CancelOrderAsync(global::PartialFoods.Services.CancelOrderRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) 104 | { 105 | return CancelOrderAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); 106 | } 107 | public virtual grpc::AsyncUnaryCall CancelOrderAsync(global::PartialFoods.Services.CancelOrderRequest request, grpc::CallOptions options) 108 | { 109 | return CallInvoker.AsyncUnaryCall(__Method_CancelOrder, null, options, request); 110 | } 111 | /// Creates a new instance of client from given ClientBaseConfiguration. 112 | protected override OrderCommandClient NewInstance(ClientBaseConfiguration configuration) 113 | { 114 | return new OrderCommandClient(configuration); 115 | } 116 | } 117 | 118 | /// Creates service definition that can be registered with a server 119 | /// An object implementing the server-side handling logic. 120 | public static grpc::ServerServiceDefinition BindService(OrderCommandBase serviceImpl) 121 | { 122 | return grpc::ServerServiceDefinition.CreateBuilder() 123 | .AddMethod(__Method_SubmitOrder, serviceImpl.SubmitOrder) 124 | .AddMethod(__Method_CancelOrder, serviceImpl.CancelOrder).Build(); 125 | } 126 | 127 | } 128 | } 129 | #endregion 130 | -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "service": { 3 | "port": "8081" 4 | }, 5 | "kafkaclient": { 6 | "brokerlist": "localhost:9092" 7 | }, 8 | "postgres": { 9 | "connectionstring": "Host=localhost;Port=5432;Database=orders;Username=postgres;Password=wopr" 10 | } 11 | } -------------------------------------------------------------------------------- /src/PartialFoods.Services.OrderManagementServer/makeprotos.sh: -------------------------------------------------------------------------------- 1 | PROJDIR=`pwd` 2 | cd ~/.nuget/packages/grpc.tools/1.8.3/tools/linux_x64 3 | protoc -I $PROJDIR/../../proto --csharp_out $PROJDIR/RPC --grpc_out $PROJDIR/RPC $PROJDIR/../../proto/ordermgmt.proto $PROJDIR/../../proto/partialfoods.proto --plugin=protoc-gen-grpc=grpc_csharp_plugin 4 | cd - --------------------------------------------------------------------------------