Refactored namespaces for ordering.infrastructure project

This commit is contained in:
Sumit Ghosh 2021-10-09 17:39:07 +05:30
parent 0c52323f8d
commit c007047291
13 changed files with 437 additions and 525 deletions

View File

@ -1,13 +1,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.EntityConfigurations;
namespace Ordering.Infrastructure.EntityConfigurations
{
class BuyerEntityTypeConfiguration
class BuyerEntityTypeConfiguration
: IEntityTypeConfiguration<Buyer>
{
{
public void Configure(EntityTypeBuilder<Buyer> buyerConfiguration)
{
buyerConfiguration.ToTable("buyers", OrderingContext.DEFAULT_SCHEMA);
@ -37,5 +32,4 @@ namespace Ordering.Infrastructure.EntityConfigurations
navigation.SetPropertyAccessMode(PropertyAccessMode.Field);
}
}
}

View File

@ -1,13 +1,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.EntityConfigurations;
namespace Ordering.Infrastructure.EntityConfigurations
{
class CardTypeEntityTypeConfiguration
class CardTypeEntityTypeConfiguration
: IEntityTypeConfiguration<CardType>
{
{
public void Configure(EntityTypeBuilder<CardType> cardTypesConfiguration)
{
cardTypesConfiguration.ToTable("cardtypes", OrderingContext.DEFAULT_SCHEMA);
@ -23,5 +18,4 @@ namespace Ordering.Infrastructure.EntityConfigurations
.HasMaxLength(200)
.IsRequired();
}
}
}

View File

@ -1,13 +1,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.EntityConfigurations;
namespace Ordering.Infrastructure.EntityConfigurations
{
class ClientRequestEntityTypeConfiguration
class ClientRequestEntityTypeConfiguration
: IEntityTypeConfiguration<ClientRequest>
{
{
public void Configure(EntityTypeBuilder<ClientRequest> requestConfiguration)
{
requestConfiguration.ToTable("requests", OrderingContext.DEFAULT_SCHEMA);
@ -15,5 +10,4 @@ namespace Ordering.Infrastructure.EntityConfigurations
requestConfiguration.Property(cr => cr.Name).IsRequired();
requestConfiguration.Property(cr => cr.Time).IsRequired();
}
}
}

View File

@ -1,14 +1,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
using System;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.EntityConfigurations;
namespace Ordering.Infrastructure.EntityConfigurations
class OrderEntityTypeConfiguration : IEntityTypeConfiguration<Order>
{
class OrderEntityTypeConfiguration : IEntityTypeConfiguration<Order>
{
public void Configure(EntityTypeBuilder<Order> orderConfiguration)
{
orderConfiguration.ToTable("orders", OrderingContext.DEFAULT_SCHEMA);
@ -82,5 +75,4 @@ namespace Ordering.Infrastructure.EntityConfigurations
// .HasForeignKey("OrderStatusId");
.HasForeignKey("_orderStatusId");
}
}
}

View File

@ -1,13 +1,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.EntityConfigurations;
namespace Ordering.Infrastructure.EntityConfigurations
{
class OrderItemEntityTypeConfiguration
class OrderItemEntityTypeConfiguration
: IEntityTypeConfiguration<OrderItem>
{
{
public void Configure(EntityTypeBuilder<OrderItem> orderItemConfiguration)
{
orderItemConfiguration.ToTable("orderItems", OrderingContext.DEFAULT_SCHEMA);
@ -55,5 +50,4 @@ namespace Ordering.Infrastructure.EntityConfigurations
.HasColumnName("PictureUrl")
.IsRequired(false);
}
}
}

View File

@ -1,13 +1,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.EntityConfigurations;
namespace Ordering.Infrastructure.EntityConfigurations
{
class OrderStatusEntityTypeConfiguration
class OrderStatusEntityTypeConfiguration
: IEntityTypeConfiguration<OrderStatus>
{
{
public void Configure(EntityTypeBuilder<OrderStatus> orderStatusConfiguration)
{
orderStatusConfiguration.ToTable("orderstatus", OrderingContext.DEFAULT_SCHEMA);
@ -23,5 +18,4 @@ namespace Ordering.Infrastructure.EntityConfigurations
.HasMaxLength(200)
.IsRequired();
}
}
}

View File

@ -1,14 +1,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
using System;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.EntityConfigurations;
namespace Ordering.Infrastructure.EntityConfigurations
{
class PaymentMethodEntityTypeConfiguration
class PaymentMethodEntityTypeConfiguration
: IEntityTypeConfiguration<PaymentMethod>
{
{
public void Configure(EntityTypeBuilder<PaymentMethod> paymentConfiguration)
{
paymentConfiguration.ToTable("paymentmethods", OrderingContext.DEFAULT_SCHEMA);
@ -61,5 +55,4 @@ namespace Ordering.Infrastructure.EntityConfigurations
.WithMany()
.HasForeignKey("_cardTypeId");
}
}
}

View File

@ -1,11 +1,8 @@
using System;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency
public class ClientRequest
{
public class ClientRequest
{
public Guid Id { get; set; }
public string Name { get; set; }
public DateTime Time { get; set; }
}
}

View File

@ -1,12 +1,8 @@
using System;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency
public interface IRequestManager
{
public interface IRequestManager
{
Task<bool> ExistAsync(Guid id);
Task CreateRequestForCommandAsync<T>(Guid id);
}
}

View File

@ -1,11 +1,7 @@
using Ordering.Domain.Exceptions;
using System;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency
public class RequestManager : IRequestManager
{
public class RequestManager : IRequestManager
{
private readonly OrderingContext _context;
public RequestManager(OrderingContext context)
@ -39,5 +35,4 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempoten
await _context.SaveChangesAsync();
}
}
}

View File

@ -1,21 +1,7 @@
using MediatR;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
using Ordering.Infrastructure;
using Ordering.Infrastructure.EntityConfigurations;
using System;
using System.Data;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure
public class OrderingContext : DbContext, IUnitOfWork
{
public class OrderingContext : DbContext, IUnitOfWork
{
public const string DEFAULT_SCHEMA = "ordering";
public DbSet<Order> Orders { get; set; }
public DbSet<OrderItem> OrderItems { get; set; }
@ -118,10 +104,10 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure
}
}
}
}
}
public class OrderingContextDesignFactory : IDesignTimeDbContextFactory<OrderingContext>
{
public class OrderingContextDesignFactory : IDesignTimeDbContextFactory<OrderingContext>
{
public OrderingContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<OrderingContext>()
@ -152,5 +138,4 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure
return Task.FromResult(default(object));
}
}
}
}

View File

@ -1,15 +1,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositories;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositories
{
public class BuyerRepository
public class BuyerRepository
: IBuyerRepository
{
{
private readonly OrderingContext _context;
public IUnitOfWork UnitOfWork
{
@ -64,5 +57,4 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositor
return buyer;
}
}
}

View File

@ -1,15 +1,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositories;
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositories
{
public class OrderRepository
public class OrderRepository
: IOrderRepository
{
{
private readonly OrderingContext _context;
public IUnitOfWork UnitOfWork
@ -59,5 +52,4 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositor
{
_context.Entry(order).State = EntityState.Modified;
}
}
}