public async Task Process(GetCustomerDetailsInput input) { Customer customer = await customerReadOnlyRepository.Get(input.CustomerId); if (customer == null) { throw new CustomerNotFoundException($"The customer {input.CustomerId} does not exist or it was not processed yet."); } List <Order> orders = await orderReadOnlyRepository.GetByCustomer(input.CustomerId); List <OrderOutput> orderOutputs = new List <OrderOutput>(); if (orders.Count == 0) { throw new CustomerNotFoundException($"No order found for customer {input.CustomerId}."); } else { foreach (var item in orders) { OrderOutput orderOutput = outputConverter.Map <OrderOutput>(item); orderOutputs.Add(orderOutput); } } CustomerOutput output = outputConverter.Map <CustomerOutput>(customer); output = new CustomerOutput(customer.Id, customer.PIN.Text, customer.Name.Text, orderOutputs); outputBoundary.Populate(output); }
public async Task <Result <OrderOutput> > GetOrderById(string orderId) { Order order = await _orderRepository.FindAsync(orderId); if (order == null) { return new Result <OrderOutput>() { Success = false } } ; PHOTOnlineUser user = await _userRepository.FindAsync(order.UserId); OrderOutput result = new OrderOutput() { Order = order, Address = user.Address, FirstName = user.FirstName, LastName = user.LastName, PhoneNumber = user.PhoneNumber }; return(new Result <OrderOutput>() { Success = true, Data = result }); }
public async Task <OrderOutput> GetOrder(string orderNo) { var orderInfo = _sellAppService.GetOrderInfo(orderNo); var goods = _sellAppService.GetGoodsInfoById(orderInfo.GoodsId, SellType.Rmb); var discount = orderInfo.OrderCost / orderInfo.OriginalCost; var orderDic = new List <OrderInfoItem>(); orderDic.Add(new OrderInfoItem() { Label = "订单号", Value = orderInfo.SalesOrderNo, Key = "SalesOrderNo", }); orderDic.Add(new OrderInfoItem() { Label = "商品名称", Value = goods.GoodName, Key = "GoodName" }); orderDic.Add(new OrderInfoItem() { Label = "授权版本", Value = ((MemberRank)goods.MemberRank).GetChineseDescribe(), Key = "MemberRank" }); orderDic.Add(new OrderInfoItem() { Label = "有效期", Value = DateTime.Now.AddMonths(orderInfo.Count).ToString("yyyy-MM-dd HH:mm:ss"), Key = "ValidDate" }); if (!discount.Equals(1.00)) { orderDic.Add(new OrderInfoItem() { Label = "原价", Value = orderInfo.OriginalCost.ToString("0.00"), Key = "OriginalCost" }); orderDic.Add(new OrderInfoItem() { Label = "折扣", Value = discount.ToString("0.00"), Key = "discount" }); } var output = new OrderOutput() { OrderPrice = orderInfo.OrderCost, OrderInfo = orderDic, OrderNo = orderInfo.SalesOrderNo, }; return(output); }
public JsonResult GetMyOrderInfo() { string id = HttpContext.Session.GetString("IID"); OrderOutput order = _orderManageService.ViewMyOrder(id); HttpContext.Session.Remove("IID"); return(Json(order)); }
public JsonResult GetFinishedOrder() { int id = (int)HttpContext.Session.GetInt32("ViewID"); OrderOutput order = _orderManageService.GetFinishedOrderInfo(id); HttpContext.Session.Remove("ViewID"); return(Json(order)); }
public void Process(Input input) { HexagonalTemplate order = new HexagonalTemplate( input.Name, input.UseCases, input.UserInterface, input.DataAccess, input.Tips, input.SkipRestore); bus.Publish(order); trackingService.OrderReceived( order.Id, order.Name.Text, order.CommandLines); OrderOutput generateOutput = outputConverter.Map <OrderOutput>(order); outputBoundary.Populate(generateOutput); }
public async Task Process(RemoveBookInput input) { Book book = await bookReadOnlyRepository.Get(input.BookId); if (book == null) { throw new BookNotFoundException($"The book {input.BookId} does not exist."); } Basket basket = (input.BasketId != null)? await basketReadOnlyRepository.Get(input.BasketId):new Basket(); Removal removal = new Removal(book.Id); basket.RemoveBook(removal); await basketWriteOnlyRepository.Update(basket); OrderOutput orderResponse = outputConverter.Map <OrderOutput>(removal); RemoveBookOutput output = new RemoveBookOutput(orderResponse, basket.GetTotalPrice().Value); outputBoundary.Populate(output); }
public async Task <OrderOutput> Order(OrderInput input) { var goods = _sellAppService.GetGoodsInfoById(input.GoodId, input.SellType); var discount = _sellAppService.GetDiscount(goods.AuthRankId, input.SellType); if (goods.Term.HasValue) { if (input.Count != goods.Term.Value && input.UnitPrice.Equals(goods.UnitPrice) && input.Discount.Equals(discount)) { throw new LotteryDataException("订单信息错误,核对您的订单"); } } else { if (input.UnitPrice.Equals(goods.UnitPrice) && input.Discount.Equals(discount)) { throw new LotteryDataException("订单信息错误,核对您的订单"); } } var orderInfo = GenerateOrder(input, goods, discount); await SendCommandAsync(orderInfo); var orderDic = new List <OrderInfoItem>(); orderDic.Add(new OrderInfoItem() { Label = "订单号", Value = orderInfo.SalesOrderNo, Key = "SalesOrderNo", }); orderDic.Add(new OrderInfoItem() { Label = "商品名称", Value = goods.GoodName, Key = "GoodName" }); orderDic.Add(new OrderInfoItem() { Label = "授权版本", Value = ((MemberRank)goods.MemberRank).GetChineseDescribe(), Key = "MemberRank" }); orderDic.Add(new OrderInfoItem() { Label = "有效期", Value = DateTime.Now.AddMonths(orderInfo.Count).ToString("yyyy-MM-dd HH:mm:ss"), Key = "ValidDate" }); if (!discount.Equals(1.00)) { orderDic.Add(new OrderInfoItem() { Label = "原价", Value = orderInfo.OriginalCost.ToString("0.00"), Key = "OriginalCost" }); orderDic.Add(new OrderInfoItem() { Label = "折扣", Value = discount.ToString("0.00"), Key = "discount" }); } var output = new OrderOutput() { OrderPrice = orderInfo.OrderCost, OrderInfo = orderDic, OrderNo = orderInfo.SalesOrderNo, }; return(output); }
public RemoveBookOutput(OrderOutput order, double updatedTotalPrice) { this.Order = order; this.UpdatedTotalPrice = updatedTotalPrice; }
public AddBookOutput(OrderOutput order, double updatedTotalPrice) { Order = order; UpdatedTotalPrice = updatedTotalPrice; }