Esempio n. 1
0
        public async Task <string> PrepareEmailContent(EmailConfigurationViewModel emailconfigviewmodel)
        {
            var emailconfig = await _repository.Value.Query().Where(_ => _.Language.Language1.ToLower() == emailconfigviewmodel.Language.ToLower() && _.EmailAction.Name.ToLower() == emailconfigviewmodel.ActionName.ToLower()).FirstOrDefaultAsync();

            var filecontent  = File.ReadAllText(HostingEnvironment.MapPath(emailconfig?.FileUrl));
            var emailcontent = EmailTemplateHelper.CustomBindingPropertiesIntoString(filecontent, emailconfigviewmodel, typeof(EmailConfigurationViewModel));

            return(emailcontent);
        }
Esempio n. 2
0
        public ActionResult UpdateEmailConfigurations(EmailConfigurationViewModel email)
        {
            try
            {
                var emailDetailsToUpdate = db.EmailSettings.Find(email.Id);
                var emailList            = db.EmailSettings.ToList();

                var emailInfo = new EmailSettings();
                if (email == null || !ModelState.IsValid)
                {
                    return(View("EmailAlert/EmailAlertSetting", emailList));
                }

                if (emailDetailsToUpdate == null)
                {
                    return(View("EmailAlert/EmailAlertSetting", emailList));
                }

                emailDetailsToUpdate.FromEmail         = email.FromEmail;
                emailDetailsToUpdate.FromEmailPassword = email.FromEmailPassword;
                emailDetailsToUpdate.PortNumber        = email.PortNumber;
                emailDetailsToUpdate.SmtpAddress       = email.SmtpAddress;
                emailDetailsToUpdate.ToEmail           = email.ToEmail;
                emailDetailsToUpdate.WarningPeriod     = email.WarningPeriod;
                emailDetailsToUpdate.UserName          = WebSecurity.CurrentUserName;
                emailDetailsToUpdate.ModifiedDate      = DateTime.Now;

                if (TryUpdateModel(emailDetailsToUpdate, "FromEmail,FromEmailPassword,ToEmail,WarningPeriod,SmtpAddress,PortNumber"))
                {
                    db.Entry(emailDetailsToUpdate).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    emailList = db.EmailSettings.ToList();
                }

                return(View("EmailAlert/EmailAlertSetting", emailList));
            }
            catch (Exception ex)
            {
                logger.Log(LogLevel.Error, "Exception occurred in Settings -> UpdateEmailConfigurations: " + ex.Message);
                throw;
            }
        }
Esempio n. 3
0
 public ActionResult ViewEmailConfigurations(int id)
 {
     try
     {
         var emailViewModel = new EmailConfigurationViewModel();
         var config         = db.EmailSettings.Find(id);
         emailViewModel.FromEmail         = config.FromEmail;
         emailViewModel.FromEmailPassword = config.FromEmail;
         emailViewModel.PortNumber        = config.PortNumber;
         emailViewModel.SmtpAddress       = config.SmtpAddress;
         emailViewModel.ToEmail           = config.ToEmail;
         emailViewModel.WarningPeriod     = config.WarningPeriod;
         emailViewModel.Id = config.Id;
         return(View("EmailAlert/_EditEmailAlertSettings", emailViewModel));
     }
     catch (Exception ex)
     {
         logger.Log(LogLevel.Error, "Exception occurred in Settings -> ViewEmailConfigurations: " + ex.Message);
         throw;
     }
 }
        public IActionResult Create([FromBody] EmailConfigurationViewModel emvm)
        {
            CurrentUser cUser = new CurrentUser(HttpContext, _configuration);

            emvm.CreatedBy = cUser.UserId;
            emvm.Active    = "Y";
            string insertQuery = @"INSERT INTO [dbo].[EamilConfig]([GroupName]
                                      ,[EmailList]
                                      ,[MobileNoList]
                                      ,[AlarmInterval]
                                        ,[MinutesCount]
                                        ,[AlarmStatus],
                                        ,[Active]
                                        ,[CreatedBy]) 
                                        VALUES 
                                        (@GroupName, @EmailList, @MobileNoList, @AlarmInterval, @MinutesCount, @AlarmStatus, @Active, @CreatedBy)";

            using (var conn = con.MasterCon())
            {
                return(Ok(conn.Execute(insertQuery, emvm)));
            }
        }
Esempio n. 5
0
        public async Task <IEnumerable <dynamic> > SaveOrUpdate([FromBody] EmailConfigurationViewModel emvm)
        {
            string sql = "dbo.EAppSaveCountry";

            using (var conn = util.MasterCon())
            {
                try
                {
                    return(await(conn.QueryAsync <dynamic>(sql, new
                    {
                        emvm.GroupName,
                        emvm.EmailList,
                        emvm.MobileNoList,
                        emvm.Active,
                        emvm.AlarmInterval,
                        emvm.MinutesCount,
                        emvm.CreatedBy,
                        emvm.CreatedOn
                    }, commandType: CommandType.StoredProcedure)));
                }
                catch (SqlException sqlException)
                {
                    if (sqlException.Number == 2601 || sqlException.Number == 2627)
                    {
                        throw new CustomException("Duplicate", "Country Code already Exists.", "Error", true, sqlException);
                    }
                    else
                    {
                        throw new CustomException("Due to some Technical Reason, Unable to Save or Update", "Error", true, sqlException);
                    }
                }
                catch (Exception ex)
                {
                    throw new CustomException("Unable to Save or Update, Please Contact Support!!!", "Error", true, ex);
                }
            }
        }