public ActionResult ContactUs(FormCollection form)
        {
            if (!PublicMethodRepository.GoogleValidIsSuccess)
            {
                throw new Exception("valid error. can't send mail");
            }

            string        renderedHTML = RenderViewToString("Mail", "MsgMail", form);
            var           mailTo       = PublicMethodRepository.GetConfigAppSetting("MailTo").Split(new string[] { @";" }, StringSplitOptions.RemoveEmptyEntries).ToList();
            string        subJect      = "肽研生醫網站線上諮詢";
            StringBuilder mailContent  = new StringBuilder(renderedHTML);
            List <string> mailToList   = mailTo;
            var           mailInfo     = new MailInfo()
            {
                Subject = subJect,
                Body    = mailContent,
                To      = mailToList,
            };
            var isSend = new Mailer(mailInfo).SendMail();

            if (isSend)
            {
                TempData["MailSendMsg"] = "信件已成功寄出。";
            }
            else
            {
                TempData["MailSendMsg"] = "信件寄送失敗。";
            }
            return(View("EmptyView"));
        }
Пример #2
0
        public DownloadFrontResultModel GetList(int page)
        {
            DownloadFrontResultModel result = new DownloadFrontResultModel();

            try
            {
                var data = this.DB.DLFILES
                           .AsEnumerable()
                           .OrderByDescending(o => o.PUB_DT_STR).ThenByDescending(a => a.SQ)
                           .Where(o => o.DISABLE == false)
                           .Select(o => new DownloadFrontDataModel()
                {
                    ID             = o.ID,
                    Title          = o.TITLE,
                    PublishDateStr = o.PUB_DT_STR
                })
                           .ToList();
                result.Data = data;
                result      = this.ListPagination(ref result, page, Convert.ToInt32(PublicMethodRepository.GetConfigAppSetting("DefaultPageSize")));

                foreach (var item in data)
                {
                    PublicMethodRepository.HtmlDecode(item);
                }


                using (var fileModule = new FileModule())
                {
                    foreach (var item in data)
                    {
                        item.Files = fileModule.GetFiles((int)item.ID, "Download", "F");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Пример #3
0
        public ApplyListViewModel GetList(int page, bool getContent = false)
        {
            ApplyListViewModel model = new ApplyListViewModel();
            var data = DB.OLACT
                       .AsEnumerable()
                       .OrderByDescending(o => o.PUB_DT_STR).ThenByDescending(a => a.SQ)
                       .Select(s => new ApplyListViewDataModel()
            {
                ID = s.ID,
                ActivityDateTimeDescription = s.ACT_DATE_DESC,
                ApplyDateRange = string.Concat(s.APPLY_DATE_BEGIN, "~", s.APPLY_DATE_END),
                Sort           = s.SQ,
                Title          = s.ACTITLE,
                Remark         = s.ACT_CONTENT
            })
                       .ToList();

            using (var actModule = new ActivityModule())
            {
                foreach (var d in data)
                {
                    d.GroupApplyLimit = DB.OLACTGROUP.Where(o => o.MAP_ACT_ID == d.ID).Sum(o => o.TEAM_APPLY_LIMIT);
                    d.Registered      = DB.APPLY.Where(g => g.MAP_ACT_ID == d.ID).Count();
                    d.ActivityStatus  = actModule.ActivityStatusCheckByID((int)d.ID);
                }
            }
            model.ListData = data;
            foreach (var d in data)
            {
                PublicMethodRepository.HtmlDecode(d);
            }

            if (!getContent)
            {
                model = this.ListPagination(ref model, page, Convert.ToInt32(PublicMethodRepository.GetConfigAppSetting("DefaultPageSize")));
            }
            return(model);
        }
        public JsonResult ValidRecaptcha(FormCollection form)
        {
            PublicMethodRepository.GoogleValidIsSuccess = false;
            var    content = new JsonResult();
            bool   isValid = true;
            string msg     = string.Empty;

            string secret = PublicMethodRepository.GetConfigAppSetting("reCAPTCHASecret");

            if (secret == null)
            {
                isValid = false;
                msg     = "無法取得Google金鑰";
            }
            else
            {
                IRecaptcha <RecaptchaV2Result> recaptcha = new RecaptchaV2(new RecaptchaV2Data()
                {
                    Secret = secret
                });

                var result = recaptcha.Verify();
                if (!result.Success)
                {
                    isValid = false;
                }
            }

            PublicMethodRepository.GoogleValidIsSuccess = isValid;
            content.Data = JsonConvert.SerializeObject(new { success = isValid, msg = msg }, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            content.ContentType         = "application/json";
            content.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(content);
        }