コード例 #1
0
        public MembershipCreateStatus CreateUser(string nom, string prenom, string password, string email)
        {
            MembershipCreateStatus createStatus;

            try
            {
                // MembershipUser newuser  = Membership.CreateUser(email, password, email);
                MembershipUser newuser = Membership.CreateUser(email, password, email, passwordQuestion: null, passwordAnswer: null, isApproved: true,
                                                               providerUserKey: null, status: out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    using (toutokaz_dbEntities ctx = new toutokaz_dbEntities()){
                        tb_account p = new tb_account
                        {
                            id_user         = (Guid)newuser.ProviderUserKey,
                            firstname       = prenom,
                            lastname        = nom,
                            email           = email,
                            username        = email,
                            id_account_type = 1,
                            status          = "active",
                        };

                        ctx.tb_account.Add(p);
                        ctx.SaveChanges();
                    }
                }
            }
            catch (MembershipCreateUserException exp) {
                throw exp;
            }

            return(createStatus);
        }
コード例 #2
0
        public void SendOFACFailedEmail1(TurnKeyBrokerSignUpDataContext dataContext, RegistrationInfo info)
        {
            var activeStore = dataContext.store_bases.FirstOrDefault(t => t.storeId == 1);

            if (dataContext == null)
            {
                dataContext = new TurnKeyBrokerSignUpDataContext();
            }
            string        email_id = "";
            emailTemplate em;
            string        fullName = string.Empty;
            // tb_account account = dataContext.tb_accounts.Where(a => a.storeURI == regModel.activeStore.uri && a.account_id == acc.account_id).FirstOrDefault();
            tb_account account = dataContext.tb_accounts.Where(a => a.storeURI == regModel.activeStore.uri && a.account_id == info.AccountId).FirstOrDefault();

            em = dataContext.emailTemplates.Where(e => e.storeId == activeStore.storeId && e.emailTemplateId == 48).FirstOrDefault();
            var        addresses = dataContext.tb_addresses.Where(add => add.account_id == account.account_id);
            tb_address primaryAddress;

            if (account.account_type_id == 3)
            {
                primaryAddress = addresses.Where(add => add.address_type_id == 1 && add.is_coapplicant == true).FirstOrDefault();
                email_id       = account.email_address;
            }
            else
            {
                primaryAddress = addresses.Where(add => add.address_type_id == 1).FirstOrDefault();
                email_id       = account.email_address; //primaryAddress
            }
            if (em != null && account != null && addresses != null && primaryAddress != null)
            {
                int templateID = em.emailTemplateId;

                string emailSubject = em.emailSubject;
                string emailBody    = em.emailBody;

                string firmAddress = string.Empty;

                firmAddress = string.IsNullOrEmpty(activeStore.address1) ? string.Empty : activeStore.address1 + "<br/>";
                firmAddress = firmAddress + (string.IsNullOrEmpty(activeStore.city) ? string.Empty : activeStore.city + " ");
                firmAddress = firmAddress + (string.IsNullOrEmpty(activeStore.state) ? string.Empty : activeStore.state + " ");
                firmAddress = firmAddress + (string.IsNullOrEmpty(activeStore.zipcode) ? string.Empty : activeStore.zipcode + " ");

                emailBody = emailBody.Replace("[FNAME]", primaryAddress.first_name);
                emailBody = emailBody.Replace("[LNAME]", primaryAddress.last_name);
                emailBody = emailBody.Replace("[FIRM]", activeStore.storeDisplayName);
                emailBody = emailBody.Replace("[FIRM ADDRESS]", firmAddress);
                emailBody = emailBody.Replace("[FIRM CUSTOMER SERVICE NUMBER]", (string.IsNullOrEmpty(activeStore.contactPhone) ? "" : activeStore.contactPhone));

                int    EmailLogID = EmailHelper.AddToEmailQueue(activeStore.uri, em.fromName, em.fromEmail, primaryAddress.first_name + " " + primaryAddress.last_name, email_id, em.ccEmail, em.bccEmail, emailSubject, emailBody);
                string message    = EmailHelper.SendEmail(em.fromName, em.fromEmail, primaryAddress.first_name + " " + primaryAddress.last_name, email_id, em.ccEmail, em.bccEmail, emailSubject, emailBody, em.isHtml);


                if (EmailLogID > 0)
                {
                    EmailHelper.UpdateEmailQueueStatus(EmailLogID, message.Trim().ToUpper().Equals("OK"), message);
                }
            }
        }
