public async Task<ActionResult> MovementReport(ReportPresenter reportPresenter, string pageNumber) { reportPresenter.MovementSearchParameters = SessionData.Instance.MovementReportSearchParameters != null && !string.IsNullOrEmpty(pageNumber) ? SessionData.Instance.MovementReportSearchParameters : reportPresenter.MovementSearchParameters; if (reportPresenter != null && reportPresenter.MovementSearchParameters != null) { reportPresenter.MovementSearchParameters.ClearanceStatus = reportPresenter.MovementSearchParameters.ClearanceStatus == ZeroConst ? string.Empty : reportPresenter.MovementSearchParameters.ClearanceStatus; reportPresenter.MovementSearchParameters.PageNumber = (!string.IsNullOrEmpty(pageNumber) && !pageNumber.Equals(UndefinedConstant)) ? (Convert.ToInt32(pageNumber) > 0 ? Convert.ToInt32(pageNumber) / ApplicationSettings.MaxPageSize : 1) : 1; reportPresenter.MovementSearchParameters.PageSize = SessionData.Instance.PagingNumberOfRecords; if (!string.IsNullOrEmpty(reportPresenter.MovementSearchParameters.SearchName)) { if (reportPresenter.MovementSearchParameters.SearchName.Contains(Comma)) { var name = reportPresenter.MovementSearchParameters.SearchName.Trim().Split(Comma); reportPresenter.MovementSearchParameters.LastName = name[0]; reportPresenter.MovementSearchParameters.FirstName = name[1].Trim(); } else { reportPresenter.MovementSearchParameters.LastName = reportPresenter.MovementSearchParameters.SearchName.Trim(); } } if (reportPresenter.MovementSearchParameters.VoyageId == null) { var voyage = reportPresenter.ActiveVoyages.OrderByDescending(d => d.EmbarkDate).FirstOrDefault(item => item.IsActive); reportPresenter.MovementSearchParameters.VoyageId = voyage != null ? voyage.VoyageId : string.Empty; } if (!string.IsNullOrEmpty(reportPresenter.MovementSearchParameters.MovementActivityStartDate) && !string.IsNullOrEmpty(reportPresenter.MovementSearchParameters.MovementActivityEndDate)) { reportPresenter.MovementSearchParameters.MovementActivityStartDate = Convert.ToDateTime(reportPresenter.MovementSearchParameters.MovementActivityStartDate).ToString(this.ApplicationSettings.ShipDateTimeFormat, CultureInfo.InvariantCulture); reportPresenter.MovementSearchParameters.MovementActivityEndDate = Convert.ToDateTime(reportPresenter.MovementSearchParameters.MovementActivityEndDate).ToString(this.ApplicationSettings.ShipDateTimeFormat, CultureInfo.InvariantCulture); } var movement = await this.reportManager.RetrieveMovementReportAsync(reportPresenter.MovementSearchParameters); if (movement.Items.Count > 0) { movement.AssignItems(movement.Items.Select(item => { item.MediaItemAddress = !string.IsNullOrEmpty(item.MediaItemAddress) ? item.MediaItemAddress + AuthConst + reportPresenter.AuthenticationToken + ImageSizeConst + ThumbnailConst : DefaultThumbnailImage; return item; }).ToList()); reportPresenter.AssignMovementSearchResult(movement); reportPresenter.TotalRecordCount = movement.TotalResults; } reportPresenter.NoRecordFound = movement.Items.Count <= 0; SessionData.Instance.AssignMovementData(reportPresenter.MovementSearchParameters); } return this.PartialView(MovementPartialView, reportPresenter); }
/// <summary> /// Guests the movement report print. /// </summary> /// <returns>The Task</returns> public async Task<ActionResult> GuestMovementReportPrint() { var reportPresenter = new ReportPresenter(); var searchFilter = new MovementReportSearchParameters(); searchFilter = SessionData.Instance.MovementReportSearchParameters; searchFilter.PageSize = 0; searchFilter.PageNumber = 1; var movement = await this.reportManager.RetrieveMovementReportAsync(searchFilter); if (movement != null && movement.Items.Count > 0) { var authenticationToken = await Client.Common.TokenManager.CreateAsync(new CancellationToken(false)); movement.AssignItems(movement.Items.Select(item => { item.MediaItemAddress = !string.IsNullOrEmpty(item.MediaItemAddress) ? item.MediaItemAddress + AuthConst + authenticationToken + ImageSizeConst + ThumbnailConst : DefaultThumbnailImage; return item; }).ToList()); reportPresenter.AssignMovementSearchResult(movement); } return this.View(MovementReportPrintView, reportPresenter); }