public void TestOrdersToDtos()
        {
            Customer customer = new Customer()
            {
                CustomerId = 213, FirstName = "FakeFirstName", Name = "FakeName"
            };
            Order order = new Order()
            {
                OrderId = 1, OrderStatus = OrderStatus.Ordered, OrderDate = DateTime.Now, ShippedDate = null, Customer = customer, Version = 0
            };

            Assert.AreEqual(true, order.IsValid);

            IQueryable <Order> orders = new List <Order>()
            {
                order
            }.AsQueryable();
            IList <OrderListDTO> orderDtos = OrderAdapter.OrdersToListDtos(orders);

            Assert.AreEqual <int>(1, orderDtos.Count());

            OrderListDTO dto = orderDtos.First();

            Assert.AreEqual <int>(order.OrderId, dto.Id);
            Assert.AreEqual <int>((int)order.OrderStatus, (int)dto.OrderStatus);
            Assert.AreEqual <DateTime?>(order.OrderDate, dto.OrderDate);
            Assert.AreEqual <DateTime?>(order.ShippedDate, dto.ShippedDate);
            Assert.AreEqual <string>(order.Customer.ToString(), dto.CustomerName);

            Assert.AreEqual(true, dto.IsValid);
        }
Exemplo n.º 2
0
 public void Load(OrderListDTO obj)
 {
     _serviceFacade = ((ServiceLocator)App.Current.Resources["ServiceLocator"]).ServiceFacade;
     _serviceFacade.CustomerServiceClient.GetOrderByIdCompleted += new EventHandler <GetOrderByIdCompletedEventArgs>(CustomerServiceClient_GetOrderByIdCompleted);
     _serviceFacade.CustomerServiceClient.GetOrderByIdAsync(new GetOrderRequest()
     {
         Id = obj.Id
     });
 }
Exemplo n.º 3
0
        public async Task <OrderListDTO> Get(int OrderId)
        {
            OrderListDTO orderList = null;

            SqlConnection conn = new SqlConnection(_connectionString);

            try
            {
                orderList = await conn.QueryFirstOrDefaultAsync <OrderListDTO>(_procedures["getOrderListQuery"], new { OrderId }, commandType : CommandType.StoredProcedure);
            }
            catch
            {
                throw;
            }

            return(orderList ?? new NullOrderListDTO());
        }
Exemplo n.º 4
0
        public async Task <int> Update(OrderListDTO DTO)
        {
            int id = -1;

            SqlConnection conn = new SqlConnection(_connectionString);

            try
            {
                var model = new { DTO.Id, DTO.OrderId, DTO.ProductId, DTO.Quantity };

                id = await conn.ExecuteScalarAsync <int>(_procedures["updateOrderListQuery"], model, commandType : CommandType.StoredProcedure);
            }
            catch
            {
                throw;
            }

            return(id);
        }
        public void TestOrderViewModel()
        {
            OrderViewModel orderViewModel = new OrderViewModel();

            orderViewModel.Service = serviceFacade;
            OrderListDTO order = new OrderListDTO()
            {
                Id = 1
            };
            IList <OrderListDTO> orders = new List <OrderListDTO>()
            {
                order
            };

            Expect.Once.On(serviceFacade).Method("GetAllOrders").Will(Return.Value(orders));
            orderViewModel.LoadCommand.Command.Execute(null);

            Assert.AreEqual <int>(1, orderViewModel.Items.Count);
            Assert.AreEqual(order, orderViewModel.SelectedItem);
            Assert.AreEqual(Strings.OrderViewModel_DisplayName, orderViewModel.DisplayName);
        }
