Exemplo n.º 1
0
        /// <summary>
        /// Call the functions of creating the HospitalityProductListViewModel and HospitalityProductGroupViewModel
        /// then use the HospitalityProductGroupViewModel to filter HospitalityProductListViewModel based on ProductCode
        /// </summary>
        /// <param name="inputModelProductList">The given hospitality product list input model</param>
        /// <param name="inputModelProductGroup">The given hospitality product group input model</param>
        /// <returns>The formed hospitality product group view model</returns>
        public HospitalityProductGroupViewModel GetHospitalityProductListByProductGroup(HospitalityProductListInputModel inputModelProductList, HospitalityProductGroupInputModel inputModelProductGroup)
        {
            HospitalityProductListViewModel  productListViewModel  = new HospitalityProductListViewModel(getContentAndAttributes: true);
            HospitalityProductGroupViewModel productGroupViewModel = new HospitalityProductGroupViewModel(getContentAndAttributes: true);

            productListViewModel = GetHospitalityProductList(inputModelProductList);
            if (productListViewModel.Error != null && productListViewModel.Error.HasError)
            {
                productGroupViewModel.Error.HasError = true;
            }
            else
            {
                productGroupViewModel = GetHospitalityProductGroups(inputModelProductGroup);
                if (productGroupViewModel.Error == null || !productGroupViewModel.Error.HasError)
                {
                    productGroupViewModel.ProductGroupDetailsList = productGroupViewModel.ProductGroupDetailsList.Where(a => a.GroupId.Equals(inputModelProductGroup.ProductGroupCode)).ToList();

                    if (productGroupViewModel.ProductGroupDetailsList.Count > 0)
                    {
                        productGroupViewModel.ProductGroupFixturesList = new List <ProductDetails>();
                        productGroupViewModel.ProductGroupFixturesList = productListViewModel.ProductListDetailByPackageId.Where(a => productGroupViewModel.ProductGroupDetailsList[0].ProductGroupFixturesList.Any(b => b.ProductCode.Trim().Equals(a.ProductCode.Trim()))).ToList();
                    }
                    else
                    {
                        productGroupViewModel.Error.HasError = true;
                    }
                }
            }

            return(productGroupViewModel);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieve the list of corporate hospitality products
        /// Home and Season products are sorted and returned as two lists
        /// The date is formatted in a very specific way to allow javascript date formatting to work correctly with time zones.
        /// </summary>
        /// <param name="inputModel">The given hospitality product list input model</param>
        /// <returns>The formed hospitality product list view model</returns>
        public HospitalityProductListViewModel GetHospitalityProductList(HospitalityProductListInputModel inputModel)
        {
            _productListViewModel = new HospitalityProductListViewModel();
            if (String.IsNullOrEmpty(inputModel.PackageID))
            {
                DataTable             dtProductListHome   = buildProductListDataTable(GlobalConstants.HOMEPRODUCTTYPE);
                DataTable             dtProductListSeason = buildProductListDataTable(GlobalConstants.SEASONTICKETPRODUCTTYPE);
                List <ProductDetails> productListHome     = new List <ProductDetails>();
                List <ProductDetails> productListSeason   = new List <ProductDetails>();
                productListHome   = Data.PopulateObjectListFromTable <ProductDetails>(dtProductListHome);
                productListSeason = Data.PopulateObjectListFromTable <ProductDetails>(dtProductListSeason);

                foreach (ProductDetails product in productListHome)
                {
                    DateTime dateUpdated = new DateTime();
                    dateUpdated               = Utilities.ISeriesDate(product.ProductMDTE08);
                    product.ProductDate       = dateUpdated.ToString(Environment.Settings.DefaultValues.GlobalDateFormat);
                    product.ProductDateSearch = dateUpdated.ToString("yyyy-MM-ddT00:00:00Z");//specific time format for filtering
                }
                foreach (ProductDetails product in productListSeason)
                {
                    DateTime dateUpdated = new DateTime();
                    dateUpdated               = Utilities.ISeriesDate(product.ProductMDTE08);
                    product.ProductDate       = dateUpdated.ToString(Environment.Settings.DefaultValues.GlobalDateFormat);
                    product.ProductDateSearch = dateUpdated.ToString("yyyy-MM-ddT00:00:00Z");//specific time format for filtering
                }

                _productListViewModel.ProductListDetailsHome   = productListHome;
                _productListViewModel.ProductListDetailsSeason = productListSeason;
                if (productListHome.Count > 0)
                {
                    _productListViewModel.MinDateHome = productListHome.OrderBy((x) => x.ProductMDTE08).Select((x) => x.ProductDateSearch).First();
                    _productListViewModel.MaxDateHome = productListHome.OrderBy((x) => x.ProductMDTE08).Select((x) => x.ProductDateSearch).Last();
                }
                if (productListSeason.Count > 0)
                {
                    _productListViewModel.MinDateSeason = productListSeason.OrderBy((x) => x.ProductMDTE08).Select((x) => x.ProductDateSearch).First();
                    _productListViewModel.MaxDateSeason = productListSeason.OrderBy((x) => x.ProductMDTE08).Select((x) => x.ProductDateSearch).Last();
                }
            }
            else
            {
                // PackageId must have been pass into viewModel
                // Retrieve the product list based on the selected package ID
                List <ProductDetails> productList   = new List <ProductDetails>();
                DataTable             dtProductList = buildProductListDataTable(inputModel.ProductType);
                foreach (DataRow productRow in dtProductList.Rows)
                {
                    DataSet   dsPackagesAndComponents = retrieveHospitalityPackages(productRow["ProductCode"].ToString());
                    DataTable dtPackages   = dsPackagesAndComponents.Tables["PackageList"];
                    DataTable dtComponents = dsPackagesAndComponents.Tables["ComponentList"];
                    DataView  dvFilteredPackages;
                    DataTable dtFilteredPackages;
                    if (dtPackages != null && dtComponents != null)
                    {
                        //check if packageList contains selected package
                        dvFilteredPackages           = new DataView(dtPackages);
                        dvFilteredPackages.RowFilter = String.Format("PackageId = '{0}'", inputModel.PackageID.ToString());
                        dtFilteredPackages           = dvFilteredPackages.ToTable();
                        if (dtFilteredPackages.Rows.Count > 0)
                        {
                            ProductDetails          product                = new ProductDetails();
                            List <PackageDetails>   packageList            = new List <PackageDetails>();
                            List <ComponentDetails> componentsList         = new List <ComponentDetails>();
                            List <ComponentDetails> filteredComponentsList = new List <ComponentDetails>();
                            DateTime dateUpdated = new DateTime();

                            dateUpdated = Utilities.ISeriesDate(productRow["ProductMDTE08"].ToString());
                            productRow["ProductDate"] = dateUpdated.ToString(Environment.Settings.DefaultValues.GlobalDateFormat);
                            product                    = Data.PopulateObjectFromRow <ProductDetails>(productRow);
                            packageList                = Data.PopulateObjectListFromTable <PackageDetails>(dtFilteredPackages);
                            componentsList             = Data.PopulateObjectListFromTable <ComponentDetails>(dtComponents);
                            filteredComponentsList     = componentsList.Where(x => x.PackageID.ToString() == inputModel.PackageID).ToList();
                            product.AvailabilityDetail = getAvailabilityDetails(packageList[0], filteredComponentsList);
                            productList.Add(product);
                        }
                    }
                }
                _productListViewModel.ProductListDetailByPackageId = productList;
            }
            return(_productListViewModel);
        }