public async Task CanCreateNewCustomer_OK()
        {
            InitializeCustomerHandler();
            var created = await _customerHandler.CreateCustomerAsync(new Customer()
            {
                CprNumber   = "12341231",
                CreatedById = "unitTest",
                Id          = "UnitTest",
                UserId      = Guid.NewGuid().ToString(),
                CreatedOn   = DateTime.Now,
                FullName    = "Test",
                Result      = Results.NotProven
            });

            _testOutputHelper.WriteLine(JsonConvert.SerializeObject(await _customerHandler.GetCustomersAsync(), Formatting.Indented));

            Assert.True(created);
        }
Example #2
0
        public async Task <IActionResult> CreateNewCustomer([FromForm] Customer input)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction(nameof(Customer)));
            }

            //Now we generate the ids
            input.UserId      = Guid.NewGuid().ToString();
            input.Id          = Guid.NewGuid().ToString();
            input.CreatedById = User?.Identity?.Name;
            input.CreatedOn   = DateTime.Now;

            await _customerHandler.CreateCustomerAsync(input);

            _logger.LogInformation($"customer is created: {input.UserId}");
            return(RedirectToAction("Customer", new { cprNumber = input.CprNumber }));
        }