Exemplo n.º 1
0
        public virtual string CreateOrderByClause(QueryPartCollector queryPartCollector)
        {
            StringBuilder orderByClause = new StringBuilder();

            if (queryPartCollector != null && queryPartCollector.OrderPartKeys != null)
            {
                bool isFirstElement = true;
                foreach (object key in queryPartCollector.OrderPartKeys)
                {
                    if (isFirstElement)
                    {
                        isFirstElement = false;
                        orderByClause.Append(" order by ");
                    }
                    else
                    {
                        orderByClause.Append(" , ");
                    }

                    OrderBase orderPart = (OrderBase)queryDescriptor.OrderParts[key];
                    orderByClause.Append(orderPart.ToPhrase());
                    orderByClause.Append(" ");
                }
            }

            return(orderByClause.ToString());
        }
Exemplo n.º 2
0
 protected OrderViewModelBase(OrderBase order)
 {
     Order       = order;
     NDoc        = order.NDoc;
     OrderStatus = order.Status;
     TotalSum    = order.TotalSum;
 }
Exemplo n.º 3
0
        private static OrderBase CreateTestOrderScenario()
        {
            var order = new OrderBase {
                OrderItems = new List <OrderItem>()
            };

            order.OrderItems.Add(new OrderItem
            {
                ItemInOrder = new ItemBase()
                {
                    Name   = "Book",
                    Amount = (decimal)23.8
                },
                Amount = 2
            });

            order.OrderItems.Add(new OrderItem
            {
                ItemInOrder = new ItemBase()
                {
                    Name   = "Wine",
                    Amount = (decimal)12.8
                },
                Amount = 6
            });
            return(order);
        }
Exemplo n.º 4
0
        public AddOrderViewModel CreateAddOrderViewModel(OrderBase order)
        {
            var addOrderViewModel = _container.Resolve <AddOrderViewModel>(new DependencyOverride <IEnumerable <OrderViewModelBase> >(new List <OrderViewModelBase>()));

            addOrderViewModel.SelectedOrder = _orderViewModelFactory.CreateOrderViewModel(order);
            return(addOrderViewModel);
        }
        public OrderControllerTestsBase()
        {
            _mediator        = new Mock <IMediator>();
            _orderController = new OrderController(_mediator.Object);

            _orderedItems = new List <OrderedItems>
            {
                new OrderedItems {
                    ProductType = ProductType.Calendar.ToString(), Quantity = 1
                },
                new OrderedItems {
                    ProductType = ProductType.Canvas.ToString(), Quantity = 2
                }
            };

            _orderBase = new OrderBase
            {
                Id = _orderId,
                RequiredBinWidth = _requiredBinWidth
            };

            _order = new Order
            {
                Id               = _orderId,
                CreatedOn        = DateTime.Now,
                RequiredBinWidth = _requiredBinWidth,
                OrderItems       = new List <OrderItem>()
            };

            _listOfOrders = new List <Order> {
                _order
            };
            _emptyListOfOrders = new List <Order>();
        }
Exemplo n.º 6
0
 public static OrderBase SetMessageLines(this OrderBase order, IOrderMessageLines orderMessageLines)
 {
     order.MessageLine1 = orderMessageLines.MessageLine1;
     order.MessageLine2 = orderMessageLines.MessageLine2;
     order.MessageLine3 = orderMessageLines.MessageLine3;
     return(order);
 }
