Beispiel #1
0
        public async Task <ActionResult> Register(string tenant, CustomerModel customerModel)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(RedirectToAction("Index", "Events", new { tenant }));
                }

                var tenantDetails = (_catalogRepository.GetTenant(tenant)).Result;
                if (tenantDetails != null)
                {
                    SetTenantConfig(tenantDetails.TenantId, tenantDetails.TenantIdInString);

                    //check if customer already exists
                    var customer = (_tenantRepository.GetCustomer(customerModel.Email, tenantDetails.TenantId)).Result;

                    if (customer == null)
                    {
                        var customerId = await _tenantRepository.AddCustomer(customerModel, tenantDetails.TenantId);

                        customerModel.CustomerId = customerId;
                        customerModel.TenantName = tenant;

                        var userSessions = HttpContext.Session.GetObjectFromJson <List <CustomerModel> >("SessionUsers");
                        if (userSessions == null)
                        {
                            userSessions = new List <CustomerModel>
                            {
                                customerModel
                            };
                            HttpContext.Session.SetObjectAsJson("SessionUsers", userSessions);
                        }
                        else
                        {
                            userSessions.Add(customerModel);
                            HttpContext.Session.SetObjectAsJson("SessionUsers", userSessions);
                        }
                    }
                    else
                    {
                        var message = _localizer["User already exists."];
                        DisplayMessage(message, "Error");
                    }
                }
                else
                {
                    return(View("TenantError", tenant));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(0, ex, "Registration failed for tenant {tenant}", tenant);
                return(View("TenantError", tenant));
            }
            return(Redirect(Request.Headers["Referer"].ToString()));
        }
        public void Setup()
        {
            _tenantRepository        = new MockTenantRepository();
            _tenantId                = 1368421345;
            _numberOfTicketPurchases = 1;
            _ticketsSold             = 1;

            _tenantRepository.AddCustomer(CreateCustomerModel(), _tenantId);
        }
Beispiel #3
0
        public void AddCustomerTest()
        {
            var result = (_tenantRepository.AddCustomer(CreateCustomerModel(), _tenantId)).Result;

            Assert.AreEqual(123, result);
        }
Beispiel #4
0
 public void Setup()
 {
     _tenantRepository = new MockTenantRepository();
     _tenantRepository.AddCustomer(CreateCustomerModel(), _tenantId);
 }