private static List <VolumeModel> GetVolumeViewModel(IEnumerable <DistributorVolume_V01> volumePoints, string countryCode, string id) { if (null == volumePoints) { LoggerHelper.Error(string.Format("volumePoints is null in the method GetVolumeViewModel {0}\n{1}", id, countryCode)); return(null); } try { var distributorProvider = new Core.DistributorProvider.DistributorProfileLoader(); var distributorModel = distributorProvider.Load(new GetDistributorProfileById { Id = id }); var currentMonth = DateUtils.GetCurrentLocalTime(countryCode).Month; var volumeModels = volumePoints.Select(distributorVolumeV01 => { var volumeMonth = GetVolumeMonth(distributorVolumeV01.VolumeMonth); return(new VolumeModel { DV = ExtractValue(distributorVolumeV01.DownlineVolume, 0.0M), GV = ExtractValue(distributorVolumeV01.GroupVolume, 0.0M), PPV = ExtractValue(distributorVolumeV01.PersonallyPurchasedVolume, 0.0M), PV = ExtractValue(distributorVolumeV01.Volume, 0.0M), TV = ExtractValue(distributorVolumeV01.TotalVolume, 0.0M), HeaderVolume = GetHeaderVolume(distributorVolumeV01, distributorModel.TypeCode), VolumeMonth = volumeMonth, IsCurrentMonth = currentMonth == volumeMonth, PPVText = _localization.GetGlobalString("HrblUI", "VolumePPVText"), DVText = _localization.GetGlobalString("HrblUI", "VolumeDVText"), TVText = _localization.GetGlobalString("HrblUI", "VolumePVText"), PVText = _localization.GetGlobalString("HrblUI", "VolumePVText"), GVText = _localization.GetGlobalString("HrblUI", "VolumeGVText") }); }).ToList(); ILoader <Dictionary <DateTime, DateTime>, string, DateTime> dualMonthLoader = new DualOrderMonthLoader(); var settings = new DualOrderMonthProvider(new DualOrderMonthLoader()); var localNow = DateUtils.GetCurrentLocalTime(countryCode); var isDualOrderMonth = settings.IsDualOrderMonth(countryCode, localNow); return(!isDualOrderMonth ? volumeModels.Where(v => v.VolumeMonth == currentMonth).ToList() : volumeModels); } catch (Exception ex) { LoggerHelper.Error(string.Format("Exception occured GetVolumeViewModel method {0}\n{1}", id, ex)); throw; } }
public DualOrderMonthViewModel GetDualOrderMonth(string country) { if (string.IsNullOrEmpty(country)) { LoggerHelper.Error("country is null - MobileDualOrderMonthController"); return(null); } try { var _businessSettings = new DualOrderMonthProvider(new DualOrderMonthLoader()); var result = new DualOrderMonthResponseViewModel(); var localNow = DateUtils.GetCurrentLocalTime(country); var isDualOrderMonth = _businessSettings.IsDualOrderMonth(country, localNow); var dualOrderMonthModel = new DualOrderMonthViewModel { PreviousOrderMonth = localNow.Month - 1, }; if (isDualOrderMonth) { var monthEndDate = _businessSettings.GetDualMonthEndValue(country, localNow); dualOrderMonthModel.PreviousOrderMonthEndDate = null != monthEndDate ? monthEndDate.Value.ToString("yyyy-MM-ddTHH:mm:sszzz") : "calendar"; } else { dualOrderMonthModel.PreviousOrderMonthEndDate = "calendar"; } return(dualOrderMonthModel); } catch (Exception ex) { LoggerHelper.Exception("General", ex, "error in DualOrderMonthViewModel GetDualOrderMonth"); return(null); } }