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; } }
// writing salutation into html span for js consumption protected void Page_Load(object sender, EventArgs e) { pnlAlertIcon.Visible = pnlAlertIcon.Enabled = GlobalContext.CultureConfiguration.IsDSAlertsEnabled && !Roles.IsUserInRole(RoleDefinitions.ROLE_DELETED_ID); if (GlobalContext.IsLoggedIn && null != DistributorProfileModel) { _FullName.Text = DistributorProfileModel.DistributorName(); _Salutation.Text = _localizationManager.GetGlobalString("HrblUI", DistributorProfileModel.TeamLevelNameResourceKey); } _LogonStatus.Text = _localizationManager.GetString("~/Controls/Logon/LogonStatusView.ascx", "_LogonStatus.LogoutText", CultureInfo.CurrentUICulture); BizWorksLogo.Visible = !Roles.IsUserInRole(RoleDefinitions.ROLE_BIZWORKS_NOT_SUBSCRIBED); lblvolumeNotAvailable.Text = _localizationManager.GetGlobalString("HrblUI", "volumeNotAvailable"); }
internal async Task <List <VolumeModel> > Get(string id) { var result = new List <VolumeModel>(); try { var model = await VolumeSource.GetVolume(id); if (null != model && model.Count > 0) { foreach (var volumeModel in model) { var pattern = LocalizationManager.GetGlobalString("HrblUI", "VolumeHeaderStringPattern"); var monthName = CultureInfo.CurrentUICulture.DateTimeFormat.GetMonthName(volumeModel.VolumeMonth); volumeModel.MonthName = monthName; volumeModel.HeaderText = string.Format(CultureInfo.CurrentUICulture, pattern, volumeModel.HeaderVolume); result.Add(volumeModel); } } } catch (Exception ex) { LoggerHelper.Exception("Error", ex, "Failed loading volume for id" + id); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { ReasonPhrase = "Error while loading volume for " + id }); } if (result.Count == 0) { LoggerHelper.Info("No volume data for " + id); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound) { ReasonPhrase = "No data found for " + id }); } return(result); }