コード例 #1
0
        public OrdersListViewModelTests()
        {
            var fixture = new OmitRecursionFixture();

            _orders = fixture.CreateMany <Order>();
            _ordersListViewModel = new OrdersListViewModel();
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: ivashyn/WaterStore
        private OrdersListViewModel Pagination(IEnumerable<OrderDTO> ordersOnPage, IEnumerable<OrderDTO> allUsersOrders, int totalOrders, bool recorderOrdersOnPageAndTotalOrders, int page = 1, int ordersPerPage = 10)
        {
            if (!recorderOrdersOnPageAndTotalOrders)
            {
                ordersOnPage = allUsersOrders.Skip((page - 1) * ordersPerPage).Take(ordersPerPage);
                totalOrders = allUsersOrders.Count();
            }
            PageInfo pageInfo = new PageInfo { PageNumber = page, PageSize = ordersPerPage, TotalItems = totalOrders };

            List<ManagerDTO> managers = _storeService.GetAllManagers().ToList();
            managers.Insert(0, new ManagerDTO { Name = "All", Id = 0 });

            List<WaterDTO> water = _storeService.GetAllWater().ToList();
            water.Insert(0, new WaterDTO { Provider = "All", Id = 0 });

            var ordersViewModel = new OrdersListViewModel
            {
                Orders = ordersOnPage.ToList(),
                Managers = new SelectList(managers, "Id", "Name"),
                Water = new SelectList(water, "Id", "Provider"),
                ObjectsPerPage = new SelectList(new List<int>() { 10, 15, 20 }),
                PageInfo = pageInfo
            };
            return ordersViewModel;
        }
コード例 #3
0
        private static FindSymbolViewModel GetVm(IFindSymbolService findSymbolService = null)
        {
            var dispatcherHelper = Substitute.For <IDispatcherHelper>();

            dispatcherHelper
            .When(x => x.InvokeOnUiThread(Arg.Any <Action>()))
            .Do(x =>
            {
                var action = x.Arg <Action>();
                action.Invoke();
            });

            var queueProcessor = Substitute.For <IQueueProcessor>();

            findSymbolService ??= Substitute.For <IFindSymbolService>();
            var factory = Substitute.For <INewOrderViewModelFactory>();

            var orderCalculationService = Substitute.For <IOrderCalculationService>();
            var orderManager            = Substitute.For <IOrderManager>();

            factory.Create().Returns(new NewOrderViewModel(dispatcherHelper, queueProcessor, findSymbolService, orderCalculationService, orderManager));

            var tradeRepository   = Substitute.For <ITradeRepository>();
            var marketDataManager = Substitute.For <IMarketDataManager>();

            var ordersListViewModel = new OrdersListViewModel(dispatcherHelper, queueProcessor, factory, tradeRepository, marketDataManager);

            return(new FindSymbolViewModel(dispatcherHelper, queueProcessor, findSymbolService, ordersListViewModel));
        }
コード例 #4
0
        public ActionResult ViewOrders(string query = null)
        {
            if (query != null)
            {
                var viewModel = new OrdersListViewModel()
                {
                    Heading      = "Maslshop - Search Orders Results",
                    Orders       = _unitOfWork.Orders.GetSearchedOrders(query),
                    Deliveries   = _unitOfWork.Deliveries.GetDeliveriesOptionsList(),
                    Payments     = _unitOfWork.Payments.GetPaymentTypes(),
                    OrderDetails = _unitOfWork.Orders.GetOrderDetailsList(),
                    OrderStats   = _unitOfWork.Orders.GetOrderStatsList(),
                    Users        = _unitOfWork.Admin.GetUsersWithoutAdmin(),
                    SearchTerm   = query
                };

                return(View(viewModel));
            }
            else
            {
                var viewModel = new OrdersListViewModel()
                {
                    Heading      = "Maslshop - List Of Orders",
                    Orders       = _unitOfWork.Orders.GetOrdersList(),
                    Deliveries   = _unitOfWork.Deliveries.GetDeliveriesOptionsList(),
                    Payments     = _unitOfWork.Payments.GetPaymentTypes(),
                    OrderDetails = _unitOfWork.Orders.GetOrderDetailsList(),
                    OrderStats   = _unitOfWork.Orders.GetOrderStatsList(),
                    Users        = _unitOfWork.Admin.GetUsersWithoutAdmin()
                };

                return(View(viewModel));
            }
        }
コード例 #5
0
        public void HistoryAsync_ReturnsView_Always()
        {
            var viewModel = new OrdersListViewModel();
            var result    = _orderController.HistoryAsync(viewModel).Result as ViewResult;
            var model     = result.Model as OrdersListViewModel;

            model.Should().NotBeNull();
        }
コード例 #6
0
        public void ListAsync_ReturnsViewWithOrderListViewModel_Always()
        {
            var viewModel = new OrdersListViewModel();

            var result = _orderController.ListAsync(viewModel).Result as ViewResult;
            var model  = result.Model;

            model.Should().BeAssignableTo <OrdersListViewModel>();
        }
コード例 #7
0
        public OrdersList(OrdersListViewModel om)
        {
            _ordersListViewModel = om;
            DataContext          = om;
            InitializeComponent();

            _ordersCollection         = (CollectionViewSource)(Resources["OrdersCollection"]);
            _ordersCollection.Filter += _ordersCollection_Filter;
        }
コード例 #8
0
        public IActionResult PreviousOrders(string search = "")
        {
            string userID            = GetUserID();
            var    orders            = _IOrderUI.GetPreviousOrders(userID, search);
            OrdersListViewModel olVM = new OrdersListViewModel();

            olVM.Orders = orders;

            return(View(olVM));
        }
コード例 #9
0
        public ActionResult Index(int companyId)
        {
            var orders = _orderRepository.GetByCompanyId(companyId);
            var model  = new OrdersListViewModel(orders)
            {
                CompanyId = companyId
            };

            return(View(model));
        }
コード例 #10
0
ファイル: OrderService.cs プロジェクト: JohnDiGriz/TestOrders
        public OrdersListViewModel GetOrders()
        {
            var list = new OrdersListViewModel();

            list.Orders.AddRange(Unit.Orders.GetAll().Select(x => x.ToViewModel()).ToList());
            list.Statuses.AddRange(Unit.Statuses.GetAll().Select(x => new SelectListItem()
            {
                Value = x.Name, Text = x.Name
            }).ToList());
            return(list);
        }
コード例 #11
0
ファイル: OrderService.cs プロジェクト: JohnDiGriz/TestOrders
        public OrdersListViewModel GetOrders(Expression <Func <Orders, bool> > predicate)
        {
            var list = new OrdersListViewModel();

            list.Orders.AddRange(Unit.Orders.GetRange(predicate).Select(x => x.ToViewModel()).ToList());
            list.Statuses.AddRange(Unit.Statuses.GetAll().Select(x => new SelectListItem()
            {
                Value = x.Name, Text = x.Name
            }).ToList());
            return(list);
        }
コード例 #12
0
        public ViewResult OrderList(string carid = null)
        {
            OrdersListViewModel viewModel = new OrdersListViewModel
            {
                Orders = _orderRepository.Orders
                         .Where(c => (c.CarId.ToString() == carid))
                         .OrderBy(c => c.Id).ToList(),
                CurrentCarId = carid
            };

            return(View(viewModel));
        }
コード例 #13
0
ファイル: OrderController.cs プロジェクト: kvoloboy/GameStore
        public async Task <IActionResult> HistoryAsync(OrdersListViewModel ordersListViewModel)
        {
            var maxDate = DateTime.UtcNow.AddDays(-Period.Month);

            if (ordersListViewModel.MaxDate == default)
            {
                ordersListViewModel.MaxDate = maxDate;
            }

            var pulledViewModel = await _ordersListViewModelFactory.CreateAsync(ordersListViewModel);

            return(View("History", pulledViewModel));
        }
コード例 #14
0
ファイル: OrderController.cs プロジェクト: megaded/Restoran
        public ActionResult Index()
        {
            var cookie     = Request.Cookies["Restoran"];
            var locationId = int.Parse(cookie["locationId"]);

            if (locationId == 0)
            {
                return(RedirectToAction("Index", "Location"));
            }
            var orders = unitOfWork.OrderRep.GetAll().Where(p => p.LocationId == locationId).ToList();
            OrdersListViewModel model = new OrdersListViewModel(orders);

            return(View("Index", model));
        }
コード例 #15
0
ファイル: OrderService.cs プロジェクト: JohnDiGriz/TestOrders
 public void ApplyChanges(OrdersListViewModel viewModel)
 {
     foreach (var order in viewModel.Orders)
     {
         if (!string.IsNullOrEmpty(order.OrderStatus) && order.OrderStatus != "None")
         {
             Unit.Orders.SetStatus(order.OxId, order.OrderStatus);
         }
         if (order.InvoiceNumber != null)
         {
             Unit.Orders.SetInvoiceNumber(order.OxId, (int)order.InvoiceNumber);
         }
     }
     Unit.Commit();
 }
コード例 #16
0
        public ActionResult UserOrders()
        {
            var viewModel = new OrdersListViewModel()
            {
                Heading      = "Your Orders",
                Orders       = _unitOfWork.Orders.GetUserOrders(HttpContext.User.Identity.GetUserId()),
                Deliveries   = _unitOfWork.Deliveries.GetDeliveriesOptionsList(),
                Payments     = _unitOfWork.Payments.GetPaymentTypes(),
                OrderDetails = _unitOfWork.Orders.GetOrderDetailsList(),
                OrderStats   = _unitOfWork.Orders.GetOrderStatsList(),
                OrdersList   = _unitOfWork.Orders.UserOrders(HttpContext.User.Identity.GetUserId())
            };

            return(View(viewModel));
        }
コード例 #17
0
        public async Task <IActionResult> Index(OrderSortingType orderSortingType, OrderSortingOption previousSortingOption)
        {
            OrderSortingOption newSortingOption = OrdersSortingLogic.GetNewSortingOption(orderSortingType, previousSortingOption);

            OrdersListViewModel ordersListViewModel = new OrdersListViewModel();

            ordersListViewModel.PreviousSortingOption = newSortingOption;

            string userId = await GetCurrentUserIdAsync();

            ordersListViewModel.Orders = orderRepository
                                         .GetUserOrders(userId)
                                         .SortBy(newSortingOption);

            return(View(ordersListViewModel));
        }
コード例 #18
0
        public void HistoryAsync_ReturnsViewWithFilteredOrders_Always()
        {
            var minDate       = new DateTime(2020, 1, 9);
            var maxDate       = new DateTime(2020, 1, 10);
            var testViewModel = new OrdersListViewModel
            {
                MinDate = minDate,
                MaxDate = maxDate
            };

            A.CallTo(() => _historyViewModelFactory.CreateAsync(testViewModel)).Returns(testViewModel);

            var result = _orderController.HistoryAsync(testViewModel).Result as ViewResult;
            var model  = result.Model as OrdersListViewModel;

            model.MinDate.Should().Be(minDate);
            model.MaxDate.Should().Be(maxDate);
        }
コード例 #19
0
        public ViewResult List(string manager, int page = 1)
        {
            OrdersListViewModel model = new OrdersListViewModel
            {
                Orders = _repository.Orders
                         .OrderBy(p => p.Number)
                         .Where(p => p.Manager.Contains(manager ?? ""))
                         .Skip((page - 1) * PageSize)
                         .Take(PageSize),
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = PageSize,
                    TotalItems   = _repository.Orders.Count(p => p.Manager.Contains(manager ?? ""))
                }
            };

            return(View(model));
        }
