public RedirectToRouteResult Create(CreateSaleViewModel viewModel)
        {
            var model = new CreateSaleModel()
            {
                CustomerId = viewModel.Sale.CustomerId,
                EmployeeId = viewModel.Sale.EmployeeId,
                ProductId = viewModel.Sale.ProductId,
                Quantity = viewModel.Sale.Quantity
            };

            _createCommand.Execute(model);

            return RedirectToAction("index", "sales");
        }
        public void TestGetCreateShouldReturnCreateSaleViewModel()
        {
            var viewModel = new CreateSaleViewModel();

            _mocker.GetMock<ICreateSaleViewModelFactory>()
                .Setup(p => p.Create())
                .Returns(viewModel);

            var viewResult = _controller.Create();

            var result = (CreateSaleViewModel) viewResult.Model;

            Assert.That(result, Is.EqualTo(viewModel));
        }
        public CreateSaleViewModel Create()
        {
            var employees = _employeesQuery.Execute();

            var customers = _customersQuery.Execute();

            var products = _productsQuery.Execute();

            var viewModel = new CreateSaleViewModel();

            viewModel.Employees = employees
                .Select(p => new SelectListItem()
                {
                    Value = p.Id.ToString(),
                    Text = p.Name
                })
                .ToList();

            viewModel.Customers = customers
                .Select(p => new SelectListItem()
                {
                    Value = p.Id.ToString(),
                    Text = p.Name
                })
                .ToList();

            viewModel.Products = products
                .Select(p => new SelectListItem()
                {
                    Value = p.Id.ToString(),
                    Text = p.Name + " ($" + p.UnitPrice + ")"
                })
                .ToList();

            viewModel.Sale = new CreateSaleModel();

            return viewModel;
        }