Exemplo n.º 6
0
        private OrderListDTO ToDTO(OrderListEntity entity)
        {
            OrderListDTO dto = new OrderListDTO();

            dto.CreateTime   = entity.CreateTime;
            dto.GoodsId      = entity.GoodsId;
            dto.GoodsName    = entity.Goods.Name;
            dto.Id           = entity.Id;
            dto.ImgUrl       = entity.ImgUrl;
            dto.Number       = entity.Number;
            dto.OrderCode    = entity.Order.Code;
            dto.OrderId      = entity.OrderId;
            dto.Price        = entity.Goods.Price;
            dto.RealityPrice = entity.Goods.RealityPrice;
            dto.TotalFee     = entity.TotalFee;
            dto.GoodsCode    = entity.Goods.Code;
            dto.IsReturn     = entity.IsReturn;
            dto.Inventory    = entity.Goods.Inventory;
            dto.Discount     = entity.Order.UpAmount == null?1: entity.Order.UpAmount.Value;
            dto.DiscountFee  = dto.TotalFee * dto.Discount;
            return(dto);
        }
        public async Task <IActionResult> AddOrder(ProductDTO product)
        {
            OrderDTO order = null;
            IEnumerable <OrderListDTO> ordersList = Enumerable.Empty <OrderListDTO>();

            try
            {
                int?userId = HttpContext.Session.GetInt32("UserId");

                if (userId == null)
                {
                    return(RedirectToAction("LoginForm", "User"));
                }

                order = await _orderService.Get((int)userId);

                if (order is NullOrderDTO)
                {
                    order = new OrderDTO
                    {
                        UserId        = (int)userId,
                        OrderStatusId = 1
                    };

                    order.Id = await _orderService.Create(order);
                }

                ordersList = await _orderListService.GetByOrderId(order.Id);

                if (!ordersList.Any())
                {
                    OrderListDTO orderList = new OrderListDTO
                    {
                        OrderId   = order.Id,
                        ProductId = product.Id,
                        Quantity  = 1
                    };

                    await _orderListService.Create(orderList);
                }
                else
                {
                    foreach (var item in ordersList)
                    {
                        if (item.ProductId == product.Id)
                        {
                            item.Quantity++;
                            await _orderListService.Update(item);
                        }
                        else
                        {
                            await _orderListService.Create(item);
                        }
                    }
                }

                HttpContext.Session.SetInt32("OrderId", order.Id);
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.GetBaseException().Message));
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 8
0
 public void Load(OrderListDTO obj)
 {
    _serviceFacade = ((ServiceLocator)App.Current.Resources["ServiceLocator"]).ServiceFacade;
    _serviceFacade.CustomerServiceClient.GetOrderByIdCompleted += new EventHandler<GetOrderByIdCompletedEventArgs>(CustomerServiceClient_GetOrderByIdCompleted);
    _serviceFacade.CustomerServiceClient.GetOrderByIdAsync(new GetOrderRequest() { Id = obj.Id });
 }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            try
            {
                ServiceFactory serviceFactory = new ServiceFactory("client_id", "client_secret", "store_name");
                var            product        = (ProductService)serviceFactory.GetService(AcendaSDK.Enums.ServiceType.Product);
                var            order          = (OrderService)serviceFactory.GetService(AcendaSDK.Enums.ServiceType.Order);
                var            inventory      = (InventoryService)serviceFactory.GetService(AcendaSDK.Enums.ServiceType.Inventory);
                var            customer       = (CustomerService)serviceFactory.GetService(AcendaSDK.Enums.ServiceType.Customer);


                ProductListDTO     productDTOs     = product.GetAll <ProductListDTO>();
                ProductDTO         productDTO      = product.GetById <ProductDTO>("2");
                ProductVariantsDTO productVariants = product.GetVariants("2");
                OrderListDTO       orderListDTO    = order.GetAll <OrderListDTO>();
                OrderDTO           orderDTO        = order.GetById <OrderDTO>("2562611");

                try
                {
                    //403 Yasak donuyor izinlerle ilgili
                    BaseDTO customerCreateResult = customer.Create(new CreateCustomerDTO()
                    {
                        first_name   = "Bob",
                        last_name    = "Smith",
                        email        = "*****@*****.**",
                        phone_number = "123-123-1234"
                    });
                }
                catch (Exception ex)
                {
                }
                try
                {
                    //401
                    BaseDTO customerDeleteResult = customer.Delete("1");
                }
                catch (Exception ex)
                {
                }

                BaseDTO inventoryUpdateResult = inventory.Update("5", new VariantDTO()
                {
                    inventory_quantity = "200"
                });

                BillingAddress billingAddress = new BillingAddress()
                {
                    first_name   = "bob",
                    last_name    = "smith",
                    phone_number = "123-123-1234",
                    street_line1 = "123 Test ln. ",

                    city    = "San Diego",
                    state   = "CA",
                    zip     = "92101",
                    country = "US"
                };
                ShippingAddress shippingAddress = new ShippingAddress()
                {
                    first_name   = "bob",
                    last_name    = "smith",
                    phone_number = "123-123-1234",
                    street_line1 = "123 Test ln. ",

                    city    = "San Diego",
                    state   = "CA",
                    zip     = "92101",
                    country = "US"
                };
                List <CreateOrderItem> creatOrderItem = new List <CreateOrderItem>();
                creatOrderItem.Add(new CreateOrderItem()
                {
                    quantity   = 1,
                    product_id = 2
                });



                CreateOrderDTO createOrderDTO = new CreateOrderDTO()
                {
                    email = "*****@*****.**",

                    billing_address = billingAddress,


                    shipping_address = shippingAddress,


                    items = creatOrderItem,
                };
                BaseDTO orderCreateResult = order.Create(createOrderDTO);

                try
                {
                    var result = order.CreateFulfillments("2562599", new FulfillmentsDTO()
                    {
                        tracking_numbers = new List <string>()
                        {
                            "1Z999AA10123456784"
                        },
                        tracking_urls = new List <string>()
                        {
                            "https://www.ups.com/track?loc=en_US&tracknum=1Z999AA10123456784/trackdetails"
                        },
                        tracking_company = "UPS",
                        shipping_method  = "Ground",
                        status           = "success",
                        items            = new List <FulfillmentItems>()
                        {
                            new FulfillmentItems()
                            {
                                id       = 74,
                                quantity = 1,
                            }
                        }
                    });
                }
                catch (Exception ex)
                {
                }

                try
                {
                    var orderGetFUlfillmentsResult = order.GetFulfillments("2562611", "86");
                }
                catch (Exception ex)
                {
                }



                Console.ReadKey();
            }


            catch (Exception ex)
            {
                var e = ex;
            }

            Console.ReadKey();
        }