コード例 #20
0
        public ShellViewModel(
            CustomersViewModel customerListVM,
            OrdersListViewModel ordersListVM,
            AddEditCustomerViewModel addEditCustomerVM,
            AddNewOrderViewModel addNewOrderVM,
            IEventAggregator eventAggregator)
        {
            _navigationStates = new Dictionary <NavigationState, Action <NavigationState> >
            {
                [NavigationState.Search] = x => InternalNavigateTo(x, customerListVM),
                [NavigationState.Orders] = x => InternalNavigateTo(x, ordersListVM)
            };

            _customerListVM    = customerListVM;
            _addEditCustomerVM = addEditCustomerVM;
            _addNewOrderVM     = addNewOrderVM;

            eventAggregator.Subscribe(this);
        }
コード例 #21
0
        public async Task <ActionResult> ListOrders(string searchName, int page = 1)
        {
            ICollection <OrderModel> orders = await this._orderRepository.GetOrdersForOnePageAsync(searchName, pageSize, page);

            PagingInfo pageInfo = new PagingInfo
            {
                CurrentPage  = page,
                ItemsPerPage = pageSize,
                TotalItems   = await this._orderRepository.GetCountOrdersAsync(searchName)
            };
            OrdersListViewModel model = new OrdersListViewModel()
            {
                Orders     = orders,
                PagingInfo = pageInfo,
                searchName = searchName
            };

            return(View(model));
        }
