示例#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;
            }
        }
示例#2
0
        public async Task AddCustomerNoDatabase()
        {
            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.AddCustomer("BadTest"));
        }
示例#3
0
        public async Task AddCustomerSuccess()
        {
            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.AddCustomer("Barbara");

            Assert.Equal(5, customer.Id);
            Assert.Equal("Barbara", customer.Name);
        }
示例#4
0
        public async Task AddCustomerNewList()
        {
            var databaseRepoMock = new Mock <IDatabaseRepository>();

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

            var customer = await customerDataService.AddCustomer("Barbara");

            Assert.Equal(1, customer.Id);
            Assert.Equal("Barbara", customer.Name);
        }
        protected async Task HandleValidSubmit()
        {
            if (Customer.Id == Guid.Empty) //new
            {
                var addedCustomer = await CustomerDataService.AddCustomer(Customer);

                if (addedCustomer != Guid.Empty)
                {
                    StatusClass = "alert-success";
                    Message     = "New Customer added successfully.";
                    Saved       = true;
                }
                else
                {
                    StatusClass = "alert-danger";
                    Message     = "Something went wrong adding the new Customer. Please try again.";
                    Saved       = false;
                }
            }
        }