コード例 #3
0
        public string CreateUserPro(string nom, string prenom, string nom_entreprise, string password, string email)
        {
            string token = null;

            try
            {
                // create account and profile
                token = WebSecurity.CreateUserAndAccount(email, password, null, true);


                try
                {
                    Roles.AddUserToRole(email, "annonceur");
                }
                catch (System.Configuration.Provider.ProviderException exp)
                {
                    throw exp;
                }

                using (toutokaz_dbEntities ctx = new toutokaz_dbEntities())
                {
                    int        Id = WebSecurity.GetUserId(email);
                    tb_account p  = new tb_account
                    {
                        UserId          = Id,
                        firstname       = prenom,
                        lastname        = nom,
                        email           = email,
                        username        = email,
                        nom_entreprise  = nom_entreprise,
                        id_account_type = 2,
                        role            = "annonceur",
                        status          = "active",
                    };

                    ctx.tb_account.Add(p);
                    ctx.SaveChanges();
                }
            }
            catch (MembershipCreateUserException exp)
            {
                throw exp;
            }
            catch (InvalidOperationException exp)
            {
                throw exp;
            }

            return(token);
        }
コード例 #4
0
        public MembershipCreateStatus CreateUserProMembership(string nom, string prenom, string nom_entreprise, string password, string email)
        {
            MembershipCreateStatus createStatus;

            try
            {
                // MembershipUser newuser  = Membership.CreateUser(email, password, email);
                MembershipUser newuser = Membership.CreateUser(email, password, email, passwordQuestion: null, passwordAnswer: null, isApproved: true,
                                                               providerUserKey: null, status: out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    try
                    {
                        Roles.AddUserToRole(newuser.UserName, "annonceur");
                    }
                    catch (System.Configuration.Provider.ProviderException exp)
                    {
                        throw exp;
                    }


                    using (toutokaz_dbEntities ctx = new toutokaz_dbEntities())
                    {
                        tb_account p = new tb_account
                        {
                            id_user         = (Guid)newuser.ProviderUserKey,
                            firstname       = prenom,
                            lastname        = nom,
                            email           = email,
                            username        = email,
                            nom_entreprise  = nom_entreprise,
                            id_account_type = 2,
                            role            = "annonceur",
                            status          = "active",
                        };

                        ctx.tb_account.Add(p);
                        ctx.SaveChanges();
                    }
                }
            }
            catch (MembershipCreateUserException exp)
            {
                throw exp;
            }

            return(createStatus);
        }
コード例 #5
0
        public ActionResult EditUser(int UserId)
        {
            if (UserId != null)
            {
                tb_account acc = accRepository.GetAccountByUserId(UserId);
                if (acc == null)
                {
                    throw new HttpException(404, "no members found");
                }

                ViewBag.accountId = acc.id_account;
                ProfileViewModel profile = new ProfileViewModel
                {
                    id_account = acc.id_account,
                    Nom        = acc.lastname,
                    Prenom     = acc.firstname,
                    telephone  = acc.telephone,
                    address    = acc.adresse
                };
                return(View(profile));
            }
            return(RedirectToAction("userlist", "account", new { Area = "Admin" }));
        }
コード例 #6
0
        public ActionResult EditUser(ProfileViewModel model)
        {
            if (ModelState.IsValid)
            {
                tb_account acc = accRepository.GetById(model.id_account);
                acc.firstname = model.Prenom;
                acc.lastname  = model.Nom;
                acc.telephone = model.telephone;
                acc.adresse   = model.address;
                try
                {
                    accRepository.Update(acc);
                    accRepository.Save();
                }
                catch (Exception exp)
                {
                    throw exp;
                }
                return(RedirectToAction("userlist", "account", new { Area = "Admin" }));
            }

            return(View(model));
        }
コード例 #7
0
        public ActionResult EditProfile(ProfileViewModel model)
        {
            if (ModelState.IsValid)
            {
                tb_account acc = account.GetById(model.id_account);
                acc.firstname = model.Prenom;
                acc.lastname  = model.Nom;
                acc.telephone = model.telephone;
                acc.adresse   = model.address;
                acc.pseudo    = model.alias;
                try
                {
                    account.Update(acc);
                    account.Save();
                }
                catch (Exception exp)
                {
                    throw exp;
                }
                return(RedirectToAction("index", "mesannonces"));
            }

            return(View(model));
        }