コード例 #22
0
        // GET: Orders/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            OrdersListViewModel order = new OrdersListViewModel(await _context.Orders
                                                                .Include(o => o.ReagentOrders)
                                                                .ThenInclude(r => r.Reagent)
                                                                .AsNoTracking().
                                                                FirstOrDefaultAsync(m => m.ID == id));

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

            return(View(order));
        }
コード例 #23
0
        public ViewResult List(string category, int page = 1)
        {
            OrdersListViewModel model = new OrdersListViewModel
            {
                Orders = repository.Orders
                         .Where(p => category == null || p.Category == category)
                         .OrderBy(p => p.OrderID)
                         .Skip((page - 1) * PageSize)
                         .Take(PageSize),
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = page,
                    ItemsPerPage = PageSize,
                    TotalItems   = repository.Orders.Count()
                },
                CurrentCategory = category
            };

            return(View(model));
        }
コード例 #24
0
        public ActionResult UnFinished()
        {
            var orders = this.dataServices.OrderService
                         .GetAll()
                         .Where(x => x.Status.WorkFlowLevel < FinishedOrderMinWorkwlowLevel)
                         .OrderByDescending(x => x.Number)
                         .Select(x => new OrderViewModel
            {
                Number                         = x.Number,
                Date                           = x.Date,
                WarrantyCardNumber             = x.WarrantyCardNumber,
                WarrantyCardDate               = x.WarrantyCardDate,
                Article                        = x.Article,
                SerialNumber                   = x.SerialNumber,
                IsHighPriority                 = x.IsHighPriority,
                Defect                         = x.Defect,
                Info                           = x.Info,
                Status                         = x.Status.Name,
                IsWarrantyService              = x.IsWarrantyService,
                CustomerName                   = x.Customer.Name,
                CustomerPhoneNumber            = x.Customer.PhoneNumber,
                CustomerTown                   = x.Customer.Address.Town.Name,
                CustomerStreet                 = x.Customer.Address.Street.Name,
                CustomerAddressNumber          = x.Customer.Address.Number,
                CustomerAddressEntry           = x.Customer.Address.Entry,
                CustomerAddressFloor           = x.Customer.Address.Floor,
                CustomerAddressApartmentNumber = x.Customer.Address.ApartmentNumber,
                EmployeeName                   = x.User.EmployeeName,
                SupplierName                   = x.Supplier.Name
            })
                         .ToList();

            var viewModel = new OrdersListViewModel
            {
                Orders = orders
            };

            return(this.View(viewModel));
        }
