public void AddChannelAlert(tbl_ChannelAlert tblchannelalerts) { try { IGenericDataRepository <tbl_ChannelAlert> repository = new GenericDataRepository <tbl_ChannelAlert>(); repository.Add(tblchannelalerts); } catch (Exception) { throw; } }
public void DeleteChannelAttrMapId(int id) { try { tbl_ChannelAlert tblchannelAlert = new tbl_ChannelAlert(); IGenericDataRepository <tbl_ChannelAlert> repository = new GenericDataRepository <tbl_ChannelAlert>(); tbl_ChannelAlertAttrMapping objtblChannelAlertMapping = new tbl_ChannelAlertAttrMapping(); IGenericDataRepository <tbl_ChannelAlertAttrMapping> repository1 = new GenericDataRepository <tbl_ChannelAlertAttrMapping>(); IList <tbl_ChannelAlert> lstChannelalert = repository.GetList(q => q.ChannelAlertID.Equals(id)); if (lstChannelalert != null) { foreach (var item in lstChannelalert) { tblchannelAlert.ChannelAlertID = item.ChannelAlertID; tblchannelAlert.ChannelAlertAttrMapID = item.ChannelAlertAttrMapID; tblchannelAlert.daId = item.daId; tblchannelAlert.TransactionSeq = item.TransactionSeq; tblchannelAlert.EntityState = EntityState.Deleted; IList <tbl_ChannelAlertAttrMapping> lstChannelAlertMappingid = repository1.GetList(q => q.ChannelAlertAttrMapID.Equals(item.ChannelAlertAttrMapID)); if (lstChannelAlertMappingid != null) { foreach (var item1 in lstChannelAlertMappingid) { objtblChannelAlertMapping.AttrID1 = item1.AttrID1; objtblChannelAlertMapping.AttrID2 = item1.AttrID2; objtblChannelAlertMapping.AttrID3 = item1.AttrID3; objtblChannelAlertMapping.AttrID4 = item1.AttrID4; objtblChannelAlertMapping.AttrID5 = item1.AttrID5; objtblChannelAlertMapping.AttrID6 = item1.AttrID6; objtblChannelAlertMapping.AttrID7 = item1.AttrID7; objtblChannelAlertMapping.AttrID8 = item1.AttrID8; objtblChannelAlertMapping.AttrID9 = item1.AttrID9; objtblChannelAlertMapping.AttrID10 = item1.AttrID10; objtblChannelAlertMapping.AttrValueID1 = item1.AttrValueID1; objtblChannelAlertMapping.AttrValueID2 = item1.AttrValueID2; objtblChannelAlertMapping.AttrValueID3 = item1.AttrValueID3; objtblChannelAlertMapping.AttrValueID4 = item1.AttrValueID4; objtblChannelAlertMapping.AttrValueID5 = item1.AttrValueID5; objtblChannelAlertMapping.AttrValueID6 = item1.AttrValueID6; objtblChannelAlertMapping.AttrValueID7 = item1.AttrValueID7; objtblChannelAlertMapping.AttrValueID8 = item1.AttrValueID8; objtblChannelAlertMapping.AttrValueID9 = item1.AttrValueID9; objtblChannelAlertMapping.AttrValueID10 = item1.AttrValueID10; objtblChannelAlertMapping.ChannelAlertAttrMapID = item1.ChannelAlertAttrMapID; objtblChannelAlertMapping.DestnID = item1.DestnID; objtblChannelAlertMapping.DistributionTypeID = item1.DistributionTypeID; objtblChannelAlertMapping.FreqID = item1.FreqID; objtblChannelAlertMapping.IsManual = item1.IsManual; objtblChannelAlertMapping.MessageDesc = item1.MessageDesc; objtblChannelAlertMapping.ModeTypeID = item1.ModeTypeID; objtblChannelAlertMapping.SourceID = item1.SourceID; objtblChannelAlertMapping.ReqReference = item1.ReqReference; objtblChannelAlertMapping.EntityState = EntityState.Deleted; repository1.Remove(objtblChannelAlertMapping); } } repository.Remove(tblchannelAlert); } } } catch (Exception) { throw; } }
public int SaveChannelAlertsData(IList <ChannelsAndAlertsViewModel> channelalerts, int daId) { try { int result = 0; ChannelsAndAlertsManager channelalertsManager = new ChannelsAndAlertsManager(); List <tbl_ChannelAlert> lstChannelAlerts = new List <tbl_ChannelAlert>(); List <tbl_ChannelAlertAttrMapping> lstChannelAlertsAttrMapping = new List <tbl_ChannelAlertAttrMapping>(); var AllChannelAlerts = channelalerts.GroupBy(b => b.ChannelAlertAttrMapID); foreach (var chn in AllChannelAlerts) { tbl_ChannelAlertAttrMapping tblchannelalertsattrmapping = new tbl_ChannelAlertAttrMapping(); if ((chn.Key.ToString().Length > 5) && (chn.Key.ToString().Substring(chn.Key.ToString().Length - 2, 2) == "00")) { #region Add New Channel and Alert int cnt = 1; var cur = channelalerts.Where(e => e.ChannelAlertAttrMapID == chn.Key && e.IsLinked.Equals(true)); //Querying checked highlevel transactions and BuzruleAttrMapID marked new foreach (var HighTrans in cur) { if (cnt == 1) { AttributesMapping(ref tblchannelalertsattrmapping, HighTrans); tblchannelalertsattrmapping.EntityState = DA.DomainModel.EntityState.Added; } cnt++; tbl_ChannelAlert channelalert = new tbl_ChannelAlert(); channelalert.daId = daId; channelalert.TransactionSeq = HighTrans.TransactionSeq; channelalert.tbl_ChannelAlertAttrMapping = tblchannelalertsattrmapping; channelalert.EntityState = DA.DomainModel.EntityState.Added; tblchannelalertsattrmapping.tbl_ChannelAlert.Add(channelalert); } lstChannelAlertsAttrMapping.Add(tblchannelalertsattrmapping); #endregion } else { #region AddModifyDelete Business Rules int cnt1 = 1; var cur = channelalerts.Where(e => e.ChannelAlertAttrMapID == chn.Key && (e.IsLinked.Equals(true) || e.ChannelAlertID != 0)); //Querying checked highlevel transactions and BuzruleID existed foreach (var HighTrans in cur) { if (cnt1 == 1) { tblchannelalertsattrmapping.ChannelAlertAttrMapID = HighTrans.ChannelAlertAttrMapID; AttributesMapping(ref tblchannelalertsattrmapping, HighTrans); tblchannelalertsattrmapping.EntityState = DA.DomainModel.EntityState.Modified; } cnt1++; tbl_ChannelAlert channelalert = new tbl_ChannelAlert(); channelalert.daId = daId; channelalert.TransactionSeq = HighTrans.TransactionSeq; channelalert.ChannelAlertAttrMapID = HighTrans.ChannelAlertAttrMapID; channelalert.ChannelAlertID = HighTrans.ChannelAlertID; if ((HighTrans.ChannelAlertID != 0) && (HighTrans.IsLinked == true)) { channelalert.EntityState = DA.DomainModel.EntityState.Unchanged; } else if ((HighTrans.ChannelAlertID == 0) && (HighTrans.IsLinked == true)) { channelalert.EntityState = DA.DomainModel.EntityState.Added; } else if ((HighTrans.ChannelAlertID != 0) && (HighTrans.IsLinked == false)) { channelalert.EntityState = DA.DomainModel.EntityState.Deleted; } tblchannelalertsattrmapping.tbl_ChannelAlert.Add(channelalert); } lstChannelAlertsAttrMapping.Add(tblchannelalertsattrmapping); #endregion } } result = channelalertsManager.SaveChannelAlertDataMapping(lstChannelAlertsAttrMapping); return(result); } catch (Exception) { throw; } }