コード例 #1
0
        public bool AddUser(APiRegisterViewModel model)
        {
            vCIOPRoEntities context = new vCIOPRoEntities();
            bool            flag    = false;

            using (var dbContextTransaction = context.Database.BeginTransaction())
            {
                try
                {
                    Guid UniqueTenantId = System.Guid.NewGuid();
                    User TntDtl         = new User()
                    {
                        TenantId    = UniqueTenantId,
                        FirstName   = model.FirstName,
                        LastName    = model.LastName,
                        Password    = model.Password,
                        UserName    = model.EmailId,
                        UserType    = 1,
                        LastLoginIP = "wqee",
                        UserID      = 12,
                        ProfilePic  = "rewr"
                    };
                    unitOfWork.GetRepositoryInstance <User>().Insert(TntDtl);
                    unitOfWork.Save();
                    Tenant TntDt2 = new Tenant()
                    {
                        TenantId                   = UniqueTenantId,
                        PlanId                     = 1,
                        CompanyName                = model.CompanyName,
                        SubDomain                  = model.SubDomain,
                        Status                     = 1,
                        CompanyLogo                = "dfgd",
                        StripeCustId               = "hgfhy",
                        StripeChargeId             = "gftyh",
                        StripeBalanceTransactionId = "hdtrt"
                    };
                    unitOfWork.GetRepositoryInstance <Tenant>().Insert(TntDt2);
                    unitOfWork.Save();

                    TenantBillingInfo TntDt3 = new TenantBillingInfo()
                    {
                        TenantId     = UniqueTenantId,
                        BillingEmail = model.BillingEmail,
                        Phone        = model.Phone,
                        Address1     = model.Address1,
                        Address2     = model.Address2,
                        CountryId    = 1,
                        StateId      = 2,
                        City         = model.City,
                        ZipCode      = model.ZipCode
                    };
                    unitOfWork.GetRepositoryInstance <TenantBillingInfo>().Insert(TntDt3);
                    unitOfWork.Save();

                    TenantCardInfo TntDt4 = new TenantCardInfo()
                    {
                        TenantId     = UniqueTenantId,
                        FirstName    = model.FirstName,
                        LastName     = model.LastName,
                        CardNo       = model.CardNo,
                        SecurityCode = model.SecurityCode,
                        ExpiryDate   = model.ExpiryDate,
                        CardType     = model.CardType,
                        Active       = true
                    };
                    unitOfWork.GetRepositoryInstance <TenantCardInfo>().Insert(TntDt4);

                    unitOfWork.Save();
                    dbContextTransaction.Commit();
                    flag = true;
                }

                catch (Exception ex)
                {
                    dbContextTransaction.Rollback();
                    throw ex;
                }
            }
            return(true);
        }
コード例 #2
0
        public bool AddUser(APiRegisterViewModel model)
        {
            vCIOPRoEntities context = new vCIOPRoEntities();
            bool            flag    = false;

            using (var dbContextTransaction = context.Database.BeginTransaction())
            {
                try
                {
                    Guid UniqueTenantId = System.Guid.NewGuid();
                    User TntDtl         = new User()
                    {
                        TenantId    = UniqueTenantId,
                        FirstName   = model.FirstName,
                        LastName    = model.LastName,
                        Password    = model.Password,
                        UserName    = model.Email,
                        UserType    = 1,
                        LastLoginIP = "wqee",
                        UserID      = 12,
                        ProfilePic  = "rewr"
                    };
                    unitOfWork.GetRepositoryInstance <User>().Insert(TntDtl);
                    unitOfWork.Save();
                    Tenant TntDt2 = new Tenant()
                    {
                        TenantId                   = UniqueTenantId,
                        PlanId                     = 1,
                        CompanyName                = model.CompanyName,
                        SubDomain                  = "dfsf",
                        EmailId                    = model.Email,
                        Status                     = 1,
                        CompanyLogo                = "dfgd",
                        StripeCustId               = "hgfhy",
                        StripeChargeId             = "gftyh",
                        StripeBalanceTransactionId = "hdtrt"
                    };
                    unitOfWork.GetRepositoryInstance <Tenant>().Insert(TntDt2);
                    unitOfWork.Save();

                    TenantBillingInfo TntDt3 = new TenantBillingInfo()
                    {
                        // BillingId=model.BillingId,
                        TenantId     = UniqueTenantId,
                        BillingEmail = model.BillingEmail,
                        Phone        = model.Phonenumber,
                        Address1     = model.Address,
                        Address2     = model.Address2,
                        CountryId    = model.CountryId,
                        StateId      = model.StateId,
                        City         = model.City,
                        ZipCode      = model.Postalcode
                    };
                    unitOfWork.GetRepositoryInstance <TenantBillingInfo>().Insert(TntDt3);
                    unitOfWork.Save();

                    TenantCardInfo TntDt4 = new TenantCardInfo()
                    {
                        // CreditId=model.CreditId,
                        TenantId     = UniqueTenantId,
                        FirstName    = model.FirstName,
                        LastName     = model.LastName,
                        CardNo       = model.CardNo,
                        SecurityCode = model.SecurityCode,
                        ExpiryDate   = model.ExpiryDate,
                        CardType     = 1,
                        Active       = true
                    };
                    unitOfWork.GetRepositoryInstance <TenantCardInfo>().Insert(TntDt4);

                    unitOfWork.Save();
                    dbContextTransaction.Commit();
                    flag = true;
                    var        toEmailIds1  = model.Email;
                    string     mailBody1    = "Greetings of The Day<br/> Congratulations you have been successfully registered with vCIOPRo.";
                    Attachment attachedfile = null;
                    ServiceLayer.EmailHelper.EmailHelper.SendEmail(toEmailIds1, mailBody1, "Registration Successful", attachedfile, true);
                }

                catch (Exception ex)
                {
                    dbContextTransaction.Rollback();
                    throw ex;
                }
            }
            return(true);
        }