コード例 #25
0
        // GET: OrderView
        public ActionResult Index(int?service)
        {
            IQueryable <Order> orders = db.Orders.Include(o => o.Client).Include(o => o.Employee).Include(o => o.Service);

            if (service != null && service != 0)
            {
                orders = orders.Where(p => p.ServiceId == service);
            }
            List <Service> services = db.Services.ToList();

            // устанавливаем начальный элемент, который позволит выбрать всех
            services.Insert(0, new Service {
                Name = "Все", Id = 0
            });

            OrdersListViewModel plvm = new OrdersListViewModel
            {
                Orders   = orders.ToList(),
                Services = new SelectList(services, "Id", "Name")
            };

            return(View(plvm));
        }
コード例 #26
0
        public async Task <OrdersListViewModel> ReportSearchAsync(string orderStatus, int timeInterval)
        {
            var orders = orderRepository.GetItems();

            if (orderStatus == "Booked")
            {
                orders = orders.Where(x => x.OrderStatus == OrderStatus.Booked);
            }
            if (orderStatus == "Cancelled")
            {
                orders = orders.Where(x => x.OrderStatus == OrderStatus.Cancelled);
            }
            if (orderStatus == "Returned")
            {
                orders = orders.Where(x => x.OrderStatus == OrderStatus.Returned);
            }

            if (timeInterval == 1) // За день.
            {
                orders = orders.Where(x => x.DateBooking.AddDays(1) >= DateTime.Now);
            }
            if (timeInterval == 2) // За неделю.
            {
                orders = orders.Where(x => x.DateBooking.AddDays(7) >= DateTime.Now);
            }
            if (timeInterval == 3) // За месяц.
            {
                orders = orders.Where(x => x.DateBooking.AddMonths(1) >= DateTime.Now);
            }

            var orderSearchVM = new OrdersListViewModel
            {
                Orders = await orders.Include(x => x.Book).Include(x => x.User).ToListAsync()
            };

            return(orderSearchVM);
        }