Exemplo n.º 7
0
        public OrderBase CalcOrderPercentDiscount(OrderBase order)
        {
            var now = DateTime.Now;
            var activePercentDiscount = _percentDiscountRepository.AsQuery()
                                        .SingleOrDefault(p => p.FromDate <= now &&
                                                         p.ToDate >= now &&
                                                         p.FromTime <= now.TimeOfDay &&
                                                         p.ToTime >= now.TimeOfDay);

            if (activePercentDiscount == null)
            {
                return(order);
            }
            var productDiscountCount = 0;

            foreach (var orderItem in order.OrderItems)
            {
                var isExist = activePercentDiscount.ProductDiscounts.SingleOrDefault(item =>
                                                                                     item.Product.Id == orderItem.OrderProduct.ProductId);
                if (isExist != null)
                {
                    ++productDiscountCount;
                }
            }
            if (productDiscountCount > 1)
            {
                throw new DomainException("تعداد کالاهای این تخفیف بیشتر از یک می باشد");
            }
            return(order);
        }
Exemplo n.º 8
0
        public async Task UpdateOrderAsync(OrderBase updatedOrder)
        {
            var partitionKey = OrderEntity.GeneratePartitionKey(updatedOrder.TraderId);
            var rowKey       = OrderEntity.GenerateRowKey(updatedOrder.Id);


            var oldStatus = OrderStatus.Registered;

            await _tableStorage.ReplaceAsync(partitionKey, rowKey, itm =>
            {
                oldStatus = itm.GetOrder().Status;
                itm.SetOrder(updatedOrder);
                return(itm);
            });



            if (oldStatus == updatedOrder.Status)
            {
                await _tableStorage.ReplaceAsync(OrderEntity.GeneratePartitionAsAllOrders(oldStatus), rowKey, itm =>
                {
                    itm.SetOrder(updatedOrder);
                    return(itm);
                });

                return;
            }


            partitionKey = OrderEntity.GeneratePartitionAsAllOrders(oldStatus);
            await _tableStorage.DeleteAsync(partitionKey, rowKey);

            var newEntity = OrderEntity.Create(updatedOrder);
            await _tableStorage.InsertOrReplaceAsync(newEntity);
        }
Exemplo n.º 9
0
        private OrderViewModelBase CreateOrderViewModel(OrderBase order, string name)
        {
            if (order == null)
            {
                throw new ArgumentNullException(nameof(order));
            }

            OrderViewModelBase orderViewModel;

            if (order is BuyerOrder)
            {
                orderViewModel = _container.Resolve <BuyerOrderViewModel>(new DependencyOverride <BuyerOrder>(order));
            }
            else if (order is SupplierOrder)
            {
                orderViewModel = _container.Resolve <SupplierOrderViewModel>(new DependencyOverride <SupplierOrder>(order));
            }
            else
            {
                throw new NotSupportedException($"{order.GetType().Name} is not supported");
            }

            orderViewModel.Name = name;

            return(orderViewModel);
        }
Exemplo n.º 10
0
        private Output isChanged(bool isBuy, OrderBase orderAddRemove)
        {
            if (isBuy)
            {
                double? newIncomeFromSelling = _buyLinkedList.calculateExpense();
                //Debug.WriteLine("{0} IncomeFromSelling: {1}", orderAddRemove.TimeStamp, newIncomeFromSelling);
                if (!Test.areDoublesEqual(_incomeFromSelling.Total, newIncomeFromSelling))
                {
                    _incomeFromSelling.Timestamp = orderAddRemove.TimeStamp;
                    _incomeFromSelling.Total = newIncomeFromSelling;
                    return _incomeFromSelling;
                }

            }
            else
            {
                double? newExpenseBuying = _sellLinkedList.calculateExpense();
                //Debug.WriteLine("{0} ExpenseBuying: {1}", orderAddRemove.TimeStamp, newExpenseBuying);
                if (!Test.areDoublesEqual(_expenseBuying.Total, newExpenseBuying))
                {
                    _expenseBuying.Timestamp = orderAddRemove.TimeStamp;
                    _expenseBuying.Total = newExpenseBuying;
                    return _expenseBuying;
                }
            }

            return null;
        }
Exemplo n.º 11
0
        private void EditingBlock_OrderAdded(OrderBase order)
        {
            OrderItemEditorView editorView = new OrderItemEditorView(order);

            editorViewDict.Add(order, editorView);

            OrderEditorViewContext.Children.Add(editorView);
        }
