public static Boolean CreatePeerConsumerAverages(PeerNConsumerAverage Peer) { Boolean flag = false; if (!(IsExistingPeerNConsumerAverage(Peer))) { using (TransactionScope scope = new TransactionScope()) { using (var context = new SycousCon()) { try { context.PeerNConsumerAverages.AddObject(Peer); context.SaveChanges(); scope.Complete(); context.AcceptAllChanges(); flag = true; } catch (Exception ex) { context.Dispose(); throw; } }// }// using }//if return flag; }
public static PeerNConsumerAverage EditPeerConsumerAverages(Int64 PeerID) { PeerNConsumerAverage peer = new PeerNConsumerAverage(); using (var context = new SycousCon()) { try { peer = context.PeerNConsumerAverages.SingleOrDefault(s => s.ID == PeerID); } catch (Exception ex) { context.Dispose(); throw; } } return peer; }
public static bool IsExistingPeerNConsumerAverage(PeerNConsumerAverage Peer) { using (var context = new SycousCon()) { try { PeerNConsumerAverage objpeer = context.PeerNConsumerAverages.SingleOrDefault(p => p.ClientID == Peer.ClientID && p.SiteID == Peer.SiteID); if (objpeer != null) { return true; } else { return false; } } catch (Exception ex) { context.Dispose(); throw; } } }
public bool CreateRecord(Object _PeerConsumerobj) { Boolean flag = false; PeerConsumerClass Peer = (PeerConsumerClass)_PeerConsumerobj; try { DAL.PeerNConsumerAverage _Peer = new PeerNConsumerAverage(); if (Peer.ClientID != null) { _Peer.ClientID = Convert.ToInt64(Peer.ClientID); } if (Peer.SiteID != null) { _Peer.SiteID = Convert.ToInt64(Peer.SiteID); } if (Peer.Percentage != null) { _Peer.Percentage = Convert.ToDecimal(Peer.Percentage); } if (Peer.FromDate != null) { _Peer.FormDate = BAL.Common.DateGB(Peer.FromDate); } else { _Peer.FormDate = null; } if (Peer.ToDate != null) { _Peer.ToDate = BAL.Common.DateGB(Peer.ToDate); } else { _Peer.ToDate = null; } if (Peer.IsPreviousConsumer == true) { _Peer.IsPreviousConsumer = false; } else { _Peer.IsPreviousConsumer = true; } if (Peer.PreConsPercentage != null) { _Peer.PreConsPercentage = Convert.ToDecimal(Peer.PreConsPercentage); } if (Peer.PreConsFormDate != null) { _Peer.PreConsFormDate = BAL.Common.DateGB(Peer.PreConsFormDate); } else { _Peer.PreConsFormDate = null; } if (Peer.PreConsToDate != null) { _Peer.PreConsToDate = BAL.Common.DateGB(Peer.PreConsToDate); } else { _Peer.PreConsToDate = null; } _Peer.CreateBy = Peer.CreateBy; _Peer.CreateDate = DateTime.Now; if ((_Peer.ClientID != null) && (_Peer.SiteID != null)) { flag = DAL.DALPeer.CreatePeerConsumerAverages(_Peer); } } catch (Exception ex) { throw; } return flag; }
public static Boolean UpdatePeerConsumerAverages(PeerNConsumerAverage Peer) { using (TransactionScope scope = new TransactionScope()) { Boolean bol = false; using (var context = new SycousCon()) { try { var Update = context.PeerNConsumerAverages.Where(c => c.ID == Peer.ID); foreach (PeerNConsumerAverage p in Update) { if (Peer.ClientID != null) { p.ClientID = Peer.ClientID; } if (Peer.SiteID != null) { p.SiteID = Peer.SiteID; } if (Peer.Percentage!= null) { p.Percentage = Peer.Percentage; } else { p.Percentage = null; } if (Peer.FormDate != null) { p.FormDate = Peer.FormDate; } else { p.FormDate = null; } if (Peer.ToDate != null) { p.ToDate = Peer.ToDate; } else { p.ToDate = null; } p.IsPreviousConsumer = Peer.IsPreviousConsumer; if (Peer.PreConsPercentage != null) { p.PreConsPercentage = Peer.PreConsPercentage; } else { p.PreConsPercentage = null; } if (Peer.PreConsFormDate != null) { p.PreConsFormDate = Peer.PreConsFormDate; } else { p.PreConsFormDate = null; } if (Peer.PreConsToDate != null) { p.PreConsToDate = Peer.PreConsToDate; } else { p.PreConsToDate = null; } p.ModifyBy = Peer.ModifyBy; p.ModifyDate = DateTime.Now; }// context.SaveChanges(); context.AcceptAllChanges(); scope.Complete(); context.Dispose(); bol = true; } catch (Exception ex) { context.Dispose(); throw; } }// using return bol; } //trans }
/// <summary> /// Create a new PeerNConsumerAverage object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="isPreviousConsumer">Initial value of the IsPreviousConsumer property.</param> /// <param name="isDeleted">Initial value of the IsDeleted property.</param> public static PeerNConsumerAverage CreatePeerNConsumerAverage(global::System.Int64 id, global::System.Boolean isPreviousConsumer, global::System.Int32 isDeleted) { PeerNConsumerAverage peerNConsumerAverage = new PeerNConsumerAverage(); peerNConsumerAverage.ID = id; peerNConsumerAverage.IsPreviousConsumer = isPreviousConsumer; peerNConsumerAverage.IsDeleted = isDeleted; return peerNConsumerAverage; }
/// <summary> /// Deprecated Method for adding a new object to the PeerNConsumerAverages EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToPeerNConsumerAverages(PeerNConsumerAverage peerNConsumerAverage) { base.AddObject("PeerNConsumerAverages", peerNConsumerAverage); }