コード例 #27
0
 public OrdersListPage()
 {
     InitializeComponent();
     BindingContext = new OrdersListViewModel();
 }
コード例 #28
0
        public IActionResult Index(int page = 1)
        {
            try
            {
                int                   pageSize     = 5;
                HomeViewModel         entryCache   = memoryCache.Get <HomeViewModel>("Workshop");
                List <OrderViewModel> list         = new List <OrderViewModel>();
                var                   orders       = entryCache.Orders;
                var                   sessionOrder = HttpContext.Session.Get("OrderFilters");
                OrderFilterViewModel  filterOrder  = null;
                if (sessionOrder != null)
                {
                    filterOrder = Transformations.DictionaryToObject <OrderFilterViewModel>(sessionOrder);
                }
                foreach (var order in orders)
                {
                    list.Add(new OrderViewModel
                    {
                        Id             = order.orderID,
                        dateCompletion = order.dateCompletion,
                        dateReceipt    = order.dateReceipt,
                        fioOwner       = order.Car.Owner.fioOwner,
                        fioWorker      = order.Worker.fioWorker,
                        stateNumber    = order.Car.stateNumber,
                        workerID       = order.Worker.workerID,
                        price          = order.Breakdowns.Sum(p => p.Part.price)
                    });
                }
                IQueryable <OrderViewModel> filterList = list.AsQueryable();
                if (filterOrder != null)
                {
                    if (!string.IsNullOrEmpty(filterOrder.Car))
                    {
                        filterList = filterList.Where(p => p.stateNumber == filterOrder.Car);
                    }
                    if (filterOrder.SelectedWorker != null && filterOrder.SelectedWorker != -1)
                    {
                        filterList = filterList.Where(p => p.workerID == filterOrder.SelectedWorker);
                    }
                    switch (filterOrder._selectedType)
                    {
                    case "Отремонтированные":
                    {
                        if (filterOrder._date1 != null)
                        {
                            filterList = filterList.Where(p => p.dateCompletion != null &&
                                                          p.dateCompletion >= filterOrder._date1);
                        }
                        if (filterOrder._date2 != null)
                        {
                            filterList = filterList.Where(p => p.dateCompletion != null &&
                                                          p.dateCompletion <= filterOrder._date2);
                        }
                        break;
                    }

                    case "Поступившие":
                    {
                        if (filterOrder._date1 != null)
                        {
                            filterList = filterList.Where(p => p.dateReceipt >= filterOrder._date1);
                        }
                        if (filterOrder._date2 != null)
                        {
                            filterList = filterList.Where(p => p.dateReceipt <= filterOrder._date2);
                        }
                        break;
                    }
                    }
                }
                var count = filterList.Count();
                var items = filterList.Skip((page - 1) * pageSize).
                            Take(pageSize).ToList();
                if (filterOrder != null)
                {
                    filterOrder.Workers = new SelectList(entryCache.Workers, "workerID", "fioWorker");
                }
                OrdersListViewModel model = new OrdersListViewModel
                {
                    PageViewModel        = new PageViewModel(count, page, pageSize),
                    OrderFilterViewModel = filterOrder == null ? new OrderFilterViewModel(null, entryCache.Workers, null, DateTime.Now, DateTime.Now, null) : filterOrder,
                    Orders = items
                };
                return(View(model));
            }
            catch (Exception ex)
            {
            }
            return(View("Error"));
        }
