Merge remote-tracking branch 'origin/migration/net-5' into migration/net-5
This commit is contained in:
commit
f3ecf87a12
@ -15,4 +15,4 @@ data:
|
|||||||
all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}"
|
all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}"
|
||||||
all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}"
|
all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}"
|
||||||
signalr__StoreConnectionString: {{ .Values.inf.redis.keystore.constr }}
|
signalr__StoreConnectionString: {{ .Values.inf.redis.keystore.constr }}
|
||||||
urls__IdentityUrl: http://{{ $identity }}
|
urls__IdentityUrl: http://identity-api
|
@ -42,7 +42,7 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
|
|||||||
|
|
||||||
public string Buyer { get; set; }
|
public string Buyer { get; set; }
|
||||||
|
|
||||||
public List<OrderItemData> OrderItems { get; } = new List<OrderItemData>();
|
public List<OrderItemData> OrderItems { get; } = new List<OrderItemData>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
|
|||||||
|
|
||||||
public class UpdateBasketItemsRequest
|
public class UpdateBasketItemsRequest
|
||||||
{
|
{
|
||||||
|
|
||||||
public string BasketId { get; set; }
|
public string BasketId { get; set; }
|
||||||
|
|
||||||
public ICollection<UpdateBasketItemData> Updates { get; set; }
|
public ICollection<UpdateBasketItemData> Updates { get; set; }
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
|
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models
|
||||||
{
|
{
|
||||||
|
|
||||||
public class UpdateBasketRequest
|
public class UpdateBasketRequest
|
||||||
{
|
{
|
||||||
public string BuyerId { get; set; }
|
public string BuyerId { get; set; }
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
using GrpcBasket;
|
using GrpcBasket;
|
||||||
using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config;
|
|
||||||
using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models;
|
using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
using GrpcOrdering;
|
using GrpcOrdering;
|
||||||
using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Config;
|
|
||||||
using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models;
|
using Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services
|
namespace Microsoft.eShopOnContainers.Mobile.Shopping.HttpAggregator.Services
|
||||||
|
@ -20,7 +20,7 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Config
|
|||||||
public class BasketOperations
|
public class BasketOperations
|
||||||
{
|
{
|
||||||
public static string GetItemById(string id) => $"/api/v1/basket/{id}";
|
public static string GetItemById(string id) => $"/api/v1/basket/{id}";
|
||||||
|
|
||||||
public static string UpdateBasket() => "/api/v1/basket";
|
public static string UpdateBasket() => "/api/v1/basket";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
using GrpcBasket;
|
using GrpcBasket;
|
||||||
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Config;
|
|
||||||
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models;
|
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
using GrpcOrdering;
|
using GrpcOrdering;
|
||||||
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models;
|
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Models;
|
||||||
using Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
|
namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator.Services
|
||||||
|
@ -44,7 +44,7 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
|
|||||||
.AddUrlGroup(new Uri(Configuration["BasketUrlHC"]), name: "basketapi-check", tags: new string[] { "basketapi" })
|
.AddUrlGroup(new Uri(Configuration["BasketUrlHC"]), name: "basketapi-check", tags: new string[] { "basketapi" })
|
||||||
.AddUrlGroup(new Uri(Configuration["IdentityUrlHC"]), name: "identityapi-check", tags: new string[] { "identityapi" })
|
.AddUrlGroup(new Uri(Configuration["IdentityUrlHC"]), name: "identityapi-check", tags: new string[] { "identityapi" })
|
||||||
.AddUrlGroup(new Uri(Configuration["PaymentUrlHC"]), name: "paymentapi-check", tags: new string[] { "paymentapi" });
|
.AddUrlGroup(new Uri(Configuration["PaymentUrlHC"]), name: "paymentapi-check", tags: new string[] { "paymentapi" });
|
||||||
|
|
||||||
services.AddCustomMvc(Configuration)
|
services.AddCustomMvc(Configuration)
|
||||||
.AddCustomAuthentication(Configuration)
|
.AddCustomAuthentication(Configuration)
|
||||||
.AddDevspaces()
|
.AddDevspaces()
|
||||||
@ -142,7 +142,7 @@ namespace Microsoft.eShopOnContainers.Web.Shopping.HttpAggregator
|
|||||||
Version = "v1",
|
Version = "v1",
|
||||||
Description = "Shopping Aggregator for Web Clients"
|
Description = "Shopping Aggregator for Web Clients"
|
||||||
});
|
});
|
||||||
|
|
||||||
options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme
|
options.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme
|
||||||
{
|
{
|
||||||
Type = SecuritySchemeType.OAuth2,
|
Type = SecuritySchemeType.OAuth2,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Devspaces.Support
|
namespace Devspaces.Support
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Devspaces.Support
|
namespace Devspaces.Support
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using System.Threading.Tasks;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions
|
||||||
{
|
{
|
||||||
|
@ -3,8 +3,8 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions
|
||||||
{
|
{
|
||||||
public interface IIntegrationEventHandler<in TIntegrationEvent> : IIntegrationEventHandler
|
public interface IIntegrationEventHandler<in TIntegrationEvent> : IIntegrationEventHandler
|
||||||
where TIntegrationEvent: IntegrationEvent
|
where TIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
Task Handle(TIntegrationEvent @event);
|
Task Handle(TIntegrationEvent @event);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using System;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json;
|
using System;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Extensions
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Extensions
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
using System;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBus
|
|||||||
public class SubscriptionInfo
|
public class SubscriptionInfo
|
||||||
{
|
{
|
||||||
public bool IsDynamic { get; }
|
public bool IsDynamic { get; }
|
||||||
public Type HandlerType{ get; }
|
public Type HandlerType { get; }
|
||||||
|
|
||||||
private SubscriptionInfo(bool isDynamic, Type handlerType)
|
private SubscriptionInfo(bool isDynamic, Type handlerType)
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@ using System;
|
|||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
||||||
{
|
{
|
||||||
public class DefaultServiceBusPersisterConnection :IServiceBusPersisterConnection
|
public class DefaultServiceBusPersisterConnection : IServiceBusPersisterConnection
|
||||||
{
|
{
|
||||||
private readonly ILogger<DefaultServiceBusPersisterConnection> _logger;
|
private readonly ILogger<DefaultServiceBusPersisterConnection> _logger;
|
||||||
private readonly ServiceBusConnectionStringBuilder _serviceBusConnectionStringBuilder;
|
private readonly ServiceBusConnectionStringBuilder _serviceBusConnectionStringBuilder;
|
||||||
@ -16,8 +16,8 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
|||||||
ILogger<DefaultServiceBusPersisterConnection> logger)
|
ILogger<DefaultServiceBusPersisterConnection> logger)
|
||||||
{
|
{
|
||||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
|
|
||||||
_serviceBusConnectionStringBuilder = serviceBusConnectionStringBuilder ??
|
_serviceBusConnectionStringBuilder = serviceBusConnectionStringBuilder ??
|
||||||
throw new ArgumentNullException(nameof(serviceBusConnectionStringBuilder));
|
throw new ArgumentNullException(nameof(serviceBusConnectionStringBuilder));
|
||||||
_topicClient = new TopicClient(_serviceBusConnectionStringBuilder, RetryPolicy.Default);
|
_topicClient = new TopicClient(_serviceBusConnectionStringBuilder, RetryPolicy.Default);
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus
|
|||||||
|
|
||||||
public ITopicClient CreateModel()
|
public ITopicClient CreateModel()
|
||||||
{
|
{
|
||||||
if(_topicClient.IsClosedOrClosing)
|
if (_topicClient.IsClosedOrClosing)
|
||||||
{
|
{
|
||||||
_topicClient = new TopicClient(_serviceBusConnectionStringBuilder, RetryPolicy.Default);
|
_topicClient = new TopicClient(_serviceBusConnectionStringBuilder, RetryPolicy.Default);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
using System;
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF
|
|
||||||
{
|
{
|
||||||
public enum EventStateEnum
|
public enum EventStateEnum
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF
|
||||||
{
|
{
|
||||||
public class IntegrationEventLogContext : DbContext
|
public class IntegrationEventLogContext : DbContext
|
||||||
{
|
{
|
||||||
public IntegrationEventLogContext(DbContextOptions<IntegrationEventLogContext> options) : base(options)
|
public IntegrationEventLogContext(DbContextOptions<IntegrationEventLogContext> options) : base(options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -15,7 +12,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF
|
|||||||
public DbSet<IntegrationEventLogEntry> IntegrationEventLogs { get; set; }
|
public DbSet<IntegrationEventLogEntry> IntegrationEventLogs { get; set; }
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder builder)
|
protected override void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
builder.Entity<IntegrationEventLogEntry>(ConfigureIntegrationEventLogEntry);
|
builder.Entity<IntegrationEventLogEntry>(ConfigureIntegrationEventLogEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,8 @@
|
|||||||
using System;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Reflection;
|
using System.Linq;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF
|
||||||
{
|
{
|
||||||
@ -16,7 +11,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF
|
|||||||
private IntegrationEventLogEntry() { }
|
private IntegrationEventLogEntry() { }
|
||||||
public IntegrationEventLogEntry(IntegrationEvent @event, Guid transactionId)
|
public IntegrationEventLogEntry(IntegrationEvent @event, Guid transactionId)
|
||||||
{
|
{
|
||||||
EventId = @event.Id;
|
EventId = @event.Id;
|
||||||
CreationTime = @event.CreationDate;
|
CreationTime = @event.CreationDate;
|
||||||
EventTypeName = @event.GetType().FullName;
|
EventTypeName = @event.GetType().FullName;
|
||||||
Content = JsonConvert.SerializeObject(@event);
|
Content = JsonConvert.SerializeObject(@event);
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data.Common;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage;
|
using Microsoft.EntityFrameworkCore.Storage;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -15,7 +10,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services
|
||||||
{
|
{
|
||||||
public class IntegrationEventLogService : IIntegrationEventLogService,IDisposable
|
public class IntegrationEventLogService : IIntegrationEventLogService, IDisposable
|
||||||
{
|
{
|
||||||
private readonly IntegrationEventLogContext _integrationEventLogContext;
|
private readonly IntegrationEventLogContext _integrationEventLogContext;
|
||||||
private readonly DbConnection _dbConnection;
|
private readonly DbConnection _dbConnection;
|
||||||
@ -43,11 +38,12 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Servi
|
|||||||
var result = await _integrationEventLogContext.IntegrationEventLogs
|
var result = await _integrationEventLogContext.IntegrationEventLogs
|
||||||
.Where(e => e.TransactionId == tid && e.State == EventStateEnum.NotPublished).ToListAsync();
|
.Where(e => e.TransactionId == tid && e.State == EventStateEnum.NotPublished).ToListAsync();
|
||||||
|
|
||||||
if(result != null && result.Any()){
|
if (result != null && result.Any())
|
||||||
|
{
|
||||||
return result.OrderBy(o => o.CreationTime)
|
return result.OrderBy(o => o.CreationTime)
|
||||||
.Select(e => e.DeserializeJsonContent(_eventTypes.Find(t=> t.Name == e.EventTypeShortName)));
|
.Select(e => e.DeserializeJsonContent(_eventTypes.Find(t => t.Name == e.EventTypeShortName)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new List<IntegrationEventLogEntry>();
|
return new List<IntegrationEventLogEntry>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +79,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Servi
|
|||||||
var eventLogEntry = _integrationEventLogContext.IntegrationEventLogs.Single(ie => ie.EventId == eventId);
|
var eventLogEntry = _integrationEventLogContext.IntegrationEventLogs.Single(ie => ie.EventId == eventId);
|
||||||
eventLogEntry.State = status;
|
eventLogEntry.State = status;
|
||||||
|
|
||||||
if(status == EventStateEnum.InProgress)
|
if (status == EventStateEnum.InProgress)
|
||||||
eventLogEntry.TimesSent++;
|
eventLogEntry.TimesSent++;
|
||||||
|
|
||||||
_integrationEventLogContext.IntegrationEventLogs.Update(eventLogEntry);
|
_integrationEventLogContext.IntegrationEventLogs.Update(eventLogEntry);
|
||||||
@ -100,7 +96,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Servi
|
|||||||
_integrationEventLogContext?.Dispose();
|
_integrationEventLogContext?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
disposedValue = true;
|
disposedValue = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Storage;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data.Common;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Utilities
|
namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Utilities
|
||||||
@ -16,8 +10,8 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Utili
|
|||||||
private ResilientTransaction(DbContext context) =>
|
private ResilientTransaction(DbContext context) =>
|
||||||
_context = context ?? throw new ArgumentNullException(nameof(context));
|
_context = context ?? throw new ArgumentNullException(nameof(context));
|
||||||
|
|
||||||
public static ResilientTransaction New (DbContext context) =>
|
public static ResilientTransaction New(DbContext context) =>
|
||||||
new ResilientTransaction(context);
|
new ResilientTransaction(context);
|
||||||
|
|
||||||
public async Task ExecuteAsync(Func<Task> action)
|
public async Task ExecuteAsync(Func<Task> action)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using Microsoft.AspNetCore.Mvc.Authorization;
|
using Microsoft.AspNetCore.Mvc.Authorization;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
using Swashbuckle.AspNetCore.Swagger;
|
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -7,7 +7,6 @@ using Microsoft.eShopOnContainers.Services.Basket.API.Model;
|
|||||||
using Microsoft.eShopOnContainers.Services.Basket.API.Services;
|
using Microsoft.eShopOnContainers.Services.Basket.API.Services;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -47,7 +46,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Controllers
|
|||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType(typeof(CustomerBasket), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(CustomerBasket), (int)HttpStatusCode.OK)]
|
||||||
public async Task<ActionResult<CustomerBasket>> UpdateBasketAsync([FromBody]CustomerBasket value)
|
public async Task<ActionResult<CustomerBasket>> UpdateBasketAsync([FromBody] CustomerBasket value)
|
||||||
{
|
{
|
||||||
return Ok(await _repository.UpdateBasketAsync(value));
|
return Ok(await _repository.UpdateBasketAsync(value));
|
||||||
}
|
}
|
||||||
@ -56,7 +55,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType((int)HttpStatusCode.Accepted)]
|
[ProducesResponseType((int)HttpStatusCode.Accepted)]
|
||||||
[ProducesResponseType((int)HttpStatusCode.BadRequest)]
|
[ProducesResponseType((int)HttpStatusCode.BadRequest)]
|
||||||
public async Task<ActionResult> CheckoutAsync([FromBody]BasketCheckout basketCheckout, [FromHeader(Name = "x-requestid")] string requestId)
|
public async Task<ActionResult> CheckoutAsync([FromBody] BasketCheckout basketCheckout, [FromHeader(Name = "x-requestid")] string requestId)
|
||||||
{
|
{
|
||||||
var userId = _identityService.GetUserIdentity();
|
var userId = _identityService.GetUserIdentity();
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ using Microsoft.eShopOnContainers.Services.Basket.API.Model;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using GrpcBasket;
|
|
||||||
|
|
||||||
namespace GrpcBasket
|
namespace GrpcBasket
|
||||||
{
|
{
|
||||||
|
@ -44,7 +44,7 @@ namespace Basket.API.Infrastructure.Middlewares
|
|||||||
private async Task ProcessConfigRequest(HttpContext context)
|
private async Task ProcessConfigRequest(HttpContext context)
|
||||||
{
|
{
|
||||||
var enable = context.Request.Query.Keys.Any(k => k == "enable");
|
var enable = context.Request.Query.Keys.Any(k => k == "enable");
|
||||||
var disable = context.Request.Query.Keys.Any(k => k == "disable");
|
var disable = context.Request.Query.Keys.Any(k => k == "disable");
|
||||||
|
|
||||||
if (enable && disable)
|
if (enable && disable)
|
||||||
{
|
{
|
||||||
@ -86,7 +86,7 @@ namespace Basket.API.Infrastructure.Middlewares
|
|||||||
}
|
}
|
||||||
|
|
||||||
return _mustFail &&
|
return _mustFail &&
|
||||||
(_options.EndpointPaths.Any(x => x == rpath)
|
(_options.EndpointPaths.Any(x => x == rpath)
|
||||||
|| _options.EndpointPaths.Count == 0);
|
|| _options.EndpointPaths.Count == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,6 @@ namespace Basket.API.Infrastructure.Middlewares
|
|||||||
public string ConfigPath = "/Failing";
|
public string ConfigPath = "/Failing";
|
||||||
public List<string> EndpointPaths { get; set; } = new List<string>();
|
public List<string> EndpointPaths { get; set; } = new List<string>();
|
||||||
|
|
||||||
public List<string> NotFilteredPaths {get; set;} = new List<string>();
|
public List<string> NotFilteredPaths { get; set; } = new List<string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using Basket.API.IntegrationEvents.Events;
|
using Basket.API.IntegrationEvents.Events;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
using Microsoft.eShopOnContainers.Services.Basket.API;
|
|
||||||
using Microsoft.eShopOnContainers.Services.Basket.API.Model;
|
using Microsoft.eShopOnContainers.Services.Basket.API.Model;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Serilog.Context;
|
using Serilog.Context;
|
||||||
|
@ -10,6 +10,6 @@ namespace Basket.API.IntegrationEvents.Events
|
|||||||
public string UserId { get; init; }
|
public string UserId { get; init; }
|
||||||
|
|
||||||
public OrderStartedIntegrationEvent(string userId)
|
public OrderStartedIntegrationEvent(string userId)
|
||||||
=> UserId = userId;
|
=> UserId = userId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.IntegrationEvents.Even
|
|||||||
// An Event is “something that has happened in the past”, therefore its name has to be
|
// An Event is “something that has happened in the past”, therefore its name has to be
|
||||||
// An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems.
|
// An Integration Event is an event that can cause side effects to other microsrvices, Bounded-Contexts or external systems.
|
||||||
public record ProductPriceChangedIntegrationEvent : IntegrationEvent
|
public record ProductPriceChangedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int ProductId { get; private init; }
|
public int ProductId { get; private init; }
|
||||||
|
|
||||||
public decimal NewPrice { get; private init; }
|
public decimal NewPrice { get; private init; }
|
||||||
|
@ -18,7 +18,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Model
|
|||||||
|
|
||||||
if (Quantity < 1)
|
if (Quantity < 1)
|
||||||
{
|
{
|
||||||
results.Add(new ValidationResult("Invalid number of units", new []{ "Quantity" }));
|
results.Add(new ValidationResult("Invalid number of units", new[] { "Quantity" }));
|
||||||
}
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
|
@ -104,7 +104,8 @@ IConfiguration GetConfiguration()
|
|||||||
return (port, grpcPort);
|
return (port, grpcPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Program {
|
public class Program
|
||||||
|
{
|
||||||
|
|
||||||
public static string Namespace = typeof(Startup).Namespace;
|
public static string Namespace = typeof(Startup).Namespace;
|
||||||
public static string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1);
|
public static string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1);
|
||||||
|
@ -6,7 +6,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API.Services
|
|||||||
{
|
{
|
||||||
public class IdentityService : IIdentityService
|
public class IdentityService : IIdentityService
|
||||||
{
|
{
|
||||||
private IHttpContextAccessor _context;
|
private IHttpContextAccessor _context;
|
||||||
|
|
||||||
public IdentityService(IHttpContextAccessor context)
|
public IdentityService(IHttpContextAccessor context)
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using Autofac;
|
using Autofac;
|
||||||
using Autofac.Extensions.DependencyInjection;
|
using Autofac.Extensions.DependencyInjection;
|
||||||
using Basket.API.Infrastructure.Filters;
|
using Basket.API.Infrastructure.Filters;
|
||||||
using Basket.API.Infrastructure.Middlewares;
|
|
||||||
using Basket.API.IntegrationEvents.EventHandling;
|
using Basket.API.IntegrationEvents.EventHandling;
|
||||||
using Basket.API.IntegrationEvents.Events;
|
using Basket.API.IntegrationEvents.Events;
|
||||||
|
using GrpcBasket;
|
||||||
using HealthChecks.UI.Client;
|
using HealthChecks.UI.Client;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
@ -33,9 +33,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using GrpcBasket;
|
|
||||||
using Microsoft.AspNetCore.Http.Features;
|
|
||||||
using Serilog;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Basket.API
|
namespace Microsoft.eShopOnContainers.Services.Basket.API
|
||||||
{
|
{
|
||||||
@ -213,7 +210,7 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
|
|||||||
ConfigureAuth(app);
|
ConfigureAuth(app);
|
||||||
|
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
|
|
||||||
app.UseEndpoints(endpoints =>
|
app.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
endpoints.MapGrpcService<BasketService>();
|
endpoints.MapGrpcService<BasketService>();
|
||||||
@ -255,22 +252,22 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
|
|||||||
|
|
||||||
private void ConfigureAuthService(IServiceCollection services)
|
private void ConfigureAuthService(IServiceCollection services)
|
||||||
{
|
{
|
||||||
// prevent from mapping "sub" claim to nameidentifier.
|
// prevent from mapping "sub" claim to nameidentifier.
|
||||||
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove("sub");
|
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove("sub");
|
||||||
|
|
||||||
var identityUrl = Configuration.GetValue<string>("IdentityUrl");
|
var identityUrl = Configuration.GetValue<string>("IdentityUrl");
|
||||||
|
|
||||||
services.AddAuthentication(options =>
|
services.AddAuthentication(options =>
|
||||||
{
|
{
|
||||||
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
|
|
||||||
}).AddJwtBearer(options =>
|
}).AddJwtBearer(options =>
|
||||||
{
|
{
|
||||||
options.Authority = identityUrl;
|
options.Authority = identityUrl;
|
||||||
options.RequireHttpsMetadata = false;
|
options.RequireHttpsMetadata = false;
|
||||||
options.Audience = "basket";
|
options.Audience = "basket";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void ConfigureAuth(IApplicationBuilder app)
|
protected virtual void ConfigureAuth(IApplicationBuilder app)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using System;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Routing;
|
using Microsoft.AspNetCore.Routing;
|
||||||
using Microsoft.eShopOnContainers.Services.Basket.API;
|
using Microsoft.eShopOnContainers.Services.Basket.API;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Basket.FunctionalTests.Base
|
namespace Basket.FunctionalTests.Base
|
||||||
{
|
{
|
||||||
@ -20,7 +20,7 @@ namespace Basket.FunctionalTests.Base
|
|||||||
services.Configure<RouteOptions>(Configuration);
|
services.Configure<RouteOptions>(Configuration);
|
||||||
return base.ConfigureServices(services);
|
return base.ConfigureServices(services);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ConfigureAuth(IApplicationBuilder app)
|
protected override void ConfigureAuth(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant())
|
if (Configuration["isTest"] == bool.TrueString.ToLowerInvariant())
|
||||||
|
@ -73,7 +73,7 @@ namespace Basket.FunctionalTests
|
|||||||
|
|
||||||
string BuildCheckout()
|
string BuildCheckout()
|
||||||
{
|
{
|
||||||
var checkoutBasket = new
|
var checkoutBasket = new
|
||||||
{
|
{
|
||||||
City = "city",
|
City = "city",
|
||||||
Street = "street",
|
Street = "street",
|
||||||
|
@ -33,7 +33,7 @@ namespace Basket.FunctionalTests
|
|||||||
Assert.Single(basket.Items);
|
Assert.Single(basket.Items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -58,7 +58,7 @@ namespace Basket.FunctionalTests
|
|||||||
|
|
||||||
Assert.True(deleteResult);
|
Assert.True(deleteResult);
|
||||||
Assert.Null(result);
|
Assert.Null(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RedisBasketRepository BuildBasketRepository(ConnectionMultiplexer connMux)
|
RedisBasketRepository BuildBasketRepository(ConnectionMultiplexer connMux)
|
||||||
|
@ -37,7 +37,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
|||||||
[ProducesResponseType(typeof(PaginatedItemsViewModel<CatalogItem>), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PaginatedItemsViewModel<CatalogItem>), (int)HttpStatusCode.OK)]
|
||||||
[ProducesResponseType(typeof(IEnumerable<CatalogItem>), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(IEnumerable<CatalogItem>), (int)HttpStatusCode.OK)]
|
||||||
[ProducesResponseType((int)HttpStatusCode.BadRequest)]
|
[ProducesResponseType((int)HttpStatusCode.BadRequest)]
|
||||||
public async Task<IActionResult> ItemsAsync([FromQuery]int pageSize = 10, [FromQuery]int pageIndex = 0, string ids = null)
|
public async Task<IActionResult> ItemsAsync([FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0, string ids = null)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(ids))
|
if (!string.IsNullOrEmpty(ids))
|
||||||
{
|
{
|
||||||
@ -126,7 +126,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("items/withname/{name:minlength(1)}")]
|
[Route("items/withname/{name:minlength(1)}")]
|
||||||
[ProducesResponseType(typeof(PaginatedItemsViewModel<CatalogItem>), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PaginatedItemsViewModel<CatalogItem>), (int)HttpStatusCode.OK)]
|
||||||
public async Task<ActionResult<PaginatedItemsViewModel<CatalogItem>>> ItemsWithNameAsync(string name, [FromQuery]int pageSize = 10, [FromQuery]int pageIndex = 0)
|
public async Task<ActionResult<PaginatedItemsViewModel<CatalogItem>>> ItemsWithNameAsync(string name, [FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0)
|
||||||
{
|
{
|
||||||
var totalItems = await _catalogContext.CatalogItems
|
var totalItems = await _catalogContext.CatalogItems
|
||||||
.Where(c => c.Name.StartsWith(name))
|
.Where(c => c.Name.StartsWith(name))
|
||||||
@ -147,7 +147,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("items/type/{catalogTypeId}/brand/{catalogBrandId:int?}")]
|
[Route("items/type/{catalogTypeId}/brand/{catalogBrandId:int?}")]
|
||||||
[ProducesResponseType(typeof(PaginatedItemsViewModel<CatalogItem>), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PaginatedItemsViewModel<CatalogItem>), (int)HttpStatusCode.OK)]
|
||||||
public async Task<ActionResult<PaginatedItemsViewModel<CatalogItem>>> ItemsByTypeIdAndBrandIdAsync(int catalogTypeId, int? catalogBrandId, [FromQuery]int pageSize = 10, [FromQuery]int pageIndex = 0)
|
public async Task<ActionResult<PaginatedItemsViewModel<CatalogItem>>> ItemsByTypeIdAndBrandIdAsync(int catalogTypeId, int? catalogBrandId, [FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0)
|
||||||
{
|
{
|
||||||
var root = (IQueryable<CatalogItem>)_catalogContext.CatalogItems;
|
var root = (IQueryable<CatalogItem>)_catalogContext.CatalogItems;
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("items/type/all/brand/{catalogBrandId:int?}")]
|
[Route("items/type/all/brand/{catalogBrandId:int?}")]
|
||||||
[ProducesResponseType(typeof(PaginatedItemsViewModel<CatalogItem>), (int)HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PaginatedItemsViewModel<CatalogItem>), (int)HttpStatusCode.OK)]
|
||||||
public async Task<ActionResult<PaginatedItemsViewModel<CatalogItem>>> ItemsByBrandIdAsync(int? catalogBrandId, [FromQuery]int pageSize = 10, [FromQuery]int pageIndex = 0)
|
public async Task<ActionResult<PaginatedItemsViewModel<CatalogItem>>> ItemsByBrandIdAsync(int? catalogBrandId, [FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0)
|
||||||
{
|
{
|
||||||
var root = (IQueryable<CatalogItem>)_catalogContext.CatalogItems;
|
var root = (IQueryable<CatalogItem>)_catalogContext.CatalogItems;
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
|||||||
[HttpPut]
|
[HttpPut]
|
||||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||||
[ProducesResponseType((int)HttpStatusCode.Created)]
|
[ProducesResponseType((int)HttpStatusCode.Created)]
|
||||||
public async Task<ActionResult> UpdateProductAsync([FromBody]CatalogItem productToUpdate)
|
public async Task<ActionResult> UpdateProductAsync([FromBody] CatalogItem productToUpdate)
|
||||||
{
|
{
|
||||||
var catalogItem = await _catalogContext.CatalogItems.SingleOrDefaultAsync(i => i.Id == productToUpdate.Id);
|
var catalogItem = await _catalogContext.CatalogItems.SingleOrDefaultAsync(i => i.Id == productToUpdate.Id);
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
|||||||
[Route("items")]
|
[Route("items")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType((int)HttpStatusCode.Created)]
|
[ProducesResponseType((int)HttpStatusCode.Created)]
|
||||||
public async Task<ActionResult> CreateProductAsync([FromBody]CatalogItem product)
|
public async Task<ActionResult> CreateProductAsync([FromBody] CatalogItem product)
|
||||||
{
|
{
|
||||||
var item = new CatalogItem
|
var item = new CatalogItem
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
using System;
|
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Model
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Model
|
|
||||||
{
|
{
|
||||||
public static class CatalogItemExtensions
|
public static class CatalogItemExtensions
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
using System;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Collections.Generic;
|
using Microsoft.Extensions.Hosting;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Polly;
|
using Polly;
|
||||||
|
using System;
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
|
|
||||||
namespace Catalog.API.Extensions
|
namespace Catalog.API.Extensions
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using System;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Polly;
|
using Polly;
|
||||||
|
using System;
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
|
|
||||||
namespace Catalog.API.Extensions
|
namespace Catalog.API.Extensions
|
||||||
{
|
{
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
using System;
|
using CatalogApi;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using CatalogApi;
|
|
||||||
using Grpc.Core;
|
using Grpc.Core;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.eShopOnContainers.Services.Catalog.API;
|
using Microsoft.eShopOnContainers.Services.Catalog.API;
|
||||||
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
|
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
|
||||||
using Microsoft.eShopOnContainers.Services.Catalog.API.Model;
|
using Microsoft.eShopOnContainers.Services.Catalog.API.Model;
|
||||||
using Microsoft.eShopOnContainers.Services.Catalog.API.ViewModel;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using static CatalogApi.Catalog;
|
using static CatalogApi.Catalog;
|
||||||
|
|
||||||
namespace Catalog.API.Grpc
|
namespace Catalog.API.Grpc
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure
|
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure
|
||||||
{
|
{
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using EntityConfigurations;
|
using EntityConfigurations;
|
||||||
using Model;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Design;
|
using Microsoft.EntityFrameworkCore.Design;
|
||||||
|
using Model;
|
||||||
|
|
||||||
public class CatalogContext : DbContext
|
public class CatalogContext : DbContext
|
||||||
{
|
{
|
||||||
@ -19,7 +19,7 @@
|
|||||||
builder.ApplyConfiguration(new CatalogBrandEntityTypeConfiguration());
|
builder.ApplyConfiguration(new CatalogBrandEntityTypeConfiguration());
|
||||||
builder.ApplyConfiguration(new CatalogTypeEntityTypeConfiguration());
|
builder.ApplyConfiguration(new CatalogTypeEntityTypeConfiguration());
|
||||||
builder.ApplyConfiguration(new CatalogItemEntityTypeConfiguration());
|
builder.ApplyConfiguration(new CatalogItemEntityTypeConfiguration());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -27,7 +27,7 @@
|
|||||||
{
|
{
|
||||||
public CatalogContext CreateDbContext(string[] args)
|
public CatalogContext CreateDbContext(string[] args)
|
||||||
{
|
{
|
||||||
var optionsBuilder = new DbContextOptionsBuilder<CatalogContext>()
|
var optionsBuilder = new DbContextOptionsBuilder<CatalogContext>()
|
||||||
.UseSqlServer("Server=.;Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb;Integrated Security=true");
|
.UseSqlServer("Server=.;Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb;Integrated Security=true");
|
||||||
|
|
||||||
return new CatalogContext(optionsBuilder.Options);
|
return new CatalogContext(optionsBuilder.Options);
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
public class CatalogContextSeed
|
public class CatalogContextSeed
|
||||||
{
|
{
|
||||||
public async Task SeedAsync(CatalogContext context,IWebHostEnvironment env,IOptions<CatalogSettings> settings,ILogger<CatalogContextSeed> logger)
|
public async Task SeedAsync(CatalogContext context, IWebHostEnvironment env, IOptions<CatalogSettings> settings, ILogger<CatalogContextSeed> logger)
|
||||||
{
|
{
|
||||||
var policy = CreatePolicy(logger, nameof(CatalogContextSeed));
|
var policy = CreatePolicy(logger, nameof(CatalogContextSeed));
|
||||||
|
|
||||||
@ -73,7 +73,7 @@
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string[] requiredHeaders = { "catalogbrand" };
|
string[] requiredHeaders = { "catalogbrand" };
|
||||||
csvheaders = GetHeaders( csvFileCatalogBrands, requiredHeaders );
|
csvheaders = GetHeaders(csvFileCatalogBrands, requiredHeaders);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -128,7 +128,7 @@
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string[] requiredHeaders = { "catalogtype" };
|
string[] requiredHeaders = { "catalogtype" };
|
||||||
csvheaders = GetHeaders( csvFileCatalogTypes, requiredHeaders );
|
csvheaders = GetHeaders(csvFileCatalogTypes, requiredHeaders);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -183,7 +183,7 @@
|
|||||||
{
|
{
|
||||||
string[] requiredHeaders = { "catalogtypename", "catalogbrandname", "description", "name", "price", "picturefilename" };
|
string[] requiredHeaders = { "catalogtypename", "catalogbrandname", "description", "name", "price", "picturefilename" };
|
||||||
string[] optionalheaders = { "availablestock", "restockthreshold", "maxstockthreshold", "onreorder" };
|
string[] optionalheaders = { "availablestock", "restockthreshold", "maxstockthreshold", "onreorder" };
|
||||||
csvheaders = GetHeaders(csvFileCatalogItems, requiredHeaders, optionalheaders );
|
csvheaders = GetHeaders(csvFileCatalogItems, requiredHeaders, optionalheaders);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -196,7 +196,7 @@
|
|||||||
|
|
||||||
return File.ReadAllLines(csvFileCatalogItems)
|
return File.ReadAllLines(csvFileCatalogItems)
|
||||||
.Skip(1) // skip header row
|
.Skip(1) // skip header row
|
||||||
.Select(row => Regex.Split(row, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)") )
|
.Select(row => Regex.Split(row, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"))
|
||||||
.SelectTry(column => CreateCatalogItem(column, csvheaders, catalogTypeIdLookup, catalogBrandIdLookup))
|
.SelectTry(column => CreateCatalogItem(column, csvheaders, catalogTypeIdLookup, catalogBrandIdLookup))
|
||||||
.OnCaughtException(ex => { logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); return null; })
|
.OnCaughtException(ex => { logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); return null; })
|
||||||
.Where(x => x != null);
|
.Where(x => x != null);
|
||||||
@ -243,7 +243,7 @@
|
|||||||
string availableStockString = column[availableStockIndex].Trim('"').Trim();
|
string availableStockString = column[availableStockIndex].Trim('"').Trim();
|
||||||
if (!String.IsNullOrEmpty(availableStockString))
|
if (!String.IsNullOrEmpty(availableStockString))
|
||||||
{
|
{
|
||||||
if ( int.TryParse(availableStockString, out int availableStock))
|
if (int.TryParse(availableStockString, out int availableStock))
|
||||||
{
|
{
|
||||||
catalogItem.AvailableStock = availableStock;
|
catalogItem.AvailableStock = availableStock;
|
||||||
}
|
}
|
||||||
@ -370,7 +370,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private AsyncRetryPolicy CreatePolicy( ILogger<CatalogContextSeed> logger, string prefix,int retries = 3)
|
private AsyncRetryPolicy CreatePolicy(ILogger<CatalogContextSeed> logger, string prefix, int retries = 3)
|
||||||
{
|
{
|
||||||
return Policy.Handle<SqlException>().
|
return Policy.Handle<SqlException>().
|
||||||
WaitAndRetryAsync(
|
WaitAndRetryAsync(
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace Catalog.API.Infrastructure.Migrations
|
namespace Catalog.API.Infrastructure.Migrations
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace Catalog.API.Infrastructure.Migrations
|
namespace Catalog.API.Infrastructure.Migrations
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace Catalog.API.Infrastructure.Migrations
|
namespace Catalog.API.Infrastructure.Migrations
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace Catalog.API.Infrastructure.Migrations
|
namespace Catalog.API.Infrastructure.Migrations
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace Catalog.API.Infrastructure.Migrations
|
namespace Catalog.API.Infrastructure.Migrations
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace Catalog.API.Infrastructure.Migrations
|
namespace Catalog.API.Infrastructure.Migrations
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace Catalog.API.Infrastructure.Migrations
|
namespace Catalog.API.Infrastructure.Migrations
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace Catalog.API.Infrastructure.Migrations
|
namespace Catalog.API.Infrastructure.Migrations
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
|
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
|
||||||
|
|
||||||
namespace Catalog.API.Infrastructure.Migrations
|
namespace Catalog.API.Infrastructure.Migrations
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
namespace Catalog.API.Migrations
|
namespace Catalog.API.Migrations
|
||||||
{
|
{
|
||||||
|
@ -1,20 +1,17 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Storage;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Utilities;
|
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Utilities;
|
||||||
using Microsoft.eShopOnContainers.Services.Catalog.API;
|
|
||||||
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
|
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Serilog.Context;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Catalog.API.IntegrationEvents
|
namespace Catalog.API.IntegrationEvents
|
||||||
{
|
{
|
||||||
public class CatalogIntegrationEventService : ICatalogIntegrationEventService,IDisposable
|
public class CatalogIntegrationEventService : ICatalogIntegrationEventService, IDisposable
|
||||||
{
|
{
|
||||||
private readonly Func<DbConnection, IIntegrationEventLogService> _integrationEventLogServiceFactory;
|
private readonly Func<DbConnection, IIntegrationEventLogService> _integrationEventLogServiceFactory;
|
||||||
private readonly IEventBus _eventBus;
|
private readonly IEventBus _eventBus;
|
||||||
@ -75,7 +72,7 @@ namespace Catalog.API.IntegrationEvents
|
|||||||
{
|
{
|
||||||
(_eventLogService as IDisposable)?.Dispose();
|
(_eventLogService as IDisposable)?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
disposedValue = true;
|
disposedValue = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling
|
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling
|
||||||
{
|
{
|
||||||
using BuildingBlocks.EventBus.Abstractions;
|
using BuildingBlocks.EventBus.Abstractions;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using BuildingBlocks.EventBus.Events;
|
using BuildingBlocks.EventBus.Events;
|
||||||
|
using global::Catalog.API.IntegrationEvents;
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
|
using IntegrationEvents.Events;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Serilog.Context;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using global::Catalog.API.IntegrationEvents;
|
using System.Threading.Tasks;
|
||||||
using IntegrationEvents.Events;
|
|
||||||
using Serilog.Context;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
public class OrderStatusChangedToAwaitingValidationIntegrationEventHandler :
|
public class OrderStatusChangedToAwaitingValidationIntegrationEventHandler :
|
||||||
IIntegrationEventHandler<OrderStatusChangedToAwaitingValidationIntegrationEvent>
|
IIntegrationEventHandler<OrderStatusChangedToAwaitingValidationIntegrationEvent>
|
||||||
{
|
{
|
||||||
private readonly CatalogContext _catalogContext;
|
private readonly CatalogContext _catalogContext;
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling
|
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling
|
||||||
{
|
{
|
||||||
using BuildingBlocks.EventBus.Abstractions;
|
using BuildingBlocks.EventBus.Abstractions;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events;
|
using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Serilog.Context;
|
using Serilog.Context;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class OrderStatusChangedToPaidIntegrationEventHandler :
|
public class OrderStatusChangedToPaidIntegrationEventHandler :
|
||||||
IIntegrationEventHandler<OrderStatusChangedToPaidIntegrationEvent>
|
IIntegrationEventHandler<OrderStatusChangedToPaidIntegrationEvent>
|
||||||
{
|
{
|
||||||
private readonly CatalogContext _catalogContext;
|
private readonly CatalogContext _catalogContext;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events
|
namespace Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events
|
||||||
{
|
{
|
||||||
using System.Collections.Generic;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Events;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public record OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent
|
public record OrderStatusChangedToPaidIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
// An Event is “something that has happened in the past”, therefore its name has to be past tense
|
// An Event is “something that has happened in the past”, therefore its name has to be past tense
|
||||||
// An Integration Event is an event that can cause side effects to other microservices, Bounded-Contexts or external systems.
|
// An Integration Event is an event that can cause side effects to other microservices, Bounded-Contexts or external systems.
|
||||||
public record ProductPriceChangedIntegrationEvent : IntegrationEvent
|
public record ProductPriceChangedIntegrationEvent : IntegrationEvent
|
||||||
{
|
{
|
||||||
public int ProductId { get; private init; }
|
public int ProductId { get; private init; }
|
||||||
|
|
||||||
public decimal NewPrice { get; private init; }
|
public decimal NewPrice { get; private init; }
|
||||||
|
@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Http;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Azure.ServiceBus;
|
using Microsoft.Azure.ServiceBus;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||||
@ -82,7 +81,7 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API
|
|||||||
{
|
{
|
||||||
c.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "Catalog.API V1");
|
c.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "Catalog.API V1");
|
||||||
});
|
});
|
||||||
|
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
app.UseCors("CorsPolicy");
|
app.UseCors("CorsPolicy");
|
||||||
app.UseEndpoints(endpoints =>
|
app.UseEndpoints(endpoints =>
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
using Autofac.Extensions.DependencyInjection;
|
|
||||||
using Catalog.API.Extensions;
|
using Catalog.API.Extensions;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.TestHost;
|
using Microsoft.AspNetCore.TestHost;
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
using System;
|
using IdentityModel;
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Claims;
|
|
||||||
using System.Text.Encodings.Web;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using IdentityModel;
|
|
||||||
using IdentityServer4;
|
using IdentityServer4;
|
||||||
using IdentityServer4.Models;
|
using IdentityServer4.Models;
|
||||||
using IdentityServer4.Services;
|
using IdentityServer4.Services;
|
||||||
@ -17,6 +12,10 @@ using Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
|
|||||||
using Microsoft.eShopOnContainers.Services.Identity.API.Services;
|
using Microsoft.eShopOnContainers.Services.Identity.API.Services;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers
|
namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers
|
|||||||
private readonly IResourceStore _resourceStore;
|
private readonly IResourceStore _resourceStore;
|
||||||
private readonly IIdentityServerInteractionService _interaction;
|
private readonly IIdentityServerInteractionService _interaction;
|
||||||
|
|
||||||
|
|
||||||
public ConsentController(
|
public ConsentController(
|
||||||
ILogger<ConsentController> logger,
|
ILogger<ConsentController> logger,
|
||||||
IIdentityServerInteractionService interaction,
|
IIdentityServerInteractionService interaction,
|
||||||
|
@ -14,7 +14,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers
|
|||||||
private readonly IOptionsSnapshot<AppSettings> _settings;
|
private readonly IOptionsSnapshot<AppSettings> _settings;
|
||||||
private readonly IRedirectService _redirectSvc;
|
private readonly IRedirectService _redirectSvc;
|
||||||
|
|
||||||
public HomeController(IIdentityServerInteractionService interaction, IOptionsSnapshot<AppSettings> settings,IRedirectService redirectSvc)
|
public HomeController(IIdentityServerInteractionService interaction, IOptionsSnapshot<AppSettings> settings, IRedirectService redirectSvc)
|
||||||
{
|
{
|
||||||
_interaction = interaction;
|
_interaction = interaction;
|
||||||
_settings = settings;
|
_settings = settings;
|
||||||
|
@ -20,8 +20,8 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
|
|||||||
{
|
{
|
||||||
private readonly IPasswordHasher<ApplicationUser> _passwordHasher = new PasswordHasher<ApplicationUser>();
|
private readonly IPasswordHasher<ApplicationUser> _passwordHasher = new PasswordHasher<ApplicationUser>();
|
||||||
|
|
||||||
public async Task SeedAsync(ApplicationDbContext context,IWebHostEnvironment env,
|
public async Task SeedAsync(ApplicationDbContext context, IWebHostEnvironment env,
|
||||||
ILogger<ApplicationDbContextSeed> logger, IOptions<AppSettings> settings,int? retry = 0)
|
ILogger<ApplicationDbContextSeed> logger, IOptions<AppSettings> settings, int? retry = 0)
|
||||||
{
|
{
|
||||||
int retryForAvaiability = retry.Value;
|
int retryForAvaiability = retry.Value;
|
||||||
|
|
||||||
@ -50,10 +50,10 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
|
|||||||
if (retryForAvaiability < 10)
|
if (retryForAvaiability < 10)
|
||||||
{
|
{
|
||||||
retryForAvaiability++;
|
retryForAvaiability++;
|
||||||
|
|
||||||
logger.LogError(ex, "EXCEPTION ERROR while migrating {DbContextName}", nameof(ApplicationDbContext));
|
logger.LogError(ex, "EXCEPTION ERROR while migrating {DbContextName}", nameof(ApplicationDbContext));
|
||||||
|
|
||||||
await SeedAsync(context,env,logger,settings, retryForAvaiability);
|
await SeedAsync(context, env, logger, settings, retryForAvaiability);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
|
|||||||
|
|
||||||
List<ApplicationUser> users = File.ReadAllLines(csvFileUsers)
|
List<ApplicationUser> users = File.ReadAllLines(csvFileUsers)
|
||||||
.Skip(1) // skip header column
|
.Skip(1) // skip header column
|
||||||
.Select(row => Regex.Split(row, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)") )
|
.Select(row => Regex.Split(row, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"))
|
||||||
.SelectTry(column => CreateApplicationUser(column, csvheaders))
|
.SelectTry(column => CreateApplicationUser(column, csvheaders))
|
||||||
.OnCaughtException(ex => { logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); return null; })
|
.OnCaughtException(ex => { logger.LogError(ex, "EXCEPTION ERROR: {Message}", ex.Message); return null; })
|
||||||
.Where(x => x != null)
|
.Where(x => x != null)
|
||||||
|
@ -4,7 +4,6 @@ using IdentityServer4.EntityFramework.Mappers;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.eShopOnContainers.Services.Identity.API.Configuration;
|
using Microsoft.eShopOnContainers.Services.Identity.API.Configuration;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -13,9 +12,9 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Data
|
|||||||
{
|
{
|
||||||
public class ConfigurationDbContextSeed
|
public class ConfigurationDbContextSeed
|
||||||
{
|
{
|
||||||
public async Task SeedAsync(ConfigurationDbContext context,IConfiguration configuration)
|
public async Task SeedAsync(ConfigurationDbContext context, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
|
|
||||||
//callbacks urls from config:
|
//callbacks urls from config:
|
||||||
var clientUrls = new Dictionary<string, string>();
|
var clientUrls = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Devspaces
|
namespace Microsoft.eShopOnContainers.Services.Identity.API.Devspaces
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Identity.API.Migrations
|
namespace Identity.API.Migrations
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Identity.API.Migrations.ConfigurationDb
|
namespace Identity.API.Migrations.ConfigurationDb
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using System;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using System;
|
||||||
|
|
||||||
namespace Identity.API.Migrations.PersistedGrantDb
|
namespace Identity.API.Migrations.PersistedGrantDb
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using IdentityServer4.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using IdentityServer4.Models;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
|
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System.Threading.Tasks;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.eShopOnContainers.Services.Identity.API.Models;
|
using Microsoft.eShopOnContainers.Services.Identity.API.Models;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Services
|
namespace Microsoft.eShopOnContainers.Services.Identity.API.Services
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using System.Threading.Tasks;
|
using Microsoft.AspNetCore.Authentication;
|
||||||
using Microsoft.AspNetCore.Authentication;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Identity.API.Services
|
namespace Microsoft.eShopOnContainers.Services.Identity.API.Services
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Services
|
|||||||
splitKey = "signin-oidc";
|
splitKey = "signin-oidc";
|
||||||
else
|
else
|
||||||
splitKey = "scope";
|
splitKey = "scope";
|
||||||
|
|
||||||
results = Regex.Split(result, splitKey);
|
results = Regex.Split(result, splitKey);
|
||||||
if (results.Length < 2)
|
if (results.Length < 2)
|
||||||
return "";
|
return "";
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Extensions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Extensions;
|
|
||||||
|
|
||||||
namespace Ordering.API.Application.Behaviors
|
namespace Ordering.API.Application.Behaviors
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using MediatR;
|
using MediatR;
|
||||||
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Extensions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Ordering.Domain.Exceptions;
|
using Ordering.Domain.Exceptions;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Extensions;
|
|
||||||
|
|
||||||
namespace Ordering.API.Application.Behaviors
|
namespace Ordering.API.Application.Behaviors
|
||||||
{
|
{
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Ordering.API.Application.Commands
|
namespace Ordering.API.Application.Commands
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ namespace Ordering.API.Application.Commands
|
|||||||
public async Task<bool> Handle(CancelOrderCommand command, CancellationToken cancellationToken)
|
public async Task<bool> Handle(CancelOrderCommand command, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber);
|
var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber);
|
||||||
if(orderToUpdate == null)
|
if (orderToUpdate == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
using System;
|
using MediatR;
|
||||||
using MediatR;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Collections;
|
|
||||||
using Ordering.API.Application.Models;
|
using Ordering.API.Application.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands
|
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands
|
||||||
{
|
{
|
||||||
|
@ -1,18 +1,12 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
|
|
||||||
using Ordering.API.Application.Models;
|
using Ordering.API.Application.Models;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using static Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands.CreateOrderCommand;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands
|
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands
|
||||||
{
|
{
|
||||||
public class CreateOrderDraftCommand : IRequest<OrderDraftDTO>
|
public class CreateOrderDraftCommand : IRequest<OrderDraftDTO>
|
||||||
{
|
{
|
||||||
|
|
||||||
public string BuyerId { get; private set; }
|
public string BuyerId { get; private set; }
|
||||||
|
|
||||||
public IEnumerable<BasketItem> Items { get; private set; }
|
public IEnumerable<BasketItem> Items { get; private set; }
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
private readonly IMediator _mediator;
|
private readonly IMediator _mediator;
|
||||||
|
|
||||||
// Using DI to inject infrastructure persistence Repositories
|
// Using DI to inject infrastructure persistence Repositories
|
||||||
public CreateOrderDraftCommandHandler(IMediator mediator, IIdentityService identityService)
|
public CreateOrderDraftCommandHandler(IMediator mediator, IIdentityService identityService)
|
||||||
{
|
{
|
||||||
_identityService = identityService ?? throw new ArgumentNullException(nameof(identityService));
|
_identityService = identityService ?? throw new ArgumentNullException(nameof(identityService));
|
||||||
_mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));
|
_mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Extensions;
|
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Extensions;
|
||||||
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency;
|
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Ordering.API.Application.Behaviors;
|
|
||||||
using Ordering.API.Application.Commands;
|
using Ordering.API.Application.Commands;
|
||||||
using System;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Ordering.API.Application.Commands
|
namespace Ordering.API.Application.Commands
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ namespace Ordering.API.Application.Commands
|
|||||||
{
|
{
|
||||||
// Regular CommandHandler
|
// Regular CommandHandler
|
||||||
public class SetAwaitingValidationOrderStatusCommandHandler : IRequestHandler<SetAwaitingValidationOrderStatusCommand, bool>
|
public class SetAwaitingValidationOrderStatusCommandHandler : IRequestHandler<SetAwaitingValidationOrderStatusCommand, bool>
|
||||||
{
|
{
|
||||||
private readonly IOrderRepository _orderRepository;
|
private readonly IOrderRepository _orderRepository;
|
||||||
|
|
||||||
public SetAwaitingValidationOrderStatusCommandHandler(IOrderRepository orderRepository)
|
public SetAwaitingValidationOrderStatusCommandHandler(IOrderRepository orderRepository)
|
||||||
@ -27,7 +27,7 @@ namespace Ordering.API.Application.Commands
|
|||||||
public async Task<bool> Handle(SetAwaitingValidationOrderStatusCommand command, CancellationToken cancellationToken)
|
public async Task<bool> Handle(SetAwaitingValidationOrderStatusCommand command, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber);
|
var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber);
|
||||||
if(orderToUpdate == null)
|
if (orderToUpdate == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Ordering.API.Application.Commands
|
namespace Ordering.API.Application.Commands
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ namespace Ordering.API.Application.Commands
|
|||||||
{
|
{
|
||||||
// Regular CommandHandler
|
// Regular CommandHandler
|
||||||
public class SetPaidOrderStatusCommandHandler : IRequestHandler<SetPaidOrderStatusCommand, bool>
|
public class SetPaidOrderStatusCommandHandler : IRequestHandler<SetPaidOrderStatusCommand, bool>
|
||||||
{
|
{
|
||||||
private readonly IOrderRepository _orderRepository;
|
private readonly IOrderRepository _orderRepository;
|
||||||
|
|
||||||
public SetPaidOrderStatusCommandHandler(IOrderRepository orderRepository)
|
public SetPaidOrderStatusCommandHandler(IOrderRepository orderRepository)
|
||||||
@ -30,7 +30,7 @@ namespace Ordering.API.Application.Commands
|
|||||||
await Task.Delay(10000, cancellationToken);
|
await Task.Delay(10000, cancellationToken);
|
||||||
|
|
||||||
var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber);
|
var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber);
|
||||||
if(orderToUpdate == null)
|
if (orderToUpdate == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Ordering.API.Application.Commands
|
namespace Ordering.API.Application.Commands
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ namespace Ordering.API.Application.Commands
|
|||||||
{
|
{
|
||||||
// Regular CommandHandler
|
// Regular CommandHandler
|
||||||
public class SetStockConfirmedOrderStatusCommandHandler : IRequestHandler<SetStockConfirmedOrderStatusCommand, bool>
|
public class SetStockConfirmedOrderStatusCommandHandler : IRequestHandler<SetStockConfirmedOrderStatusCommand, bool>
|
||||||
{
|
{
|
||||||
private readonly IOrderRepository _orderRepository;
|
private readonly IOrderRepository _orderRepository;
|
||||||
|
|
||||||
public SetStockConfirmedOrderStatusCommandHandler(IOrderRepository orderRepository)
|
public SetStockConfirmedOrderStatusCommandHandler(IOrderRepository orderRepository)
|
||||||
@ -30,7 +30,7 @@ namespace Ordering.API.Application.Commands
|
|||||||
await Task.Delay(10000, cancellationToken);
|
await Task.Delay(10000, cancellationToken);
|
||||||
|
|
||||||
var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber);
|
var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber);
|
||||||
if(orderToUpdate == null)
|
if (orderToUpdate == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Ordering.API.Application.Commands
|
namespace Ordering.API.Application.Commands
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ namespace Ordering.API.Application.Commands
|
|||||||
{
|
{
|
||||||
// Regular CommandHandler
|
// Regular CommandHandler
|
||||||
public class SetStockRejectedOrderStatusCommandHandler : IRequestHandler<SetStockRejectedOrderStatusCommand, bool>
|
public class SetStockRejectedOrderStatusCommandHandler : IRequestHandler<SetStockRejectedOrderStatusCommand, bool>
|
||||||
{
|
{
|
||||||
private readonly IOrderRepository _orderRepository;
|
private readonly IOrderRepository _orderRepository;
|
||||||
|
|
||||||
public SetStockRejectedOrderStatusCommandHandler(IOrderRepository orderRepository)
|
public SetStockRejectedOrderStatusCommandHandler(IOrderRepository orderRepository)
|
||||||
@ -30,10 +30,10 @@ namespace Ordering.API.Application.Commands
|
|||||||
await Task.Delay(10000, cancellationToken);
|
await Task.Delay(10000, cancellationToken);
|
||||||
|
|
||||||
var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber);
|
var orderToUpdate = await _orderRepository.GetAsync(command.OrderNumber);
|
||||||
if(orderToUpdate == null)
|
if (orderToUpdate == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
orderToUpdate.SetCancelledStatusWhenStockIsRejected(command.OrderStockItems);
|
orderToUpdate.SetCancelledStatusWhenStockIsRejected(command.OrderStockItems);
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
using MediatR;
|
using MediatR;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Ordering.API.Application.Commands
|
namespace Ordering.API.Application.Commands
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
||||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
_buyerRepository = buyerRepository;
|
_buyerRepository = buyerRepository;
|
||||||
_orderingIntegrationEventService = orderingIntegrationEventService;
|
_orderingIntegrationEventService = orderingIntegrationEventService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Handle(OrderStatusChangedToAwaitingValidationDomainEvent orderStatusChangedToAwaitingValidationDomainEvent, CancellationToken cancellationToken)
|
public async Task Handle(OrderStatusChangedToAwaitingValidationDomainEvent orderStatusChangedToAwaitingValidationDomainEvent, CancellationToken cancellationToken)
|
||||||
@ -48,5 +48,5 @@
|
|||||||
order.Id, order.OrderStatus.Name, buyer.Name, orderStockList);
|
order.Id, order.OrderStatus.Name, buyer.Name, orderStockList);
|
||||||
await _orderingIntegrationEventService.AddAndSaveEventAsync(orderStatusChangedToAwaitingValidationIntegrationEvent);
|
await _orderingIntegrationEventService.AddAndSaveEventAsync(orderStatusChangedToAwaitingValidationIntegrationEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,7 +19,7 @@
|
|||||||
private readonly ILoggerFactory _logger;
|
private readonly ILoggerFactory _logger;
|
||||||
private readonly IBuyerRepository _buyerRepository;
|
private readonly IBuyerRepository _buyerRepository;
|
||||||
private readonly IOrderingIntegrationEventService _orderingIntegrationEventService;
|
private readonly IOrderingIntegrationEventService _orderingIntegrationEventService;
|
||||||
|
|
||||||
|
|
||||||
public OrderStatusChangedToPaidDomainEventHandler(
|
public OrderStatusChangedToPaidDomainEventHandler(
|
||||||
IOrderRepository orderRepository, ILoggerFactory logger,
|
IOrderRepository orderRepository, ILoggerFactory logger,
|
||||||
@ -30,7 +30,7 @@
|
|||||||
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
||||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
_buyerRepository = buyerRepository ?? throw new ArgumentNullException(nameof(buyerRepository));
|
_buyerRepository = buyerRepository ?? throw new ArgumentNullException(nameof(buyerRepository));
|
||||||
_orderingIntegrationEventService = orderingIntegrationEventService ?? throw new ArgumentNullException(nameof(orderingIntegrationEventService));
|
_orderingIntegrationEventService = orderingIntegrationEventService ?? throw new ArgumentNullException(nameof(orderingIntegrationEventService));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Handle(OrderStatusChangedToPaidDomainEvent orderStatusChangedToPaidDomainEvent, CancellationToken cancellationToken)
|
public async Task Handle(OrderStatusChangedToPaidDomainEvent orderStatusChangedToPaidDomainEvent, CancellationToken cancellationToken)
|
||||||
@ -51,7 +51,7 @@
|
|||||||
buyer.Name,
|
buyer.Name,
|
||||||
orderStockList);
|
orderStockList);
|
||||||
|
|
||||||
await _orderingIntegrationEventService.AddAndSaveEventAsync(orderStatusChangedToPaidIntegrationEvent);
|
await _orderingIntegrationEventService.AddAndSaveEventAsync(orderStatusChangedToPaidIntegrationEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,7 +20,7 @@ namespace Ordering.API.Application.DomainEventHandlers.OrderShipped
|
|||||||
private readonly ILoggerFactory _logger;
|
private readonly ILoggerFactory _logger;
|
||||||
|
|
||||||
public OrderShippedDomainEventHandler(
|
public OrderShippedDomainEventHandler(
|
||||||
IOrderRepository orderRepository,
|
IOrderRepository orderRepository,
|
||||||
ILoggerFactory logger,
|
ILoggerFactory logger,
|
||||||
IBuyerRepository buyerRepository,
|
IBuyerRepository buyerRepository,
|
||||||
IOrderingIntegrationEventService orderingIntegrationEventService)
|
IOrderingIntegrationEventService orderingIntegrationEventService)
|
||||||
|
@ -1,19 +1,11 @@
|
|||||||
using System;
|
namespace Ordering.API.Application.DomainEventHandlers.OrderStartedEvent
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
using MediatR;
|
|
||||||
using Ordering.Domain.Events;
|
|
||||||
|
|
||||||
namespace Ordering.API.Application.DomainEventHandlers.OrderStartedEvent
|
|
||||||
{
|
{
|
||||||
public class SendEmailToCustomerWhenOrderStartedDomainEventHandler
|
public class SendEmailToCustomerWhenOrderStartedDomainEventHandler
|
||||||
//: IAsyncNotificationHandler<OrderStartedDomainEvent>
|
//: IAsyncNotificationHandler<OrderStartedDomainEvent>
|
||||||
{
|
{
|
||||||
public SendEmailToCustomerWhenOrderStartedDomainEventHandler()
|
public SendEmailToCustomerWhenOrderStartedDomainEventHandler()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//public async Task Handle(OrderStartedDomainEvent orderNotification)
|
//public async Task Handle(OrderStartedDomainEvent orderNotification)
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user