public string GetText(MessagingType type, ConcreteKey key) { var template = GetAll().FirstOrDefault(x => x.MessagingType == type && x.Key == key.ToString()); if (template == null) { FileLoger.Info($"Sms Tempalte With Key {key} Been Removed From Database"); return("sms template is removed"); } return(template.Text); }
public void Notify(ConcreteKey concrete, ObserverMessage msg) { var user = new User(); var officeUser = new User(); if (msg.UserId.IsNotNullGuid()) { user = _uow.Set <User>().Find(msg.UserId); } if (msg.OfficeUserId.IsNotNullGuid()) { officeUser = _uow.Set <User>().Find(msg.OfficeUserId); } var observers = JsonConvert.DeserializeObject <IEnumerable <Concrete> >(File.ReadAllText(GlobalVariable.ObserverConfig)); var officeUsername = false; foreach (var item in observers) { if (item.Key == concrete.ToString()) { if (item.Key == "Order_Status_Changed" || item.Key == "Offline_Payment") { officeUsername = true; } foreach (var obs in item.Observers) { Assembly assembly = Assembly.GetExecutingAssembly(); _observers.Add(assembly.CreateInstance(obs) as IObserver); } msg.Subject = item.Key; foreach (IObserver o in _observers) { if (officeUsername) { o.Observe(_uow, _messageBusiness, msg, officeUser.UserId.IsNotNullGuid() ? officeUser : user); } else { o.Observe(_uow, _messageBusiness, msg, user); } } break; } } _uow.SaveChanges(); }