Skip to content

Commit

Permalink
Implement factories and repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
kathulhur committed Jan 3, 2024
1 parent 2707969 commit 347e609
Show file tree
Hide file tree
Showing 112 changed files with 3,268 additions and 215 deletions.
Binary file modified .vs/ProjectEvaluation/storemanagementsystemx.metadata.v7.bin
Binary file not shown.
Binary file modified .vs/ProjectEvaluation/storemanagementsystemx.projects.v7.bin
Binary file not shown.
Binary file modified .vs/StoreManagementSystemX/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file modified .vs/StoreManagementSystemX/v17/.futdcache.v2
Binary file not shown.
Binary file modified .vs/StoreManagementSystemX/v17/.suo
Binary file not shown.
Binary file modified .vs/StoreManagementSystemX/v17/TestStore/0/testlog.manifest
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private IProductFactory CreateProductFactory()
{

IProductRepository _productRepository = new ProductRepository();
IBarcodeGenerationService barcodeGenerationService = new BarcodeGenerationService(_productRepository);
IBarcodeGenerationService barcodeGenerationService = new BarcodeGenerationService();
IProductFactory _productFactory = new ProductFactory(barcodeGenerationService);

return _productFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class TransactionAggregateTests
{
private static readonly PayLaterFactory payLaterFactory = new PayLaterFactory();
private static readonly ITransactionFactory _transactionFactory = new TransactionFactory(payLaterFactory);
private static readonly IProductFactory _productFactory = new ProductFactory(new BarcodeGenerationService(new ProductRepository()));
private static readonly IProductFactory _productFactory = new ProductFactory(new BarcodeGenerationService());

private ITransaction CreateEmptyTransaction()
{
Expand Down
2 changes: 1 addition & 1 deletion StoreManagementSystemX.Domain.Tests/UserRepositoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class UserRepositoryTests
private UserFactory CreateUserFactory()
{
var productRepository = new ProductRepository();
var barcodeGenerationService = new BarcodeGenerationService(productRepository);
var barcodeGenerationService = new BarcodeGenerationService();
var productFactory = new ProductFactory(barcodeGenerationService);
var payLaterFactory = new PayLaterFactory();
var transactionFactory = new TransactionFactory(payLaterFactory);
Expand Down
43 changes: 43 additions & 0 deletions StoreManagementSystemX.Infrastructure/DTO/PayLaterDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using StoreManagementSystemX.Domain.Aggregates.Roots.Transactions.Interfaces;
using StoreManagementSystemX.Domain.Factories.Transactions.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StoreManagementSystemX.Infrastructure.DTO
{
public class PayLaterDTO : IPayLaterReconstitutionArgs
{
public PayLaterDTO(IPayLater payLater)
{
CustomerName = payLater.CustomerName;
IsPaid = payLater.IsPaid;
PaidAt = payLater.PaidAt;
}

public PayLaterDTO(PayLaterDBModel payLater)
{
CustomerName = payLater.CustomerName;
IsPaid = payLater.IsPaid;
PaidAt = payLater.PaidAt;
}

public string CustomerName { get; set; }

public bool IsPaid { get; set; }

public DateTime? PaidAt { get; set; }

public PayLaterDBModel ToDBModel()
{
return new PayLaterDBModel
{
CustomerName = CustomerName,
IsPaid = IsPaid,
PaidAt = PaidAt
};
}
}
}
38 changes: 38 additions & 0 deletions StoreManagementSystemX.Infrastructure/DTO/ProductDBModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using StoreManagementSystemX.Domain.Aggregates.Roots.Products.Interfaces;
using StoreManagementSystemX.Domain.Factories.Products.Interfaces;
using StoreManagementSystemX.Infrastructure.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StoreManagementSystemX.Infrastructure.DTO
{
public class ProductDBModel : IProductReconstitutionArgs
{
public ProductDBModel() { }

public Guid Id { get; set; }

public string Barcode { get; set; } = string.Empty;

public string Name { get; set; } = string.Empty;

public decimal CostPrice { get; set; }

public decimal SellingPrice { get; set; }

public int InStock { get; set; }

public UserDBModel Creator { get; set; } = null!;

public Guid CreatorId { get; set; }

public List<TransactionProductDBModel> TransactionProducts { get; set; } = new List<TransactionProductDBModel>();

public List<TransactionDBModel> Transactions { get; set; } = new List<TransactionDBModel>();

public List<StockPurchaseDBModel> StockPurchases { get; set; } = new List<StockPurchaseDBModel>();
}
}
65 changes: 65 additions & 0 deletions StoreManagementSystemX.Infrastructure/DTO/ProductDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using StoreManagementSystemX.Domain.Aggregates.Roots.Products;
using StoreManagementSystemX.Domain.Aggregates.Roots.Products.Interfaces;
using StoreManagementSystemX.Domain.Factories.Products.Interfaces;
using StoreManagementSystemX.Infrastructure.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StoreManagementSystemX.Infrastructure.DTO
{
public class ProductDTO : IProductReconstitutionArgs
{
public ProductDTO(IProduct product)
{
Id = product.Id;
Barcode = product.Barcode;
Name = product.Name;
CostPrice = product.CostPrice;
SellingPrice = product.SellingPrice;
InStock = product.InStock;
CreatorId = product.CreatorId;
}

public ProductDTO(ProductDBModel product)
{
Id = product.Id;
Barcode = product.Barcode;
Name = product.Name;
CostPrice = product.CostPrice;
SellingPrice = product.SellingPrice;
InStock = product.InStock;
CreatorId = product.CreatorId;
}

public Guid Id { get; set; }

public string Barcode { get; set; } = string.Empty;

public string Name { get; set; } = string.Empty;

public decimal CostPrice { get; set; }

public decimal SellingPrice { get; set; }

public int InStock { get; set; }

public Guid CreatorId { get; set; }

public ProductDBModel ToDBModel()
{
return new ProductDBModel
{
Id = Id,
Barcode = Barcode,
Name = Name,
CostPrice = CostPrice,
SellingPrice = SellingPrice,
InStock = InStock,
CreatorId = CreatorId,
};
}
}
}
39 changes: 39 additions & 0 deletions StoreManagementSystemX.Infrastructure/DTO/StockPurchaseDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using StoreManagementSystemX.Domain.Aggregates.Roots.StockPurchases;
using StoreManagementSystemX.Domain.Aggregates.Roots.StockPurchases.Interfaces;
using StoreManagementSystemX.Domain.Factories.StockPurchases.Interfaces;
using StoreManagementSystemX.Infrastructure.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StoreManagementSystemX.Infrastructure.DTO
{
public class StockPurchaseDTO : IStockPurchaseReconstitutionArgs
{
public StockPurchaseDTO(StockPurchaseDBModel stockPurchase, IList<StockPurchaseProductDTO> stockPurchaseProducts)
{
StockManagerId = stockPurchase.StockManagerId;
Id = stockPurchase.Id;
DateTime = stockPurchase.DateTime;
StockPurchaseProducts = stockPurchaseProducts;
}

public StockPurchaseDTO(IStockPurchase stockPurchase, IEnumerable<StockPurchaseProductDTO> stockPurchaseProducts)
{
StockManagerId = stockPurchase.StockManagerId;
Id = stockPurchase.Id;
DateTime = stockPurchase.DateTime;
StockPurchaseProducts = stockPurchaseProducts;
}

public Guid StockManagerId { get; }

public Guid Id { get; }

public DateTime DateTime { get; }

public IEnumerable<IStockPurchaseProductReconstitutionArgs> StockPurchaseProducts { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using StoreManagementSystemX.Domain.Aggregates.Roots.StockPurchases.Interfaces;
using StoreManagementSystemX.Domain.Factories.StockPurchases.Interfaces;
using StoreManagementSystemX.Infrastructure.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StoreManagementSystemX.Infrastructure.DTO
{
public class StockPurchaseProductDTO : IStockPurchaseProductReconstitutionArgs
{
public StockPurchaseProductDTO(StockPurchaseProductDBModel stockPurchaseProduct)
{
ProductId = stockPurchaseProduct.ProductId;
Barcode = stockPurchaseProduct.Barcode;
Name = stockPurchaseProduct.Name;
Price = stockPurchaseProduct.Price;
QuantityBought = stockPurchaseProduct.QuantityBought;
}

public StockPurchaseProductDTO(IStockPurchaseProduct stockPurchaseProduct)
{
ProductId = stockPurchaseProduct.ProductId;
Barcode = stockPurchaseProduct.Barcode;
Name = stockPurchaseProduct.Name;
Price = stockPurchaseProduct.Price;
QuantityBought = stockPurchaseProduct.QuantityBought;
}

public Guid ProductId { get; }

public string Barcode { get; }

public string Name { get; }

public decimal Price { get; }

public int QuantityBought { get; }
}
}
32 changes: 32 additions & 0 deletions StoreManagementSystemX.Infrastructure/DTO/TransactionDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using StoreManagementSystemX.Domain.Factories.Transactions.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StoreManagementSystemX.Infrastructure.DTO
{
public class TransactionDTO : ITransactionReconstitutionArgs
{
public TransactionDTO(TransactionDBModel transaction, PayLaterDTO? payLater, IEnumerable<TransactionProductDTO> transactionProducts)
{
Id = transaction.Id;
SellerId = transaction.SellerId;
DateTime = transaction.DateTime;
PayLater = payLater;
TransactionProducts = transactionProducts;
}

public Guid SellerId { get; set; }

public DateTime DateTime { get; set; }

public Guid Id { get; set; }

public IPayLaterReconstitutionArgs? PayLater { get; set; } = null!;

public IEnumerable<ITransactionProductReconstitutionArgs> TransactionProducts { get; }

}
}
22 changes: 22 additions & 0 deletions StoreManagementSystemX.Infrastructure/DTO/TransactionProductDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using StoreManagementSystemX.Domain.Factories.Transactions.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StoreManagementSystemX.Infrastructure.DTO
{
public class TransactionProductDTO : ITransactionProductReconstitutionArgs
{
public Guid ProductId { get; set; }

public string ProductName { get; set; }

public decimal CostPrice { get; set; }

public decimal SellingPrice { get; set; }

public int QuantityBought { get; set; }
}
}
50 changes: 50 additions & 0 deletions StoreManagementSystemX.Infrastructure/DTO/UserDTO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using StoreManagementSystemX.Domain.Aggregates.Roots.Users.Interfaces;
using StoreManagementSystemX.Domain.Factories.Users.Interfaces;
using StoreManagementSystemX.Infrastructure.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StoreManagementSystemX.Infrastructure.DTO
{
public class UserDTO : IUserReconstitutionArgs
{

public UserDTO(IUser user)
{
Id = user.Id;
CreatorId = user.CreatorId;
Username = user.Username;
Password = user.Password;
}

public UserDTO(UserDBModel user)
{
Id = user.Id;
CreatorId = user.CreatorId;
Username = user.Username;
Password = user.Password;
}

public Guid Id { get; set; }

public Guid? CreatorId { get; set; }

public string Username { get; set; }

public string Password { get; set; }

public UserDBModel ToDBModel()
{
return new UserDBModel
{
Id = Id,
CreatorId = CreatorId,
Username = Username,
Password = Password,
};
}
}
}
Loading

0 comments on commit 347e609

Please sign in to comment.