public static string AnniversaryEmailText() { string AnniversaryEmailTextKey = SettingsKeys.AnniversaryEmailTextKey(); using (RemindersEntities db = new RemindersEntities()) { var setting = db.Settings.Where(x => x.Key == AnniversaryEmailTextKey).FirstOrDefault(); return(setting.Description); } }
//---------------------------------save list data after edit--------------------------------------// public static void Save(SettingsViewModel settingviewmodel) { try { RemindersEntities Entities = new RemindersEntities(); string BirthDayEmailTextKey = SettingsKeys.BirthDayEmailTextKey(); string AnniversaryEmailTextKey = SettingsKeys.AnniversaryEmailTextKey(); string BirthdayReminderKey = SettingsKeys.BirthdayReminderKey(); string AnniversaryReminderKey = SettingsKeys.AnniversaryReminderKey(); string EventReminderKey = SettingsKeys.EventReminderKey(); string SendBirthdayKey = SettingsKeys.SendBirthdayKey(); string SendAnniversaryKey = SettingsKeys.SendAnniversaryKey(); string SendEventKey = SettingsKeys.SendEventKey(); string UpComingReminderKey = SettingsKeys.UpComingReminderKey(); string EmailAdminKey = SettingsKeys.EmailAdminKey(); string EmailSenderKey = SettingsKeys.EmailSenderKey(); string PasswordSenderKey = SettingsKeys.PasswordSenderKey(); string smtpaddressKey = SettingsKeys.smtpaddressKey(); string portnumberKey = SettingsKeys.portnumberKey(); var set0 = Entities.Settings.Where(x => x.Key == BirthDayEmailTextKey).FirstOrDefault(); set0.Values = settingviewmodel.settingsView.BirthDayEmailText; set0.Description = settingviewmodel.settingsView.BirthDayEmailText; set0.CreatedOn = DateTime.Now; var set1 = Entities.Settings.Where(x => x.Key == AnniversaryEmailTextKey).FirstOrDefault(); set1.Values = settingviewmodel.settingsView.AnniversaryEmailText; set1.Description = settingviewmodel.settingsView.AnniversaryEmailText; set1.CreatedOn = DateTime.Now; var set2 = Entities.Settings.Where(x => x.Key == BirthdayReminderKey).FirstOrDefault(); set2.Values = settingviewmodel.BirthdayReminderID.ToString(); var Lookup2 = Entities.Lookups.Find(settingviewmodel.BirthdayReminderID); set2.Description = Lookup2.Description.ToString(); set2.CreatedOn = DateTime.Now; var set3 = Entities.Settings.Where(x => x.Key == AnniversaryReminderKey).FirstOrDefault(); set3.Values = settingviewmodel.AnniversaryReminderID.ToString(); var Lookup3 = Entities.Lookups.Find(settingviewmodel.AnniversaryReminderID); set3.Description = Lookup3.Description.ToString(); set3.CreatedOn = DateTime.Now; var set4 = Entities.Settings.Where(x => x.Key == EventReminderKey).FirstOrDefault(); set4.Values = settingviewmodel.EventReminderID.ToString(); var Lookup4 = Entities.Lookups.Find(settingviewmodel.EventReminderID); set4.Description = Lookup4.Description.ToString(); set4.CreatedOn = DateTime.Now; var set5 = Entities.Settings.Where(x => x.Key == SendBirthdayKey).FirstOrDefault(); set5.Values = settingviewmodel.SendBirthdayID.ToString(); var Lookup5 = Entities.Lookups.Find(settingviewmodel.SendBirthdayID); set5.Description = Lookup5.Description.ToString(); set5.CreatedOn = DateTime.Now; var set6 = Entities.Settings.Where(x => x.Key == SendAnniversaryKey).FirstOrDefault(); set6.Values = settingviewmodel.SendAnniversaryID.ToString(); var Lookup6 = Entities.Lookups.Find(settingviewmodel.SendAnniversaryID); set6.Description = Lookup6.Description.ToString(); set6.CreatedOn = DateTime.Now; var set7 = Entities.Settings.Where(x => x.Key == SendEventKey).FirstOrDefault(); set7.Values = settingviewmodel.SendEventID.ToString(); var Lookup7 = Entities.Lookups.Find(settingviewmodel.SendEventID); set7.Description = Lookup7.Description.ToString(); set7.CreatedOn = DateTime.Now; var set8 = Entities.Settings.Where(x => x.Key == UpComingReminderKey).FirstOrDefault(); set8.Values = settingviewmodel.UpComingReminderID.ToString(); var Lookup8 = Entities.Lookups.Find(settingviewmodel.UpComingReminderID); set8.Description = Lookup8.Description.ToString(); set8.CreatedOn = DateTime.Now; var set15 = Entities.Settings.Where(x => x.Key == EmailAdminKey).FirstOrDefault(); set15.Values = settingviewmodel.settingsView.EmailAdmin.ToString(); set15.Description = settingviewmodel.settingsView.EmailAdmin.ToString(); set15.CreatedOn = DateTime.Now; Entities.SaveChanges(); } catch (Exception ex) { throw ex; } }