Example #1
0
        public async Task <IActionResult> Index(DateConfirmationDto model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (model.DateOfBirth == DateTime.MinValue)
                    {
                        throw new Exception("The date you entered is not valid, Please check you input and try again");
                    }

                    // process input and redirect here
                    var isCorrect = await _viewModel.ConfirmCustomerBirthDateAsync(model);

                    if (isCorrect)
                    {
                        _session.SetString("_sessionState", "valid");
                        return(RedirectToAction("OrderDetails", new { orderId = model.OrderId }));
                    }

                    ModelState.AddModelError("", "Entered date is not correct");
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
            }
            return(View(model));
        }
Example #2
0
        public async Task <bool> ConfirmOrderCustomerBirthDateAsync(DateConfirmationDto model)
        {
            var customer = await _orderService.GetOrderCustomerAsync(model.OrderId);

            if (customer == null)
            {
                return(false);
            }

            return(customer.DateOfBirth.Date == model.DateOfBirth.Date);
        }
Example #3
0
        public async Task <bool> ConfirmCustomerBirthDateAsync(DateConfirmationDto model)
        {
            var result = await _client.Post <bool, DateConfirmationDto>("api/order/confirmCustomerDoB", model);

            return(result);
        }