Beispiel #1
0
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            var tenant = _tenantProvider?.GetTenant();

            if (tenant != null)
            {
                optionsBuilder.UseMySQL(tenant?.DatabaseConnectionString);
            }

            base.OnConfiguring(optionsBuilder);
        }
Beispiel #2
0
 public ApplicationDbContext(DbContextOptions <ApplicationDbContext> options, ITenantProvider tenantProvider) : base(options)
 {
     _tenant = tenantProvider.GetTenant();
 }
Beispiel #3
0
 public IActionResult About()
 {
     ViewData["Message"] = _context.TenantId + ";" + _tenantProvider.GetTenant().Id;
     return(View());
 }
 public SingleTenantContextResolver(ITenantProvider tenantProvider, Guid tenantId)
 {
     this.tenantProvider = tenantProvider;
     Tenant = tenantProvider.GetTenant(tenantId);
 }
Beispiel #5
0
 public IActionResult About()
 {
     _context.Users.Add(new IdentityUser());
     ViewData["Message"] = _context.TenantId + ";" + _tenantProvider.GetTenant().Id;
     return(View());
 }
Beispiel #6
0
 public AppDbContext(DbContextOptions <AppDbContext> options,
                     ITenantProvider tenantProvider) : base(options)
 {
     _tenantProvider = tenantProvider;
     _tenantId       = tenantProvider?.GetTenant()?.TenantId;
 }
Beispiel #7
0
        public async Task <ActionResult <User> > RegisterUser([FromForm] UserViewModel uservm)
        {
            // Verifying the user already present on a tenant with incomplete KYC (Task 5)

            bool anyIncompleteKyc = GetIncompleteKyc(uservm.Email);

            if (anyIncompleteKyc)
            {
                User incompleteKyc = _context.Users.Where(k => k.Email == uservm.Email && (k.Status == Status.Failed || k.Status == Status.Declined)).FirstOrDefault();

                var iTenant = from u in _context.Users where u.Id == incompleteKyc.Id select u.Tenant;

                var iTenantId = iTenant.FirstOrDefault().Id;

                return(BadRequest("Error: Already an incomplete profile with the Tenant ID: " + iTenantId));
            }


            // Uploading files to the local directory, Customers/Documents ...

            this.DocFront = this.DocBack = null;

            var fdoc = uservm.DocFrontFile;

            if (fdoc != null && fdoc.Length > 0)
            {
                if (!IsUploaded(fdoc, out this.DocFront))
                {
                    return(BadRequest("Please upload valid front side document."));
                }
            }

            var bdoc = uservm.DocBackFile;

            if (bdoc != null && bdoc.Length > 0)
            {
                if (!IsUploaded(bdoc, out this.DocBack))
                {
                    return(BadRequest("Please upload valid back side document."));
                }
            }

            // Registering user on GetId

            string GetId = CreateGetId(uservm);

            // Getting KYC status of the user...

            string status = GetKycStatus(GetId);    // This can be a valid status value or an error message. So, it's verified below:


            // Get KYC user status in title case for matching the values of Status (Enum)

            TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;

            status = textInfo.ToTitleCase(status);

            if (!Enum.IsDefined(typeof(Status), status))
            {
                var statusObj = (JObject)JsonConvert.DeserializeObject(status);

                if (statusObj["error"] != null)
                {
                    return(Ok(status));
                }
            }

            // Saving user to the local database...

            User user = new User();

            user.GetId       = GetId;
            user.Tenant      = _provider.GetTenant(uservm.TenantId);
            user.FirstName   = uservm.FirstName;
            user.LastName    = uservm.LastName;
            user.DateOfBirth = uservm.DateOfBirth;
            user.Email       = uservm.Email;
            user.DocFront    = this.DocFront;
            user.DocBack     = this.DocBack;

            user.Status = (Status)Enum.Parse(typeof(Status), status);

            _context.Users.Add(user);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetKycUser), new { GetId = user.GetId }, new { GetId = user.GetId, KycSatus = status.ToString() }));
        }
Beispiel #8
0
        //public CustomerDbContext(DbContextOptions<CustomerDbContext> options)
        //    : base(options)
        //{
        //}

        // Comment this ctor, use above ctor for migrations.
        public CustomerDbContext(DbContextOptions <CustomerDbContext> options,
                                 ITenantProvider tenantProvider)
            : base(options)
        {
            _tenant = tenantProvider.GetTenant();
        }
Beispiel #9
0
        public EFRepository(DbContext dbContext, ITenantProvider tenantProvider)
        {
            _dbContext = dbContext;

            _tenant = tenantProvider.GetTenant();
        }
Beispiel #10
0
 public EFUnitOfWorkManager(DbContext dbContext, ITenantProvider tenantProvider)
 {
     this._dbContext = dbContext;
     this._tenant    = tenantProvider.GetTenant();
 }