コード例 #1
0
 public void SetUp()
 {
     mockedClient = new Mock <IRestClient>();
     provider     = new AccountServiceProvider(mockedClient.Object);
 }
コード例 #2
0
 public AccountController(IAccountServiceProvider accountServiceProvider, IFileDirectoryServiceProvider fileDirectoryServiceProvider)
 {
     _accountServiceProvider       = accountServiceProvider;
     _fileDirectoryServiceProvider = fileDirectoryServiceProvider;
 }
コード例 #3
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_DO_CP_1724 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();
            //Put your code here
            var _providerFactory = ProviderFactory.Instance;
            IAccountServiceProvider accountService = _providerFactory.CreateAccountServiceProvider();
            List <String>           MailToL        = new List <String>();
            string mailToFromCompanySettings       = "";
            var    accountId   = Guid.Empty;
            var    accountMail = "";
            var    displayName = "";

            if (Parameter.type == "Arzt")
            {
                var account = cls_Get_Doctor_AccountID_for_DoctorID.Invoke(Connection, Transaction, new P_DO_GDAIDfDID_1549()
                {
                    DoctorID = Parameter.ID
                }, securityTicket).Result;
                accountId   = account.accountID;
                accountMail = account.accountMail;
                MailToL.Add(accountMail);
                displayName = account.DisplayName;
                var doctorDetails = cls_Get_Doctor_Details_for_DoctorID.Invoke(Connection, Transaction, new P_DO_GDDfDID_0823()
                {
                    DoctorID = Parameter.ID
                }, securityTicket).Result.Single();
                string maildoc = null;
                if (doctorDetails.DoctorComunication.Where(k => k.Type == "Email").SingleOrDefault() != null)
                {
                    maildoc = doctorDetails.DoctorComunication.Where(k => k.Type == "Email").Single().Content;
                }

                if (maildoc != null && maildoc != accountMail)
                {
                    MailToL.Add(maildoc);
                }
                mailToFromCompanySettings = cls_Get_Company_Settings.Invoke(Connection, Transaction, securityTicket).Result.Email;
                MailToL.Add(mailToFromCompanySettings);
            }
            else if (Parameter.type == "Praxis")
            {
                var account = cls_Get_Practice_AccountID_for_PracticeID.Invoke(Connection, Transaction, new P_DO_GPAIDfPID_1351()
                {
                    PracticeID = Parameter.ID
                }, securityTicket).Result;
                accountId   = account.accountID;
                accountMail = account.accountMail;
                MailToL.Add(accountMail);
                displayName = account.DisplayName;
                var practiceDetails = cls_Get_Practice_Details_for_PracticeID.Invoke(Connection, Transaction, new P_DO_GPDfPID_1432()
                {
                    PracticeID = Parameter.ID
                }, securityTicket).Result;
                string mailPractice = practiceDetails.FirstOrDefault().contact_email;
                if (mailPractice != null && mailPractice != accountMail)
                {
                    MailToL.Add(mailPractice);
                }
                mailToFromCompanySettings = cls_Get_Company_Settings.Invoke(Connection, Transaction, securityTicket).Result.Email;
                MailToL.Add(mailToFromCompanySettings);
            }


            BOp.Providers.TMS.Requests.ResetPasswordRequest request = new BOp.Providers.TMS.Requests.ResetPasswordRequest();
            request.AccountID    = accountId;
            request.NewPassword  = Parameter.password;
            request.SessionToken = securityTicket.SessionTicket;
            accountService.ResetPassword(request);

            string appName        = WebConfigurationManager.AppSettings["mmAppUrl"];
            var    prefix         = HttpContext.Current.Request.Url.AbsoluteUri.Contains("https") ? "https://" : "http://";
            var    imageUrl       = HttpContext.Current.Request.Url.AbsoluteUri.Substring(0, HttpContext.Current.Request.Url.AbsoluteUri.IndexOf("api")) + "Content/images/logo.png";
            var    email_template = File.ReadAllText(HttpContext.Current.Server.MapPath("~/EmailTemplates/PasswordChangedEmailTemplate.html"));

            var     subjectsJson = File.ReadAllText(HttpContext.Current.Server.MapPath("~/EmailTemplates/EmailSubjects.json"));
            dynamic subjects     = JsonConvert.DeserializeObject(subjectsJson);
            var     subjectMail  = subjects["NewPasswordSubject"].ToString();

            email_template = EmailTemplater.SetTemplateData(email_template, new
            {
                name                    = displayName,
                password                = Parameter.password,
                mmapp_dashboard_url     = prefix + HttpContext.Current.Request.Url.Authority + "/" + appName,
                medios_connect_logo_url = imageUrl
            }, "{{", "}}");

            try
            {
                // string mailFrom = cls_Get_Company_Settings.Invoke(Connection, Transaction, securityTicket).Result.Email;
                string mailFrom      = WebConfigurationManager.AppSettings["mailFrom"];
                var    mailsDistinct = MailToL.Distinct().ToList();
                foreach (var mailTo in mailsDistinct)
                {
                    EmailNotificationSenderUtil.SendEmail(mailFrom, mailTo, subjectMail, email_template);
                }
            }
            catch (Exception ex)
            {
                LogUtils.Logger.LogDocAppInfo(new LogUtils.LogEntry(System.Reflection.MethodInfo.GetCurrentMethod(), ex, null, "Change password (doc app): Email sending failed."), "EmailExceptions");
            }
            return(returnValue);

            #endregion UserCode
        }