List <ParcelDiscounts> GetDiscountForParcelCode(ParcelCode code, int discountSet) { var discounts = new List <ParcelDiscounts>(); var groupedParcels = Parcels .Where(parcel => parcel.Type.Code == code) .OrderBy(parcel => parcel.TotalPrice) .ToList(); var numberOfRequiredDiscounts = (int)Math.Floor((double)groupedParcels.Count / discountSet); var offset = 0; while (discounts.Count < numberOfRequiredDiscounts) { var discount = new ParcelDiscounts { DiscountedParcel = groupedParcels[offset], Parcels = groupedParcels.GetRange(offset, discountSet), Value = groupedParcels[offset].TotalPrice }; discounts.Add(discount); offset = offset + discountSet; } return(discounts); }
public ParcelType(ParcelDimensions dimensions, double weightKg) { if (weightKg >= 50) { Name = "Heavy"; Code = ParcelCode.Heavy; return; } var largestDimensionCm = dimensions.GetLargestDimension(); if (largestDimensionCm < 10) { Name = "Small"; Code = ParcelCode.Small; } else if (largestDimensionCm < 50) { Name = "Medium"; Code = ParcelCode.Medium; } else if (largestDimensionCm < 100) { Name = "Large"; Code = ParcelCode.Large; } else { Name = "XL"; Code = ParcelCode.XL; } }
public bool CanBeOpenedBy <T>(ParcelCode code) where T : Person { if (CurrentParcel == null) { return(true); } else { return(CurrentParcel.CanBeOpenedBy <T>(code)); } }
public Commission FindCommissionByParcelCode(ParcelCode parcelCode) { return(_entities.Where(x => x.Parcel.CommissionerCode == parcelCode || x.Parcel.DeliverersCodes.Contains(parcelCode) || x.Parcel.RecipientCode == parcelCode) .FirstOrDefault()); }
public bool ContainsParcelWithCode(ParcelCode code) { return(CurrentParcel.IsAccessibleByCode(code)); }
public OpenLockerCommand(ParcelCode code, Person executor) { Id = Guid.NewGuid(); ParcelCode = code; Executor = executor; }
public Locker GetLockerByParcelCode(ParcelCode code) { return(Lockers.Where(x => x.ContainsParcelWithCode(code)).FirstOrDefault()); }
public List <string> Parcelcodes() { return(ParcelCode.Split(',').ToList()); }