コード例 #8
0
        public ActionResult EditProfile()
        {
            if (Request.IsAuthenticated)
            {
                string username = User.Identity.Name;
                int    UserId   = WebSecurity.GetUserId(username);
                //  MembershipUser user =  Membership.GetUser(username);

                tb_account acc = account.GetAccountByUserId(UserId);
                //ViewBag.accountId = acc.id_account;
                ProfileViewModel profile = new ProfileViewModel
                {
                    id_account = acc.id_account,
                    Nom        = acc.lastname,
                    Prenom     = acc.firstname,
                    telephone  = acc.telephone,
                    address    = acc.adresse
                };

                return(View(profile));
            }

            return(RedirectToAction("Index", "home"));
        }
コード例 #9
0
        public void SendThankYouEmail(TurnKeyBrokerSignUpDataContext dataContext, RegistrationInfo info)
        {
            string uri = "TradeZero";

            if (dataContext == null)
            {
                dataContext = new TurnKeyBrokerSignUpDataContext();
            }
            string        email_id = "";
            emailTemplate em;
            string        fullName = string.Empty;
            tb_account    account  = dataContext.tb_accounts.Where(a => a.storeURI == uri && a.account_id == info.AccountId).FirstOrDefault();//regModel.activeStore.uri

            if (account.trading_type == "Bitcoin")
            {
                em = dataContext.emailTemplates.Where(e => e.storeId == 1 && e.templateName == "New Bitcoin Account").FirstOrDefault();//regModel.activeStore.storeId
            }
            else
            {
                em = dataContext.emailTemplates.Where(e => e.storeId == 1 && e.templateName == "NEWACCOUNT").FirstOrDefault();//regModel.activeStore.storeId
            }
            var        addresses = dataContext.tb_addresses.Where(add => add.account_id == account.account_id);
            tb_address primaryAddress;

            if (account.account_type_id == 3)
            {
                primaryAddress = addresses.Where(add => add.address_type_id == 1 && add.is_coapplicant == true).FirstOrDefault();
                email_id       = account.email_address;
            }
            else
            {
                primaryAddress = addresses.Where(add => add.address_type_id == 1).FirstOrDefault();
                email_id       = primaryAddress.email_address;
            }
            if (em != null && account != null && addresses != null && primaryAddress != null)
            {
                int templateID = em.emailTemplateId;

                string emailSubject = em.emailSubject;
                string emailBody    = em.emailBody;

                string firmAddress = string.Empty;

                firmAddress = string.IsNullOrEmpty(regModel.activeStore.address1) ? string.Empty : regModel.activeStore.address1 + "<br/>";
                firmAddress = firmAddress + (string.IsNullOrEmpty(regModel.activeStore.city) ? string.Empty : regModel.activeStore.city + " ");
                firmAddress = firmAddress + (string.IsNullOrEmpty(regModel.activeStore.state) ? string.Empty : regModel.activeStore.state + " ");
                firmAddress = firmAddress + (string.IsNullOrEmpty(regModel.activeStore.zipcode) ? string.Empty : regModel.activeStore.zipcode + " ");

                emailBody = emailBody.Replace("[FNAME]", primaryAddress.first_name);
                emailBody = emailBody.Replace("[LNAME]", primaryAddress.last_name);
                emailBody = emailBody.Replace("[FIRM]", regModel.activeStore.storeDisplayName);
                emailBody = emailBody.Replace("[ACCOUNT]", account.customer_id);
                emailBody = emailBody.Replace("[FIRM ADDRESS]", firmAddress);
                emailBody = emailBody.Replace("[FIRM CUSTOMER SERVICE NUMBER]", (string.IsNullOrEmpty(regModel.activeStore.contactPhone) ? "" : regModel.activeStore.contactPhone));

                int    EmailLogID = TurnKeyBrokerSignUp.WebUI.Services.EmailHelper.AddToEmailQueue(regModel.activeStore.uri, em.fromName, em.fromEmail, primaryAddress.first_name + " " + primaryAddress.last_name, email_id, em.ccEmail, em.bccEmail, emailSubject, emailBody);
                string message    = TurnKeyBrokerSignUp.WebUI.Services.EmailHelper.SendEmail(em.fromName, em.fromEmail, primaryAddress.first_name + " " + primaryAddress.last_name, email_id, em.ccEmail, em.bccEmail, emailSubject, emailBody, em.isHtml);

                if (EmailLogID > 0)
                {
                    TurnKeyBrokerSignUp.WebUI.Services.EmailHelper.UpdateEmailQueueStatus(EmailLogID, message.Trim().ToUpper().Equals("OK"), message);
                }
            }
        }