Beispiel #1
0
        public IActionResult Create()
        {
            var model = new CreateSaleModel
            {
                Cars      = this.GetCarsToSelectListItem(),
                Customers = this.GetCustomersToSelectListItem()
            };

            return(View(model));
        }
        public void TestCreateSaleShouldCreateSale()
        {
            var sale = new CreateSaleModel();

            var result = _controller.Create(sale);

            _mocker.GetMock <ICreateSaleCommand>()
            .Verify(p => p.Execute(sale),
                    Times.Once);

            Assert.That(result.StatusCode,
                        Is.EqualTo(HttpStatusCode.Created));
        }
        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 TestPostCreateShouldReturnExecuteCreateSaleCommand()
        {
            var model = new CreateSaleModel();

            var viewModel = new CreateSaleViewModel()
            {
                Sale = model
            };

            _controller.Create(viewModel);

            _mocker.GetMock <ICreateSaleCommand>()
            .Verify(p => p.Execute(model));
        }
Beispiel #5
0
        public async Task <SaleResponseBase> CreateSale(CreateSaleModel model)
        {
            model.SellerId   = base.sellerId;
            model.PrivateKey = base.privateKey;

            var request = new RestRequest($"checkout/api/1/{base.sellerId}/rs/authService", Method.POST);
            var body    = JsonConvert.SerializeObject(model, Formatting.None, new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            });

            request.AddParameter("application/json", body, ParameterType.RequestBody);

            return(await base.Execute <SaleResponseBase>(request));
        }
Beispiel #6
0
        public IActionResult Confirm(CreateSaleModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Cars      = this.GetCarsToSelectListItem();
                model.Customers = this.GetCustomersToSelectListItem();

                return(View(nameof(Create), new { model }));
            }

            var sale = this.saleService.ReviewSale(model.Customer, model.Car, model.Discount);

            TempData["carId"]      = model.Car;
            TempData["customerId"] = model.Customer;
            TempData["discount"]   = sale.Discount;

            return(View(sale));
        }
Beispiel #7
0
        public void GivenTheFollowingSaleInfo(Table table)
        {
            var saleInfo = table.CreateInstance <CreateSaleInfoModel>();

            _context.Mocker.GetMock <IDateService>()
            .Setup(p => p.GetDate())
            .Returns(saleInfo.Date);

            var mockDatabase = _context.Mocker.GetMock <IDatabaseContext>();

            var lookup = new DatabaseLookup(mockDatabase.Object);

            _model = new CreateSaleModel
            {
                CustomerId = lookup.GetCustomerId(saleInfo.Customer),
                EmployeeId = lookup.GetEmployeeId(saleInfo.Employee),
                ProductId  = lookup.GetProductIdByName(saleInfo.Product),
                Quantity   = saleInfo.Quantity
            };
        }
Beispiel #8
0
        public HttpResponseMessage Create(CreateSaleModel sale)
        {
            _createCommand.Execute(sale);

            return(new HttpResponseMessage(HttpStatusCode.Created));
        }
Beispiel #9
0
 public void Post(CreateSaleModel model)
 {
     _createSaleCommand.Execute(model);
 }
        public void CreateCustomerSaleExample()
        {
            // All values given here are examples.
            // Please use appropriate values according to your Anthill configuration.
            var locationId    = 1;
            var customerModel = new CreateCustomerModel {
                TypeId = 1,
                MarketingConsentGiven = true,
                Address = new AddressModel {
                    Address1 = "74 Azalea Drive",
                    Address2 = null,
                    City     = "Anttown",
                    County   = "Antshire",
                    Postcode = "AH1 1AA"
                },
                CustomFields = new[] {
                    new CustomField {
                        Key = "Title", Value = "Mr"
                    },
                    new CustomField {
                        Key = "First Name", Value = "John"
                    },
                    new CustomField {
                        Key = "Last Name", Value = "Smith"
                    },
                    new CustomField {
                        Key = "Email", Value = "*****@*****.**"
                    },
                    new CustomField {
                        Key = "Telephone", Value = "01234567890"
                    }
                }
            };
            var saleModel = new CreateSaleModel {
                TypeId       = 1,
                CustomFields = new[] {
                    new CustomField {
                        Key = "Subtotal", Value = "140.00"
                    },
                    new CustomField {
                        Key = "Value (inc VAT)", Value = "168.00"
                    },
                    new CustomField {
                        Key = "Another custom field", Value = "A value that means something"
                    }
                },
                ExternalReference = "AB/123/456"
            };

            try {
                using (var client = new ApiV1SoapClient()) {
                    // endpoint will be configured from web.config system.serviceModel/client/endpoint settings
                    var result = client.CreateCustomerSale(_authHeader, locationId, Source, customerModel, saleModel);
                    // result is an int[] containing the CustomerID and SaleID
                    Console.WriteLine("Customer ID: {0}, Sale ID: {1}", result[0], result[1]);
                }
            }
            catch (Exception ex) {
                Console.WriteLine("An error has occurred\n{0}", ex);
            }
        }