コード例 #29
0
        public IActionResult Index(OrderFilterViewModel filterOrder)
        {
            int                   pageSize   = 5;
            HomeViewModel         entryCache = memoryCache.Get <HomeViewModel>("Workshop");
            List <OrderViewModel> list       = new List <OrderViewModel>();
            var                   orders     = entryCache.Orders;

            foreach (var order in orders)
            {
                list.Add(new OrderViewModel
                {
                    Id             = order.orderID,
                    dateCompletion = order.dateCompletion,
                    dateReceipt    = order.dateReceipt,
                    fioOwner       = order.Car.Owner.fioOwner,
                    fioWorker      = order.Worker.fioWorker,
                    stateNumber    = order.Car.stateNumber,
                    workerID       = order.Worker.workerID,
                    price          = order.Breakdowns.Sum(p => p.Part.price)
                });
            }
            IQueryable <OrderViewModel> filterList = list.AsQueryable();

            if (filterOrder.Car != null)
            {
                filterList = filterList.Where(p => p.stateNumber == filterOrder.Car);
            }
            if (filterOrder.SelectedWorker != null && filterOrder.SelectedWorker != -1)
            {
                filterList = filterList.Where(p => p.workerID == filterOrder.SelectedWorker);
            }
            switch (filterOrder._selectedType)
            {
            case "Отремонтированные":
            {
                if (filterOrder._date1 != null)
                {
                    filterList = filterList.Where(p => p.dateCompletion != null &&
                                                  p.dateCompletion >= filterOrder._date1);
                }
                if (filterOrder._date2 != null)
                {
                    filterList = filterList.Where(p => p.dateCompletion != null &&
                                                  p.dateCompletion <= filterOrder._date2);
                }
                break;
            }

            case "Поступившие":
            {
                if (filterOrder._date1 != null)
                {
                    filterList = filterList.Where(p => p.dateReceipt >= filterOrder._date1);
                }
                if (filterOrder._date2 != null)
                {
                    filterList = filterList.Where(p => p.dateReceipt <= filterOrder._date2);
                }
                break;
            }
            }
            var count = filterList.Count();
            var items = filterList.Take(pageSize).ToList();
            OrdersListViewModel model = new OrdersListViewModel
            {
                PageViewModel        = new PageViewModel(count, 1, pageSize),
                OrderFilterViewModel = new OrderFilterViewModel(filterOrder.Car,
                                                                db.Workers.ToList(), filterOrder.SelectedWorker, filterOrder._date1, filterOrder._date2, filterOrder._selectedType),
                Orders = items
            };

            return(View(model));
        }
コード例 #30
0
 public OrdersListView()
 {
     Context     = new OrdersListViewModel();
     DataContext = Context;
     InitializeComponent();
 }