public Contract(Subscriber subscriber, TariffType tariffType) { LastTariffUpdateDate = DateTime.Now; Subscriber = subscriber; Number = rnd.Next(1000000, 9999999); Tariff = new Tariff(tariffType); }
public Tariff(TariffType type) { TariffType = type; switch (TariffType) { case Enums.TariffType.Light: { CostOfMonth = 10; LimitCallInMonth = 4; CostOfCallPerMinute = 3; break; } case Enums.TariffType.Standart : { CostOfMonth = 20; LimitCallInMonth = 8; CostOfCallPerMinute = 2; break; } case Enums.TariffType.Pro : { CostOfMonth = 30; LimitCallInMonth = 12; CostOfCallPerMinute = 1; break; } default : { CostOfMonth = 0; LimitCallInMonth = 0; CostOfCallPerMinute = 0; break; } } }
public Contract(Client client, TariffType tariffType, DateTime conclusionDate) { LastTariffUpdateDate = DateTime.Now; Client = client; PhoneNumber = new PhoneNumber(rnd.Next(1000000, 9999999).ToString()); TariffPlan = new TariffPlan(tariffType); ConclusionDate = conclusionDate; }
public bool ChangeTariff(TariffType tariffType) { if(DateTime.Now.AddMonths(-1) >= LastTariffUpdateDate) { LastTariffUpdateDate = DateTime.Now; Tariff = new Tariff(tariffType); Console.WriteLine("Tariff has changed!"); return true; } else { Console.WriteLine("Цait until the end of the month!"); return false; } }
public Contract(Subscriber subscriber, TariffType tariffType) { Subscriber = subscriber; Number = random.Next(1000000, 9999999); Tariff = new Tariff(tariffType); }
private Ralid.Park.Hardware.H_Tariff_CarType ConvertTariffCarType(byte carType, TariffType tariffType) { if (tariffType == TariffType.Holiday || tariffType == TariffType.HolidayAndInnerRoom) //节假日费率 { return((H_Tariff_CarType)(carType + 4)); //4~7为车型节假日费率 } else { return((H_Tariff_CarType)carType);//0~3为车型工作日费率 } }
public ProRatePricingStrategy(TariffType tType) : base(tType) { }
/// <summary> /// Add/Edit Service Rate /// </summary> /// <param name="serviceRtMain"></param> /// <returns></returns> public ServiceRtMainContent SaveServiceRate(ServiceRtMain serviceRtMain) { TariffType tariffType = tariffTypeRepository.Find(long.Parse(serviceRtMain.TariffTypeCode)); serviceRtMain.TariffTypeCode = tariffType.TariffTypeCode; ServiceRtMain serviceRtMainDbVersion = serviceRtMainRepository.Find(serviceRtMain.ServiceRtMainId); #region Add if (serviceRtMainDbVersion == null) { ValidateServiceRt(serviceRtMain, true); serviceRtMain.UserDomainKey = serviceRtMainRepository.UserDomainKey; serviceRtMain.IsActive = true; serviceRtMain.IsDeleted = false; serviceRtMain.IsPrivate = false; serviceRtMain.IsReadOnly = false; serviceRtMain.RecCreatedDt = DateTime.Now; serviceRtMain.RecLastUpdatedDt = DateTime.Now; serviceRtMain.RecCreatedBy = serviceRtMainRepository.LoggedInUserIdentity; serviceRtMain.RecLastUpdatedBy = serviceRtMainRepository.LoggedInUserIdentity; serviceRtMain.RowVersion = 0; //set child (Service Rate in Service Rate Main) properties #region Service Rate in Service Rate Main if (serviceRtMain.ServiceRts != null) { // set properties foreach (ServiceRt item in serviceRtMain.ServiceRts) { item.IsActive = true; item.IsDeleted = false; item.IsPrivate = false; item.IsReadOnly = false; item.RecCreatedDt = DateTime.Now; item.RecLastUpdatedDt = DateTime.Now; item.RecCreatedBy = serviceRtMainRepository.LoggedInUserIdentity; item.RecLastUpdatedBy = serviceRtMainRepository.LoggedInUserIdentity; item.UserDomainKey = serviceRtMainRepository.UserDomainKey; } } #endregion serviceRtMainRepository.Add(serviceRtMain); serviceRtMainRepository.SaveChanges(); } #endregion #region Edit else { ValidateServiceRt(serviceRtMain, false); serviceRtMainDbVersion.RecLastUpdatedDt = DateTime.Now; serviceRtMainDbVersion.RecLastUpdatedBy = serviceRtMainRepository.LoggedInUserIdentity; serviceRtMainDbVersion.StartDt = serviceRtMain.StartDt; //add new Insurance Rate items if (serviceRtMain.ServiceRts != null) { foreach (ServiceRt serviceRt in serviceRtMain.ServiceRts) { if ( serviceRtMainDbVersion.ServiceRts.All( x => x.ServiceRtId != serviceRt.ServiceRtId) || serviceRt.ServiceRtId == 0) { // set properties serviceRt.IsActive = true; serviceRt.IsDeleted = false; serviceRt.IsPrivate = false; serviceRt.IsReadOnly = false; serviceRt.RecCreatedDt = DateTime.Now; serviceRt.RecLastUpdatedDt = DateTime.Now; serviceRt.RecCreatedBy = serviceRtMainRepository.LoggedInUserIdentity; serviceRt.RecLastUpdatedBy = serviceRtMainRepository.LoggedInUserIdentity; serviceRt.UserDomainKey = serviceRtMainRepository.UserDomainKey; serviceRt.ServiceRtMainId = serviceRtMain.ServiceRtMainId; serviceRtMainDbVersion.ServiceRts.Add(serviceRt); } else { serviceRt.IsActive = true; serviceRt.IsDeleted = false; serviceRt.IsPrivate = false; serviceRt.IsReadOnly = false; serviceRt.RecCreatedDt = DateTime.Now; serviceRt.RecLastUpdatedDt = DateTime.Now; serviceRt.RecCreatedBy = serviceRtMainRepository.LoggedInUserIdentity; serviceRt.RecLastUpdatedBy = serviceRtMainRepository.LoggedInUserIdentity; serviceRt.UserDomainKey = serviceRtMainRepository.UserDomainKey; serviceRt.ServiceRtMainId = serviceRtMain.ServiceRtMainId; long oldRecordId = serviceRt.ServiceRtId; serviceRt.ServiceRtId = 0; serviceRt.RevisionNumber = serviceRt.RevisionNumber + 1; serviceRtRepository.Add(serviceRt); serviceRtRepository.SaveChanges(); ServiceRt oldServiceRt = serviceRtRepository.Find(oldRecordId); oldServiceRt.ChildServiceRtId = serviceRt.ServiceRtId; serviceRtRepository.SaveChanges(); } } } } serviceRtMainRepository.SaveChanges(); #endregion return(new ServiceRtMainContent { TariffTypeCodeName = tariffType.TariffTypeCode + " - " + tariffType.TariffTypeName, TariffTypeId = tariffType.TariffTypeId, OperationId = tariffType.Operation.OperationId, OperationCodeName = tariffType.Operation.OperationCode + " - " + tariffType.Operation.OperationName, ServiceRtMainId = serviceRtMain.ServiceRtMainId, ServiceRtMainCode = serviceRtMain.ServiceRtMainCode, ServiceRtMainName = serviceRtMain.ServiceRtMainName, ServiceRtMainDescription = serviceRtMain.ServiceRtMainDescription, StartDt = serviceRtMain.StartDt }); }
public IContract RegisterContract(Subscriber subscriber, TariffType type) { var contract = new Contract(subscriber, type); return(contract); }
public static TariffType GetTariffType(DateTime recCreatedDate, DateTime startDate, DateTime endDate, Int64 operationId, List <TariffType> oTariffTypeList) { TariffType obj = null; TimeSpan dtSpan = endDate - startDate; //converting duration to minutes for standard scale var duration = dtSpan.Days * 24 * 60 + dtSpan.Hours * 60 + dtSpan.Minutes; //filtering TariffType list on Operation and Record Created Date List <TariffType> oReturnedList = oTariffTypeList.FindAll(delegate(TariffType item) { return(item.OperationId == operationId && item.EffectiveDate <= recCreatedDate); }); // Boolean found = false; //now get the tarifftype by matching time TariffType oReturnedTariffType = oReturnedList.Find(delegate(TariffType item) //changed it to oReturnedList from TariffTypeList { float newDuration = 0; if (item.MeasurementUnitId == (int)(MeasurementUnitEnum.Day)) { newDuration = item.DurationFrom * (24 * 60); } else if (item.MeasurementUnitId == (int)(MeasurementUnitEnum.Hour)) { newDuration = item.DurationFrom * 60; } else if (item.MeasurementUnitId == (int)(MeasurementUnitEnum.Minute)) { newDuration = item.DurationFrom; } if (!found) { if (newDuration <= duration) { obj = item; found = true; } return(false); } else { float oldDuration = 0; if (obj.MeasurementUnitId == (int)(MeasurementUnitEnum.Day)) { oldDuration = obj.DurationFrom * (24 * 60); } else if (obj.MeasurementUnitId == (int)(MeasurementUnitEnum.Hour)) { oldDuration = obj.DurationFrom * 60; } else if (obj.MeasurementUnitId == (int)(MeasurementUnitEnum.Minute)) { oldDuration = obj.DurationFrom; } if (newDuration >= oldDuration && newDuration <= duration) { if (item.MeasurementUnitId == obj.MeasurementUnitId && item.EffectiveDate >= obj.EffectiveDate) { obj = item; } else if (item.MeasurementUnitId > obj.MeasurementUnitId) { obj = item; } } return(false); } }); return(obj); }
public PricingStrategy(TariffType tType) { _TariffType = tType; }
public IContract RegisterContract(Subscriber subscriber, TariffType type) { var contract = new Contract(subscriber, type); return contract; }
public void Add(TariffType type) { tariffTypes.Add(type); }
/// <summary> /// Constructor /// </summary> public FixedPricingStrategy(TariffType tType) : base(tType) { }
/// <summary> /// Add Tariff Rate /// </summary> /// <param name="standardRateMain"></param> /// <returns></returns> public TariffRateContent SaveTariffRate(StandardRateMain standardRateMain) { TariffType tariffType = tariffTypeRepository.Find(long.Parse(standardRateMain.TariffTypeCode)); standardRateMain.TariffTypeCode = tariffType.TariffTypeCode; #region Add if (standardRateMain.StandardRtMainId == 0) { StandardRateValidation(standardRateMain, true); standardRateMain.UserDomainKey = standardRateMainRepository.UserDomainKey; standardRateMain.IsActive = true; standardRateMain.IsDeleted = false; standardRateMain.IsPrivate = false; standardRateMain.IsReadOnly = false; standardRateMain.RecCreatedDt = DateTime.Now; standardRateMain.RecLastUpdatedDt = DateTime.Now; standardRateMain.RecCreatedBy = standardRateMainRepository.LoggedInUserIdentity; standardRateMain.RecLastUpdatedBy = standardRateMainRepository.LoggedInUserIdentity; standardRateMain.RowVersion = 0; //set child (Standard Rate in Standard Rate Main) properties #region Standard Rate in Standard Rate Main if (standardRateMain.StandardRates != null) { // set properties foreach (StandardRate item in standardRateMain.StandardRates) { item.IsActive = true; item.IsDeleted = false; item.IsPrivate = false; item.IsReadOnly = false; item.RecCreatedDt = DateTime.Now; item.RecLastUpdatedDt = DateTime.Now; item.RecCreatedBy = standardRateMainRepository.LoggedInUserIdentity; item.RecLastUpdatedBy = standardRateMainRepository.LoggedInUserIdentity; item.UserDomainKey = standardRateMainRepository.UserDomainKey; } } #endregion standardRateMainRepository.Add(standardRateMain); standardRateMainRepository.SaveChanges(); } #endregion #region Edit else { StandardRateValidation(standardRateMain, false); if (standardRateMain.StandardRates != null) { foreach (StandardRate standardRate in standardRateMain.StandardRates) { standardRate.IsActive = true; standardRate.IsDeleted = false; standardRate.IsPrivate = false; standardRate.IsReadOnly = false; standardRate.RecCreatedDt = DateTime.Now; standardRate.RecLastUpdatedDt = DateTime.Now; standardRate.RecCreatedBy = standardRateMainRepository.LoggedInUserIdentity; standardRate.RecLastUpdatedBy = standardRateMainRepository.LoggedInUserIdentity; standardRate.UserDomainKey = standardRateMainRepository.UserDomainKey; standardRate.StandardRtMainId = standardRateMain.StandardRtMainId; if (standardRate.StandardRtId > 0) { long oldRecordId = standardRate.StandardRtId; standardRate.StandardRtId = 0; standardRate.RevisionNumber = standardRate.RevisionNumber + 1; standardRateRepository.Add(standardRate); standardRateRepository.SaveChanges(); StandardRate oldStandardRate = standardRateRepository.Find(oldRecordId); oldStandardRate.ChildStandardRtId = standardRate.StandardRtId; standardRateRepository.SaveChanges(); } else { standardRateRepository.Add(standardRate); standardRateRepository.SaveChanges(); } } } } #endregion return(new TariffRateContent { StandardRtMainId = standardRateMain.StandardRtMainId, StandardRtMainCode = standardRateMain.StandardRtMainCode, StandardRtMainName = standardRateMain.StandardRtMainName, StandardRtMainDescription = standardRateMain.StandardRtMainDescription, StartDt = standardRateMain.StartDt, EndDt = standardRateMain.EndDt, TariffTypeId = tariffType.TariffTypeId, TariffTypeCodeName = tariffType.TariffTypeCode + " - " + tariffType.TariffTypeName, OperationId = tariffType.OperationId, OperationCodeName = tariffType.Operation.OperationCode + " - " + tariffType.Operation.OperationName, }); }