Exemplo n.º 12
0
        private async Task HandleCommonStuff(OrderBase order)
        {
            var id = await _identityGenerator.GenerateNewIdAsync();

            order.Id         = id;
            order.Status     = OrderStatus.Registered;
            order.Registered = DateTime.UtcNow;
        }
Exemplo n.º 13
0
 private OrderType GetOrderType(OrderBase orderBase)
 {
     if (orderBase is PrivateOrder)
     {
         return(OrderType.PrivateOrder);
     }
     return(OrderType.AreaOrder);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Creates new instance of the <see cref="AdvancedOrderBase"/> class.
 /// </summary>
 /// <param name="baseOrder">Base order object for creating advanced one.</param>
 /// <param name="orderClass">Advanced order class for new smart order.</param>
 protected internal AdvancedOrderBase(
     OrderBase baseOrder,
     OrderClass orderClass)
     : base(baseOrder.EnsureNotNull(nameof(baseOrder)))
 {
     BaseOrder  = baseOrder;
     OrderClass = orderClass;
 }
 internal AdvancedOrderBase(
     OrderBase baseOrder,
     OrderClass orderClass)
     : base(baseOrder)
 {
     BaseOrder  = baseOrder;
     OrderClass = orderClass;
 }
Exemplo n.º 16
0
        public async Task RegisterOrderAsync(OrderBase order)
        {
            var newEntity = OrderEntity.Create(order);
            await _tableStorage.InsertAsync(newEntity);

            newEntity.PartitionKey = OrderEntity.GeneratePartitionKey(order.TraderId);
            await _tableStorage.InsertAsync(newEntity);
        }
Exemplo n.º 17
0
        public async Task <GetOrderDto> GetCurrentByAccountIdAsync(long accountId, CancellationToken ct = default)
        {
            _logger.LogInformation("Get current order by AccountId, {AccountId}", accountId);

            OrderBase currentOrder = await GetCurrentOrderAsync(accountId, ct);

            return(_mapper.Map <GetOrderDto>(currentOrder));
        }
Exemplo n.º 18
0
 public static OrderBase SetExchangeRate(this OrderBase order, Customer customer, decimal exchangeRate)
 {
     if (customer.IsForeignCurrencyAccount && exchangeRate > 0)
     {
         order.ExchangeRate = (double)exchangeRate;
     }
     return(order);
 }
        private void OrderStatusHandler(OrderBase order)
        {
            // Do something for handle order status changing.

            Console.WriteLine($"Order {order.OrigClientId} is {order.Status}");

            // Use OrigClientId for comparison of orders.
        }
Exemplo n.º 20
0
        public void CreateOrder3()
        {
            OrderBase order = PromotionTests.CreateOrder3();


            Assert.AreEqual(order.Products.ToList().Sum(p => p.DiscountedPrice), 280);
            // Assert.Fail();
        }
Exemplo n.º 21
0
 public ShopOrderLog(Guid id, Shop shop, OrderBase order)
 {
     Id             = id;
     Shop           = shop;
     Order          = order;
     CreationTime   = DateTime.Now;
     HasSuggestions = false;
     HasFactor      = false;
 }
        public OrderItemEditorView(OrderBase order)
        {
            this.order = order;

            InitializeComponent();
            Indicator.IsCountVisible = false;

            ValueEditorUtility.CreateValueEditorViews(order, ValueEditorViewContext);
        }
Exemplo n.º 23
0
        private static OrderDetail NewOrderDetail(OrderBase order)
        {
            var orderLine = new OrderDetail {
                TaxMode = order.TaxMode
            };

            order.Detail.Add(orderLine);
            return(orderLine);
        }
Exemplo n.º 24
0
        public static List <OrderBase> OrdersForCustomer(string CustomerID)
        {
            List <OrderBase> CustOrders = new List <OrderBase>();
            OrderBase        OB;
            OrderDetailsBase ODB;
            DataTable        dtOrders = new DataTable(), dtDetails;
            //get the orders
            string         sql = "Select * from Orders where CustomerID = @CustomerID order by OrderDate";
            string         sqlDet = "Select * from [Order Details] Where OrderID = @OrderID";
            SqlDataAdapter da, daDet;

            OpenDB();
            da = new SqlDataAdapter(sql, con);
            da.SelectCommand.Parameters.Add(new SqlParameter("@CustomerID", CustomerID));
            da.FillSchema(dtOrders, SchemaType.Source);
            da.Fill(dtOrders);
            foreach (DataRow dr in dtOrders.Rows)
            {
                OB                = new OrderBase();
                OB.OrderID        = (int)dr["OrderID"];
                OB.CustomerID     = CustomerID;
                OB.OrderDate      = (DateTime)dr["OrderDate"];
                OB.RequiredDate   = dr["RequiredDate"] != DBNull.Value ? (DateTime?)dr["RequiredDate"] : null;
                OB.ShippedDate    = dr["ShippedDate"] != DBNull.Value ? (DateTime?)dr["ShippedDate"] : null;
                OB.EmployeeID     = dr["EmployeeID"] != DBNull.Value ? (int?)dr["EmployeeID"] : null;
                OB.ShipVia        = dr["ShipVia"] != DBNull.Value ? (int?)dr["ShipVia"] : null;
                OB.Freight        = dr["Freight"] != DBNull.Value ? (decimal?)dr["Freight"] : null;
                OB.ShipName       = dr["ShipName"] != DBNull.Value ? (string)dr["ShipName"] : null;
                OB.ShipAddress    = dr["ShipAddress"] != DBNull.Value ? (string)dr["ShipAddress"] : null;
                OB.ShipCity       = dr["ShipCity"] != DBNull.Value ? (string)dr["ShipCity"] : null;
                OB.ShipRegion     = dr["ShipRegion"] != DBNull.Value ? (string)dr["ShipRegion"] : null;
                OB.ShipPostalCode = dr["ShipPostalCode"] != DBNull.Value ? (string)dr["ShipPostalCode"] : null;
                OB.ShipCountry    = dr["ShipCountry"] != DBNull.Value ? (string)dr["ShipCountry"] : null;

                //and now get all the details for the  order
                daDet = new SqlDataAdapter(sqlDet, con);
                daDet.SelectCommand.Parameters.Add(new SqlParameter("@OrderID", OB.OrderID));
                dtDetails = new DataTable(); //must make a new one or it will add on to the old one!
                daDet.FillSchema(dtDetails, SchemaType.Source);
                daDet.Fill(dtDetails);
                OB.ListOrderDetailsBase = new List <OrderDetailsBase>();
                foreach (DataRow drdet in dtDetails.Rows)
                {
                    ODB           = new OrderDetailsBase();
                    ODB.OrderID   = OB.OrderID;
                    ODB.ProductID = (int)drdet["ProductID"];
                    ODB.UnitPrice = (decimal)drdet["UnitPrice"];
                    ODB.Quantity  = (short)drdet["Quantity"];
                    ODB.Discount  = (float)drdet["Discount"];
                    OB.ListOrderDetailsBase.Add(ODB);
                }
                CustOrders.Add(OB);
            }
            return(CustOrders);
        }
Exemplo n.º 25
0
 public static OrderBase SetDeliveryAddress(this OrderBase order, Customer customer)
 {
     order.DeliverTo = new Address(
         customer.PhysicalAddress.Line1.EmptyIfNull(),
         customer.PhysicalAddress.Line2.EmptyIfNull(),
         customer.PhysicalAddress.Line3.EmptyIfNull(),
         customer.PhysicalAddress.Line4.EmptyIfNull(),
         customer.PhysicalAddress.Line5.EmptyIfNull(),
         customer.PhysicalAddress.Line6.EmptyIfNull());
     return(order);
 }
Exemplo n.º 26
0
        private async Task ValidateAddingGameToOrderAsync(OrderBase currentOrder, long gameId, CancellationToken ct)
        {
            bool isGameAlreadyExists =
                await _unitOfWork.OrderGameRepository.IsExists(currentOrder.AccountId, gameId, ct);

            if (isGameAlreadyExists)
            {
                _logger.LogInformation("Account {AccountId} already has game {GameId}", currentOrder.AccountId, gameId);
                throw new AccountAlreadyHasGameException();
            }
        }
Exemplo n.º 27
0
        public string GenerateInvoice(OrderBase order)
        {
            if (order.OrderItems.Any())
            {
                foreach (var ord in order.OrderItems)
                {
                }
            }

            return(string.Empty);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Обновляет объявление в базе данных по идентификатору <see cref="OrderBase.ID"/>
        /// </summary>
        /// <param name="id"></param>
        /// <param name="order"></param>
        // PUT api/order/5
        public void Put(int id, ActionData actionData)
        {
            OrderBase order = _dbContext.OrderBases.Find(id);

            order.ObjectBase.Title        = actionData.orderFields[1].ToString();
            order.ObjectBase.Description  = actionData.orderFields[2].ToString();
            order.ObjectBase.CategoryItem = _dbContext.CategoryItems.Find(actionData.orderFields[3]);
            order.ObjectBase.Location     = actionData.orderFields[4].ToString();

            _dbContext.SaveChanges();
        }
Exemplo n.º 29
0
 public static OrderBase SetPostalAddress(this OrderBase order, Customer customer)
 {
     order.InvoiceTo = new Address(
         customer.PostalAddress.Line1.EmptyIfNull(),
         customer.PostalAddress.Line2.EmptyIfNull(),
         customer.PostalAddress.Line3.EmptyIfNull(),
         customer.PostalAddress.Line4.EmptyIfNull(),
         customer.PostalAddress.Line5.EmptyIfNull(),
         customer.PostalAddress.Line6.EmptyIfNull());
     return(order);
 }
Exemplo n.º 30
0
        public void Delete(int id)
        {
            OrderBase  order = _dbContext.OrderBases.Find(id);
            ObjectBase obj   = _dbContext.ObjectBases.Find(id);

            if (order != null && obj != null)
            {
                _dbContext.OrderBases.Remove(order);
                _dbContext.ObjectBases.Remove(obj);
                _dbContext.SaveChanges();
            }
        }
Exemplo n.º 31
0
        public static OrderEntity Create(OrderBase src)
        {
            var result = new OrderEntity
            {
                PartitionKey = GeneratePartitionAsAllOrders(src.Status),
                RowKey       = GenerateRowKey(src.Id)
            };

            result.SetOrder(src);

            return(result);
        }
Exemplo n.º 32
0
 public static bool InsertOrder(OrderBase orderBase, OrderDetail detail)
 {
     try
     {
        orderBase =  orderBase.PostAdd();
        detail.OrderID = orderBase.ID;
        detail = detail.PostAdd();
        if (orderBase.ID != null && detail.ID != null)
            return true;
        else
            return false;
     }
     catch (Exception ex)
     {
         LogHelper.Write(CommonLogger.Application, ex);
         return false;
     }
 }
Exemplo n.º 33
0
        public Output removeOrder(OrderBase reduceOrder)
        {
            Order orderToRemove = _orderIDLkp[reduceOrder.OrderID];

            OrdersLinkedList relevantList = orderToRemove.IsBuy ? _buyLinkedList : _sellLinkedList;

            if (orderToRemove.Volume > reduceOrder.Volume)
            {
                orderToRemove.Volume -= reduceOrder.Volume;
            }
            else
            {
                relevantList.remove(orderToRemove);
                _orderIDLkp.Remove(orderToRemove.OrderID);
            }

            return isChanged(orderToRemove.IsBuy, reduceOrder);
        }
Exemplo n.º 34
0
        public ActionResult AddOrder()
        {
            string userName = System.Web.HttpContext.Current.User.Identity.Name;
            if (userName != null && userName != "")
            {
                OrderBase orderBase = new OrderBase();
                orderBase.CreateTime = DateTime.Now;
                orderBase.CreaterUser = userName;
                orderBase.TransferAccountNumber = Request["transferAccountNumber"].ToString();
                orderBase.TransferAccountTime = DateTime.ParseExact(Request["transferAccountTime"],"yyyy-MM-dd HH:mm", CultureInfo.CurrentCulture);
                orderBase.TransferMethod = Request["transferMethod"].ToString();
                orderBase.TransferredAmount = Convert.ToDecimal(Request["transferAmount"].ToString());
                orderBase.BeneficiaryAccountNo = Request["beneficiaryAccountNo"].ToString();
                orderBase.Comments = Request["comments"].ToString();
                orderBase.Source = Request["source"].ToString();
                orderBase.PayerName = userName;

                OrderDetail orderDetail = new OrderDetail();
                //orderDetail.OrderID = orderBase.ID;
                orderDetail.ProductName = Request["productName"].ToString();
                orderDetail.Numbers = Convert.ToInt32(Request["ProductAccount"].ToString());
                orderDetail.UnitPrice = Convert.ToDecimal(Request["originPrice"].ToString());
                orderDetail.TotalPrice = Convert.ToDecimal(Request["totalPrice"].ToString());
                orderDetail.PayTime = DateTime.ParseExact(Request["payTime"], "yyyy-MM-dd HH:mm", CultureInfo.CurrentCulture);
                orderDetail.PayAccount = Request["payAccount"].ToString();
                orderDetail.GoldAccount = Convert.ToInt64(Request["goldAccount"].ToString());
                //orderDetail.PayDeviceAccount = Request["payDeviceAccount"].ToString();
                orderDetail.Pay4PlayerId =Convert.ToInt64(Request["pay4PlayerId"].ToString());

                bool insertStatus = PlaceOrderBiz.InsertOrder(orderBase, orderDetail);

                if (insertStatus)
                    return Content("1");
                else
                    return Content("0");

            }
            else
            {
                return Content("0");
            }
        }
Exemplo n.º 35
0
        public Output removeOrder(OrderBase reduceOrder)
        {
            Order orderToRemove = _orderIDLkp[reduceOrder.OrderID];
            BinaryTree relevantBook = orderToRemove.IsBuy ? _buyBook : _sellBook;

            int oldVolume = orderToRemove.Volume;
            if (oldVolume > reduceOrder.Volume)
            {
                orderToRemove.Volume -= reduceOrder.Volume;
                var node = relevantBook.Find(orderToRemove);
                node.adjustExpense(oldVolume);
            }
            else
            {
                relevantBook.Remove(orderToRemove);
                _orderIDLkp.Remove(orderToRemove.OrderID);
            }

            return isChanged(orderToRemove.IsBuy, reduceOrder, relevantBook.totalExpense());
        }
Exemplo n.º 36
0
        private Output isChanged(bool isBuyOrder, OrderBase ord, double? newIncExp)
        {
            if (isBuyOrder)
            {
                if (!Test.areDoublesEqual(_incomeFromSelling.Total, newIncExp))
                {
                    _incomeFromSelling.Timestamp = ord.TimeStamp;
                    _incomeFromSelling.Total = newIncExp;
                    return _incomeFromSelling;
                }
            }
            else
            {
                if (!Test.areDoublesEqual(_expenseBuying.Total, newIncExp))
                {
                    _expenseBuying.Timestamp = ord.TimeStamp;
                    _expenseBuying.Total = newIncExp;
                    return _expenseBuying;
                }
            }

            return null;
        }