/// <summary>
        /// Metoda zwracająca obiekt typu BIPFormViewModel zawierający
        /// elementy wyświetlane na stronie formularza BIP
        /// </summary>
        /// <param name="currentUmbracoPageId">id strony umbraco na której się znajdujemy</param>
        /// <returns></returns>
        public BIPFormViewModel GetBipFormView(int currentUmbracoPageId)
        {
            var _model = new BIPFormViewModel();

            _model.CurrentUmbracoPageId = currentUmbracoPageId;
            _model.CurrentPageCulture   = Thread.CurrentThread.CurrentCulture;
            return(_model);
        }
 public ActionResult SubmitBipFom(BIPFormViewModel model)
 {
     SetCulture(model.CurrentPageCulture);
     if (ModelState.IsValid)
     {
         var _result = _emailService.SendBIPEmail(model);
         model = _result;
     }
     return(PartialView("BIPFormPartial", model));
 }
Example #3
0
        /// <summary>
        /// Metoda służąca do wysyłki emaila z formularza o udostępnienie
        /// informacji publicznej
        /// </summary>
        /// <param name="model">Model BIPFormViewModel</param>
        /// <returns>true/false</returns>
        public BIPFormViewModel SendBIPEmail(BIPFormViewModel model)
        {
            var bipFormNode = _umbracoHelper.TypedContent(model.CurrentUmbracoPageId);
            var bipForm     = new BIpform(bipFormNode);

            model.SharingInformation = _umbracoHelper.GetDictionaryValue(
                string.Format("BIP.Placeholder.SharingInformation.{0}", model.SharingInformationType));

            var email = new Email <BIPFormViewModel>
            {
                Model         = model,
                Template      = "/Views/Mails/BIP.cshtml",
                Subject       = "Wniosek o udostępnienie informacji publicznej",
                FromConfigKey = "smtp_email_from_bip",
                To            = bipForm.EmailAdress.ToString(),
                DW            = bipForm.EmailAdressUdw.ToString()
            };

            try
            {
                SendEmail(email);
                Log.Info(string.Format("Email wysłany poprawnie - model: {0}", JsonConvert.SerializeObject(model)));

                var _model = new BIPFormViewModel();
                _model.SendResponse = new BipSendEmailResponse()
                {
                    Display = true,
                    IsError = false,
                    Message = _umbracoHelper.GetDictionaryValue("BIP.SendEmail.Success")
                };

                _model.CurrentPageCulture   = model.CurrentPageCulture;
                _model.CurrentUmbracoPageId = model.CurrentUmbracoPageId;
                model = _model;
            }
            catch (Exception exception)
            {
                Log.Error(string.Format("{0} -|- model: {1}", exception.Message, JsonConvert.SerializeObject(model)),
                          exception);
                model.SendResponse = new BipSendEmailResponse()
                {
                    Display = true,
                    IsError = true,
                    Message = _umbracoHelper.GetDictionaryValue("BIP.SendEmail.Error")
                };
            }

            return(model);
        }