This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost("UpdateBasketItems")] | |
public async Task<Basket.Api.Models.Basket?> UpdateBasketItems(Basket.Api.Models.Basket basket) | |
{ | |
using var channel = GrpcChannel.ForAddress(_configuration.GetValue<string>("DiscountGrpcServerUrl")); | |
var client = new Price.PriceClient(channel); | |
foreach (var item in basket.BasketItems) | |
{ | |
var reply = await client.GetPriceAsync(new PriceRequest() { Id = item.ProductId }); | |
if (!string.IsNullOrEmpty(reply.ErrorMessage)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Dapper; | |
using Discount.Api.Grpc; | |
using Grpc.Core; | |
using Npgsql; | |
namespace Discount.Api.GrpcService.Server | |
{ | |
public class GetPriceService : Price.PriceBase | |
{ | |
private readonly IConfiguration _configuration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk.Web"> | |
<PropertyGroup> | |
<TargetFramework>net6.0</TargetFramework> | |
<Nullable>enable</Nullable> | |
<ImplicitUsings>enable</ImplicitUsings> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="Dapper" Version="2.0.123" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax = "proto3"; | |
option csharp_namespace = "Discount.Api.Grpc"; | |
package price; | |
// The greeting service definition. | |
service Price { | |
// Sends a greeting | |
rpc GetPrice (PriceRequest) returns (PriceReply); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"DatabaseSettings": { | |
"ConnectionString": "Server=localhost;Port=5432;Database=DiscountDb;User Id=postgres;Password=123456;" | |
}, | |
"Logging": { | |
"LogLevel": { | |
"Default": "Information", | |
"Microsoft.AspNetCore": "Warning" | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Discount.Api.Grpc; | |
using Grpc.Core; | |
namespace Discount.Api.GrpcService.Server | |
{ | |
public class GreeterService : Greeter.GreeterBase | |
{ | |
public GreeterService() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax = "proto3"; | |
option csharp_namespace = "Discount.Api.Grpc"; | |
package greet; | |
// The greeting service definition. | |
service Greeter { | |
// Sends a greeting | |
rpc SayHello (HelloRequest) returns (HelloReply); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Dapper; | |
using Discount.Api.Models; | |
using Microsoft.AspNetCore.Mvc; | |
using Npgsql; | |
namespace Discount.Api.Controllers; | |
[ApiController] | |
[Route("[controller]")] | |
public class DiscountController : ControllerBase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Discount.Api.Models | |
{ | |
public class Price | |
{ | |
public int Id { get; set; } | |
public string ProductName { get; set; } | |
public int ProductId { get; set; } | |
public long Amount { get; set; } | |
public long CurrentAmount { get; set; } | |
public DateTime CreatedDate { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
catalog.api: | |
ports: | |
- 4000:4300 | |
depends_on: | |
- catalog.db | |
environment: | |
- MONGO_URL=catalogdb:27017 | |
catalog.db: |