Ejemplo n.º 1
0
        protected async Task HandleValidSubmit()
        {
            //Customer.CountryId = int.Parse(CountryId);
            //Customer.JobCategoryId = int.Parse(JobCategoryId);

            if (Customer.CustomerID == 0) //new
            {
                var addedCustomer = await CustomerDataService.AddCustomer(Customer);

                if (addedCustomer != null)
                {
                    StatusClass = "alert-success";
                    Message     = "Nieuwe klant succesvol toegevoegd.";
                    Saved       = true;
                }
                else
                {
                    StatusClass = "alert-danger";
                    Message     = "Er is iets misgegaan tijdens het aanmaken van een nieuwe klant. Probeer het opnieuw.";
                    Saved       = false;
                }
            }
            else
            {
                await CustomerDataService.UpdateCustomer(Customer);

                StatusClass = "alert-success";
                Message     = "Klantgegevens zijn succesvol bijgewerkt.";
                Saved       = true;
            }
        }
Ejemplo n.º 2
0
        public async Task UpdateCustomerCustomerNotFound()
        {
            var databaseRepoMock = new Mock <IDatabaseRepository>();

            databaseRepoMock.Setup(repo => repo.ReadDatabase().Result);
            databaseRepoMock.Setup(repo => repo.SaveDatabase(TestDatabaseFilled()));
            var customerDataService = new CustomerDataService(databaseRepoMock.Object, _mockLogger.Object);

            await Assert.ThrowsAnyAsync <Exception>(async() => await customerDataService.UpdateCustomer(new Customer(-999, "Barbara")));
        }
Ejemplo n.º 3
0
        public ActionResult EditCustomer(CustomerViewModel customer)
        {
            var customerDataService = new CustomerDataService();
            var result = customerDataService.UpdateCustomer(customer);

            return(new JsonResult()
            {
                Data = customer,
                ContentType = "application/json"
            });
        }
Ejemplo n.º 4
0
        public async Task UpdateCustomerSuccess()
        {
            var databaseRepoMock = new Mock <IDatabaseRepository>();

            databaseRepoMock.Setup(repo => repo.ReadDatabase().Result).Returns(TestDatabaseFilled);
            databaseRepoMock.Setup(repo => repo.SaveDatabase(TestDatabaseFilled()));
            var customerDataService = new CustomerDataService(databaseRepoMock.Object, _mockLogger.Object);

            var customer = await customerDataService.UpdateCustomer(new Customer(3, "Barbara"));

            Assert.Equal(3, customer.Id);
            Assert.Equal("Barbara", customer.Name);
        }
Ejemplo n.º 5
0
        protected async Task HandleValidSubmit()
        {
            CustomerDetailVm.CustomerTypeId = Guid.Parse(SelectedCustomerTypeId);

            ApiResponse <CustomerDetailVm> response;

            if (SelectedCustomerId == Guid.Empty)
            {
                response = await CustomerDataService.CreateCustomer(CustomerDetailVm);
            }
            else
            {
                response = await CustomerDataService.UpdateCustomer(CustomerDetailVm);
            }
            HandleResponse(response);
        }