/// /// Copyright (c) 2016 Sensus Metering Systems /// using System; using System.Collections.Generic; using System.Linq; namespace Results.Entities { public class WaterMeterData { public virtual int Id { get; protected set; } public virtual string ProductName { get; set; } public virtual string Producer { get; set; } public virtual string MetrologicalClass { get; set; } public virtual string ApprovalInfo { get; set; } public virtual double Q4_Qmax { get; set; } /// [m3/h] public virtual double Qn { get; set; } /// [m3/h] public virtual double Q3 { get; set; } /// [m3/h] public virtual double Q2_Qt { get; set; } /// [m3/h] public virtual double Q1_Qmin { get; set; } /// [m3/h] public virtual bool Compound { get; set; } #if IPERLST public virtual int WMTypeId { get; set; } public virtual int WMTypeRev { get; set; } #endif public WaterMeterData() { } /// /// Method to compare the content of two entities /// /// Second entity to compare with /// first = two entities are equal (except of Id) public virtual bool Equals(WaterMeterData wmd) { if (!ProductName.Equals(wmd.ProductName)) return false; if (!Producer.Equals(wmd.Producer)) return false; if (!MetrologicalClass.Equals(wmd.MetrologicalClass)) return false; if (!ApprovalInfo.Equals(wmd.ApprovalInfo)) return false; if (Q4_Qmax != wmd.Q4_Qmax) return false; if (Qn != wmd.Qn) return false; if (Q3 != wmd.Q3) return false; if (Q2_Qt != wmd.Q2_Qt) return false; if (Q1_Qmin != wmd.Q1_Qmin) return false; if (Compound != wmd.Compound) return false; #if IPERLST if (WMTypeId != wmd.WMTypeId) return false; if (WMTypeRev != wmd.WMTypeRev) return false; #endif return true; } /// /// Adds an item to the list if it does not occur there /// /// List of items /// Item to add to the list or find there /// Item from the list (existing or added) public static WaterMeterData UpdateList(IList list, WaterMeterData item) { if (item == null) return null; /// Null item is not stored in the list WaterMeterData found = list.FirstOrDefault(x => x.Equals(item)); if (found != null) return found; /// The same item found in the list, The found item returned list.Add(item); /// Item not fund in the list, it is added to the list return item; } } }