public IHttpActionResult sendEmailForgotPassword(string email, long hosID)
        {
            try
            {
                MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                string code         = DateTime.Now.ToString("yyyyMMddhhmmsstt");
                string code_encrypt = LVCrypto.GetMd5Hash(md5, code);
                // Luu thong tin lai:
                UserAccount account = this.Repository.GetQuery <UserAccount>().FirstOrDefault(m => m.AccountNameEmailAddress == email);
                if (account != null)
                {
                    account.isBlocked         = true;
                    account.RequestDateForPWD = DateTime.Now;
                    account.ForgotPwdCode     = code_encrypt;
                    this.Repository.Update <UserAccount>(account);
                    this.Repository.UnitOfWork.SaveChanges();
                }


                RegisterMailController mailCtrl = new RegisterMailController();
                string report = GetMailTemplate();
                //Dictionary<long, string> appStatusDic = GetAppStatusDic();
                string Body    = "";
                var    hosInfo = (from h in this.Repository.GetQuery <HCProvider>()
                                  where h.HosID == hosID
                                  select new
                {
                    hospital = h.HCPrvProviderName,
                    slogan = h.Slogan,
                    addressHos = h.HCPractAddressText,
                    logo = h.HosLogoImgPath
                }).FirstOrDefault();

                Body = report;
                var url = HttpContext.Current.Request.UrlReferrer.AbsoluteUri.Replace(HttpContext.Current.Request.UrlReferrer.AbsolutePath, "");

                Body = Body.Replace("@hospital", hosInfo.hospital);
                Body = Body.Replace("@addressHos", hosInfo.addressHos);


                //slogan
                Body = Body.Replace("@slogan", hosInfo.slogan);

                LV.Common.LVCrypto cry = new LVCrypto();
                Body = Body.Replace("@ForgotPassword", url + "/eportal/NewPassword/" + code_encrypt);

                List <LinkedResource> res = new List <LinkedResource>();

                LinkedResource pic1 = new LinkedResource(HttpContext.Current.Server.MapPath("~") + hosInfo.logo);
                pic1.ContentId = "logo";
                res.Add(pic1);

                mailCtrl._SendMail(email, "Cấp lại mật khẩu", Body, null, res);
                return(Ok(true));
            }
            catch (Exception exp)
            {
                return(Ok(false));
            }
        }
Example #2
0
 public IHttpActionResult getHospitalInfo(string hosId, string perID)
 {
     try
     {
         var hospitalInfo = (from hospital in this.Repository.GetQuery <HCProvider>()
                             where hospital.HosID == 11163 && hospital.isBulitIn == true
                             select hospital).FirstOrDefault();
         if (hospitalInfo == null)
         {
             return(null);
         }
         LV.Service.Eportal.RegisterMailController getWork = new RegisterMailController();
         List <WorkDayTime> dateTimeToWork = new List <WorkDayTime>();
         dateTimeToWork = getWork.GetScheduleOfHos(long.Parse(hosId));
         return(Ok(new { hospitalInfo = hospitalInfo, dateTimeToWork = dateTimeToWork }));
     }
     catch (Exception exp)
     {
         return(BadRequest(exp.ToString()));
     }
 }
Example #3
0
        public bool RegisterMailD(string to, string subject, long AccountID, string ActivationCode)
        {
            try
            {
                RegisterMailController mailCtrl = new RegisterMailController();
                int    hosID  = 11163;
                string report = GetMailTemplate();
                //Dictionary<long, string> appStatusDic = GetAppStatusDic();
                string Body    = "";
                var    hosInfo = (from h in this.Repository.GetQuery <HCProvider>()
                                  where h.HosID == hosID
                                  select
                                  new { hospital = h.HCPrvProviderName, slogan = h.Slogan, addressHos = h.HCPractAddressText, logo = h.HosLogoImgPath }).FirstOrDefault();

                Body = report;
                var url = HttpContext.Current.Request.UrlReferrer.AbsoluteUri.Replace(HttpContext.Current.Request.UrlReferrer.AbsolutePath, "");

                Body = Body.Replace("@hospital", hosInfo.hospital);
                Body = Body.Replace("@addressHos", hosInfo.addressHos);


                //slogan
                Body = Body.Replace("@slogan", hosInfo.slogan);

                LV.Common.LVCrypto cry = new LVCrypto();
                Body = Body.Replace("@linkActive", url + "/eportal/ActiveRegister/" + ActivationCode);
                List <LinkedResource> res = new List <LinkedResource>();

                LinkedResource pic1 = new LinkedResource(HttpContext.Current.Server.MapPath("~") + hosInfo.logo);
                pic1.ContentId = "logo";
                res.Add(pic1);

                mailCtrl._SendMail(to, subject, Body, null, res);
                return(true);
            }
            catch (Exception exp)
            {
                return(false);
            }
        }