- Some minor refactoring (renaming) and make work web clients applications that were 'broken' after refactoring dtos in ordering service in this branch.
- Update dockerfile to asp.net 1.1 in ordering
This commit is contained in:
parent
b005118a29
commit
1c1f7571e6
@ -33,7 +33,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands
|
|||||||
|
|
||||||
public string BuyerFullName { get; set; }
|
public string BuyerFullName { get; set; }
|
||||||
|
|
||||||
public IEnumerable<OrderItemDTO> Items => _orderItems;
|
public IEnumerable<OrderItemDTO> OrderItems => _orderItems;
|
||||||
|
|
||||||
public void AddOrderItem(OrderItemDTO item)
|
public void AddOrderItem(OrderItemDTO item)
|
||||||
{
|
{
|
||||||
@ -57,6 +57,8 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands
|
|||||||
public decimal Discount { get; set; }
|
public decimal Discount { get; set; }
|
||||||
|
|
||||||
public int Units { get; set; }
|
public int Units { get; set; }
|
||||||
|
|
||||||
|
public string PictureUrl { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,9 +55,9 @@
|
|||||||
|
|
||||||
var order = new Order(buyer.Id, payment.Id, new Address(message.Street, message.City, message.State, message.Country, message.ZipCode));
|
var order = new Order(buyer.Id, payment.Id, new Address(message.Street, message.City, message.State, message.Country, message.ZipCode));
|
||||||
|
|
||||||
foreach (var item in message.Items)
|
foreach (var item in message.OrderItems)
|
||||||
{
|
{
|
||||||
order.AddOrderItem(item.ProductId, item.ProductName, item.UnitPrice, item.Discount, item.Units);
|
order.AddOrderItem(item.ProductId, item.ProductName, item.UnitPrice, item.Discount, item.PictureUrl, item.Units);
|
||||||
}
|
}
|
||||||
|
|
||||||
_orderRepository.Add(order);
|
_orderRepository.Add(order);
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
o.Street as street, o.City as city, o.Country as country, o.State as state, o.ZipCode as zipcode
|
o.Street as street, o.City as city, o.Country as country, o.State as state, o.ZipCode as zipcode
|
||||||
FROM ordering.Orders o
|
FROM ordering.Orders o
|
||||||
LEFT JOIN ordering.Orderitems oi ON o.Id = oi.orderid
|
LEFT JOIN ordering.Orderitems oi ON o.Id = oi.orderid
|
||||||
LEFT JOIN ordering.orderstatus os on o.StatusId = os.Id
|
LEFT JOIN ordering.orderstatus os on o.OrderStatusId = os.Id
|
||||||
WHERE o.Id=@id"
|
WHERE o.Id=@id"
|
||||||
, new { id }
|
, new { id }
|
||||||
);
|
);
|
||||||
@ -52,7 +52,7 @@
|
|||||||
return await connection.QueryAsync<dynamic>(@"SELECT o.[Id] as ordernumber,o.[OrderDate] as [date],os.[Name] as [status],SUM(oi.units*oi.unitprice) as total
|
return await connection.QueryAsync<dynamic>(@"SELECT o.[Id] as ordernumber,o.[OrderDate] as [date],os.[Name] as [status],SUM(oi.units*oi.unitprice) as total
|
||||||
FROM [ordering].[Orders] o
|
FROM [ordering].[Orders] o
|
||||||
LEFT JOIN[ordering].[orderitems] oi ON o.Id = oi.orderid
|
LEFT JOIN[ordering].[orderitems] oi ON o.Id = oi.orderid
|
||||||
LEFT JOIN[ordering].[orderstatus] os on o.StatusId = os.Id
|
LEFT JOIN[ordering].[orderstatus] os on o.OrderStatusId = os.Id
|
||||||
GROUP BY o.[Id], o.[OrderDate], os.[Name]");
|
GROUP BY o.[Id], o.[OrderDate], os.[Name]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM microsoft/aspnetcore:1.0.1
|
FROM microsoft/aspnetcore:1.1
|
||||||
|
|
||||||
# Entry point through the copied assembly
|
# Entry point through the copied assembly
|
||||||
ENTRYPOINT ["dotnet", "Ordering.API.dll"]
|
ENTRYPOINT ["dotnet", "Ordering.API.dll"]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
|
||||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate
|
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate
|
@ -1,4 +1,4 @@
|
|||||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate
|
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
|
||||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -47,7 +47,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void AddOrderItem(int productId, string productName, decimal unitPrice, decimal discount, int units = 1)
|
public void AddOrderItem(int productId, string productName, decimal unitPrice, decimal discount, string pictureUrl, int units = 1)
|
||||||
{
|
{
|
||||||
var existingOrderForProduct = _orderItems.Where(o => o.ProductId == productId)
|
var existingOrderForProduct = _orderItems.Where(o => o.ProductId == productId)
|
||||||
.SingleOrDefault();
|
.SingleOrDefault();
|
||||||
@ -66,7 +66,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
|
|||||||
{
|
{
|
||||||
//add validated new order item
|
//add validated new order item
|
||||||
|
|
||||||
var orderItem = new OrderItem(productId, productName, unitPrice, discount, units);
|
var orderItem = new OrderItem(productId, productName, unitPrice, discount, pictureUrl, units);
|
||||||
|
|
||||||
_orderItems.Add(orderItem);
|
_orderItems.Add(orderItem);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate
|
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate
|
||||||
@ -18,7 +18,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
|
|||||||
|
|
||||||
protected OrderItem() { }
|
protected OrderItem() { }
|
||||||
|
|
||||||
public OrderItem(int productId, string productName, decimal unitPrice, decimal discount, int units = 1)
|
public OrderItem(int productId, string productName, decimal unitPrice, decimal discount, string PictureUrl, int units = 1)
|
||||||
{
|
{
|
||||||
if (units <= 0)
|
if (units <= 0)
|
||||||
{
|
{
|
||||||
@ -36,6 +36,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O
|
|||||||
_unitPrice = unitPrice;
|
_unitPrice = unitPrice;
|
||||||
_discount = discount;
|
_discount = discount;
|
||||||
_units = units;
|
_units = units;
|
||||||
|
_pictureUrl = PictureUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPictureUri(string pictureUri)
|
public void SetPictureUri(string pictureUri)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate
|
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate
|
||||||
{
|
{
|
||||||
using SeedWork;
|
using Seedwork;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork
|
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork
|
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork
|
||||||
{
|
{
|
||||||
|
|
||||||
public interface IAggregateRoot { }
|
public interface IAggregateRoot { }
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork
|
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork
|
||||||
{
|
{
|
||||||
public interface IRepository
|
public interface IRepository
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork
|
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork
|
||||||
{
|
{
|
||||||
public interface IUnitOfWork : IDisposable
|
public interface IUnitOfWork : IDisposable
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Metadata;
|
|||||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
|
||||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
|
||||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure
|
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.BuyerAggregate;
|
||||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderAggregate;
|
||||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
|
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Seedwork;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositories
|
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositories
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.eShopOnContainers.WebMVC.Models.Annotations;
|
using Microsoft.eShopOnContainers.WebMVC.Models.Annotations;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
@ -62,7 +62,8 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services
|
|||||||
order.Street = user.Street;
|
order.Street = user.Street;
|
||||||
order.State = user.State;
|
order.State = user.State;
|
||||||
order.Country = user.Country;
|
order.Country = user.Country;
|
||||||
|
order.ZipCode = user.ZipCode;
|
||||||
|
|
||||||
order.CardNumber = user.CardNumber;
|
order.CardNumber = user.CardNumber;
|
||||||
order.CardHolderName = user.CardHolderName;
|
order.CardHolderName = user.CardHolderName;
|
||||||
order.CardExpiration = new DateTime(int.Parse("20" + user.Expiration.Split('/')[1]),int.Parse(user.Expiration.Split('/')[0]), 1);
|
order.CardExpiration = new DateTime(int.Parse("20" + user.Expiration.Split('/')[1]),int.Parse(user.Expiration.Split('/')[0]), 1);
|
||||||
@ -82,6 +83,8 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services
|
|||||||
var ordersUrl = $"{_remoteServiceBaseUrl}/new";
|
var ordersUrl = $"{_remoteServiceBaseUrl}/new";
|
||||||
order.CardTypeId = 1;
|
order.CardTypeId = 1;
|
||||||
order.CardExpirationApiFormat();
|
order.CardExpirationApiFormat();
|
||||||
|
SetFakeIdToProducts(order);
|
||||||
|
|
||||||
StringContent content = new StringContent(JsonConvert.SerializeObject(order), System.Text.Encoding.UTF8, "application/json");
|
StringContent content = new StringContent(JsonConvert.SerializeObject(order), System.Text.Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
var response = await _apiClient.PostAsync(ordersUrl, content);
|
var response = await _apiClient.PostAsync(ordersUrl, content);
|
||||||
@ -96,11 +99,18 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services
|
|||||||
destination.Street = original.Street;
|
destination.Street = original.Street;
|
||||||
destination.State = original.State;
|
destination.State = original.State;
|
||||||
destination.Country = original.Country;
|
destination.Country = original.Country;
|
||||||
|
destination.ZipCode = original.ZipCode;
|
||||||
|
|
||||||
destination.CardNumber = original.CardNumber;
|
destination.CardNumber = original.CardNumber;
|
||||||
destination.CardHolderName = original.CardHolderName;
|
destination.CardHolderName = original.CardHolderName;
|
||||||
destination.CardExpiration = original.CardExpiration;
|
destination.CardExpiration = original.CardExpiration;
|
||||||
destination.CardSecurityNumber = original.CardSecurityNumber;
|
destination.CardSecurityNumber = original.CardSecurityNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetFakeIdToProducts(Order order)
|
||||||
|
{
|
||||||
|
var id = 1;
|
||||||
|
order.OrderItems.ForEach(x => { x.ProductId = id; id++; });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<input asp-for="ZipCode" type="hidden" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ export class OrdersService {
|
|||||||
order.city = identityInfo.address_city;
|
order.city = identityInfo.address_city;
|
||||||
order.country = identityInfo.address_country;
|
order.country = identityInfo.address_country;
|
||||||
order.state = identityInfo.address_state;
|
order.state = identityInfo.address_state;
|
||||||
order.zipcode = identityInfo.addrees_zipcode;
|
order.zipcode = identityInfo.address_zip_code;
|
||||||
order.cardexpiration = identityInfo.card_expiration;
|
order.cardexpiration = identityInfo.card_expiration;
|
||||||
order.cardnumber = identityInfo.card_number;
|
order.cardnumber = identityInfo.card_number;
|
||||||
order.cardsecuritynumber = identityInfo.card_security_number;
|
order.cardsecuritynumber = identityInfo.card_security_number;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user