Exemple #1
0
        public async Task <ActionResult <IEnumerable <ShipperAPIModel> > > GetAllShippers()
        {
            var shippers = await _shipperService.GetAllShippers();

            var shippersAPIModel = _mapper.Map <IEnumerable <Shippers>, IEnumerable <ShipperAPIModel> >(shippers);

            return(Ok(shippersAPIModel));
        }
Exemple #2
0
        public void GetAllShippers_ShouldCallOnce_WhenEmpty()
        {
            // Act
            _shipperService.GetAllShippers();

            // Assert
            _shipperRepository.Verify(x => x.GetMany(It.IsAny<int>(), It.IsAny<int>(), null, null,
                It.IsAny<SortDirection>(), It.IsAny<Expression<Func<ShipperModel, object>>[]>()), Times.Once);
        }
Exemple #3
0
        public async Task <IActionResult> Checkout()
        {
            OrderViewModel model = new OrderViewModel()
            {
                LinesCount = _cart.Lines.Count
            };

            if (User.Identity.IsAuthenticated)
            {
                var appUser = await _userManager.GetUserAsync(User);

                model.Addresses         = _addressService.GetAddressesByUserId(appUser.Id);
                model.AddressCollection = new SelectList(model.Addresses, "Id", "Title");
                model.PaymentCollection = new SelectList(_paymentService.GetAllPayments(), "PaymentId", "PaymentType");
                model.ShipperCollection = new SelectList(_shipperService.GetAllShippers(), "Id", "CompanyName");
            }

            return(View(model));
        }
        public IActionResult Detail(int orderId)
        {
            List <BillViewModel> bill = new List <BillViewModel>();

            Order order = _orderService.GetOrderWithId(orderId);

            if (order is null)
            {
                return(NotFound());
            }


            Address OrderAddress = _addressService.GetAddressesByUserId(order.CustomerId)
                                   .Single(I => I.Id == order.AddressId);
            Shipper OrderShipper = _shipperService.GetAllShippers().Single(I => I.Id == order.ShipperId);

            OrderDetailViewModel model = new OrderDetailViewModel()
            {
                OrderId          = order.Id,
                OrderDate        = order.OrderDate,
                ShipDate         = order.ShipDate,
                ShipStatus       = order.IsShipped ? "Kargoya Verildi" : "Kargoya Verilmedi",
                AllowStatus      = order.IsAllowed ? "Onaylandı" : "Onay Bekliyor",
                PaymentMethod    = _paymentService.GetPaymentNameWithId(order.PaymentId),
                CustomerFullName = _appUserService.GetOrderOwnerFullNameWithUserId(order.CustomerId),

                AddressId           = order.AddressId,
                AddressLine         = OrderAddress.AddressLine,
                AddressCity         = OrderAddress.City,
                AddressDistrict     = OrderAddress.District,
                AddressNeighborhood = OrderAddress.Neighborhood,
                AddressPostalCode   = OrderAddress.PostalCode,

                ShipperCompanyName = OrderShipper.CompanyName,
                ShipperPhone       = OrderShipper.Phone
            };

            model.OrderDetails = _orderDetailService.GetAllOrderDetails().Where(I => I.OrderId == orderId).ToList();

            foreach (var orderDetail in model.OrderDetails)
            {
                bill.Add(new BillViewModel()
                {
                    UnitPrice  = orderDetail.Price,
                    OrderId    = orderDetail.OrderId,
                    Quantity   = orderDetail.Quantity,
                    Product    = _productService.Products.Single(I => I.Id == orderDetail.ProductId),
                    TotalPrice = _orderDetailService.ComputeTotalPriceOfOrder(model.OrderId),
                });
            }

            model.Bill = bill;

            return(View(model));
        }
Exemple #5
0
        public IActionResult Order()
        {
            var customerEmail = User.Identity.Name;
            var order         = _orderService.GetAllCartOrder(customerEmail);
            var shippers      = _shipperService.GetAllShippers().Select(x => x.CompanyName).ToList();

            var orderViewModel = new OrderViewModel {
                Order = order, Shippers = shippers
            };

            return(View(orderViewModel));
        }
        public JsonResult GetAllRows()
        {
            IEnumerable <ShipperFlatViewModel> shippers;

            shippers = _shipperService.GetAllShippers().Shippers.ConvertToShipperFlatViewModels();
            DataTableViewModel data = new DataTableViewModel();

            data.draw            = "1";
            data.recordsTotal    = shippers.ToList().Count.ToString();
            data.recordsFiltered = shippers.ToList().Count.ToString();

            data.data = shippers.ToList <object>();

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Exemple #7
0
        public ActionResult Index()
        {
            OrderTableViewModel model = new OrderTableViewModel();

            model.Employees = _employeeService.GetAllEmployees().Employees.Select(u => new SelectListItem()
            {
                Text = u.LastName, Value = u.EmployeeID.ToString()
            }).ToList();
            model.Customers = _customerService.GetAllCustomers().Customers.Select(u => new SelectListItem()
            {
                Text = u.CompanyName, Value = u.CustomerID
            }).ToList();
            model.Shippers = _shipperService.GetAllShippers().Shippers.Select(u => new SelectListItem()
            {
                Text = u.CompanyName, Value = u.ShipperID.ToString()
            }).ToList();
            return(View("../Datatables/OrderTable", model));
        }