Example #1
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Id != null)
         {
             hashCode = hashCode * 59 + Id.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (Description != null)
         {
             hashCode = hashCode * 59 + Description.GetHashCode();
         }
         if (Price != null)
         {
             hashCode = hashCode * 59 + Price.GetHashCode();
         }
         if (PricePeriod != null)
         {
             hashCode = hashCode * 59 + PricePeriod.GetHashCode();
         }
         if (PriceCurrency != null)
         {
             hashCode = hashCode * 59 + PriceCurrency.GetHashCode();
         }
         return(hashCode);
     }
 }
Example #2
0
        private List <PricePeriodHeader> GetPricePeriodHeader(PricePeriod pricePeriod, string agreementType)
        {
            var pricePeriodHeaders = new List <PricePeriodHeader>();

            if (pricePeriod == null)
            {
                return(pricePeriodHeaders);
            }

            foreach (var periodInfo in pricePeriod.Prices)
            {
                var startIndex        = periodInfo.IndexOf(';');
                var periodStr         = periodInfo.Substring(startIndex + 1);
                var pricePeriodHeader = new PricePeriodHeader
                {
                    Period  = periodStr,
                    Priskey = GetPriskey(periodInfo, agreementType)
                };

                if (periodInfo.StartsWith("S"))
                {
                    pricePeriodHeader.MonthRange = "Senast";
                    pricePeriodHeader.DateRange  = $"{periodStr.Substring(11, 6)}";
                }
                else //if (periodInfo.StartsWith("T"))
                {
                    var spaceForRange = agreementType == AgreementType.PrissakringDepaavtal ? " " : string.Empty;
                    pricePeriodHeader.MonthRange = $"{GetMonth(periodStr.Substring(4, 2))}{spaceForRange}-{spaceForRange}{GetMonth(periodStr.Substring(13, 2))}";
                    pricePeriodHeader.DateRange  = $"{periodStr.Substring(2, 6)}- {periodStr.Substring(11, 6)}";
                }
                pricePeriodHeaders.Add(pricePeriodHeader);
            }

            return(pricePeriodHeaders);
        }
Example #3
0
        /// <summary>
        /// Returns true if BusinessModel instances are equal
        /// </summary>
        /// <param name="other">Instance of BusinessModel to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(BusinessModel other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     Description == other.Description ||
                     Description != null &&
                     Description.Equals(other.Description)
                 ) &&
                 (
                     Price == other.Price ||
                     Price != null &&
                     Price.Equals(other.Price)
                 ) &&
                 (
                     PricePeriod == other.PricePeriod ||
                     PricePeriod != null &&
                     PricePeriod.Equals(other.PricePeriod)
                 ) &&
                 (
                     PriceCurrency == other.PriceCurrency ||
                     PriceCurrency != null &&
                     PriceCurrency.Equals(other.PriceCurrency)
                 ));
        }