protected override NgResult _create(EmailSenderDataProviderVM[] models) { using (var l = new MessagesModuleLogic()) { foreach (var model in models) { var item = l.Create <tblEmailSenderDataProvider>(); EmailSenderDataProviderVM.ReflectToTblEmailSenderDataProvider.Run(model, item); l.Add(item); } } return(NgResult.Succes(DEBS.Translate("MessageMdl.{0} email sms providers was added", models.Count())));; }
protected override NgResult _create(MessageScheduleVM[] models) { using (var l = new MessagesModuleLogic()) { foreach (var model in models) { var item = l.Create <tblMessageSchedule>(); MessageScheduleVM.ReflectToTblMessageSchedule.Run(model, item); l.Add(item); } } return(NgResult.Succes(DEBS.Translate("MessageMdl.{0} new schedules was added", models.Count()))); }
protected override NgResult _create(RFilterVM[] models) { //TODO OPTIMIZE using (var l = new MessagesModuleLogic()) { foreach (var model in models) { var filt = l.Create <tblRecepientFilter>(); filt.Name = model.Name; filt.tblRecepientFilterTableNameId = model.BaseTableId; l.Add(filt); model.Id = filt.Id; CreateAndUpdateRFilterParts(model, l); } } return(NgResult.Succes()); }
protected void ManagerRFilterPart <TEnitity, TNgViewModel> (MessagesModuleLogic l, IEnumerable <TNgViewModel> items, Action <TEnitity, TNgViewModel> updater) where TEnitity : class, IMessagesModuleEntity where TNgViewModel : class, INgViewModel { if (items == null) { return; } //TODO OPTIMIZE work with DB foreach (var item in items) { TEnitity ent = null; if (item.ng_ToDelete) { l.Delete <TEnitity>(item.Id); } else if (item.ng_JustCreated) { ent = l.Create <TEnitity>(); } else { ent = l.Get <TEnitity>(item.Id); } if (ent != null) { updater(ent, item); if (item.ng_JustCreated) { l.Add(ent); } else { l.SaveChanges(ent); } } } }