/// <summary> /// Get details of Hospitality Product groups and its Fixtures /// </summary> /// <param name="inputModel">The given hospitality product group list input model</param> /// <returns>Hospitality Product groups and its fixtures list</returns> public HospitalityProductGroupViewModel GetHospitalityProductGroups(HospitalityProductGroupInputModel inputModel) { HospitalityProductGroupViewModel viewModel = new HospitalityProductGroupViewModel(getContentAndAttributes: true); DataSet dsProductGroupList = new DataSet(); DataSet dsProductGroupFixturesList = new DataSet(); ErrorObj err = new ErrorObj(); DEProductDetails de = new DEProductDetails(); DESettings settings = Environment.Settings.DESettings; List <ProductGroupDetails> productGroupDetailsList = new List <ProductGroupDetails>(); List <ProductDetails> productGroupFixturesList = new List <ProductDetails>(); dsProductGroupList = retrieveProductGroups(); viewModel.Error = Data.PopulateErrorObject(err, dsProductGroupList, settings, GlobalConstants.STATUS_RESULTS_TABLE_NAME, 2); if (!viewModel.Error.HasError) { productGroupDetailsList = Data.PopulateObjectListFromTable <ProductGroupDetails>(dsProductGroupList.Tables["ProductGroupsDetails"]); foreach (ProductGroupDetails productGroup in productGroupDetailsList) { HospitalityProductGroupInputModel inputModelProductGroup = new HospitalityProductGroupInputModel(); inputModelProductGroup.ProductGroupCode = productGroup.GroupId; dsProductGroupFixturesList = retrieveProductGroupFixtures(inputModelProductGroup.ProductGroupCode); viewModel.Error = Data.PopulateErrorObject(err, dsProductGroupFixturesList, settings, GlobalConstants.STATUS_RESULTS_TABLE_NAME, 2); if (!viewModel.Error.HasError) { productGroup.ProductGroupFixturesList = new List <ProductDetails>(); productGroup.ProductGroupFixturesList = Data.PopulateObjectListFromTable <ProductDetails>(dsProductGroupFixturesList.Tables["ProductGroupFixturesDeatils"]); } } viewModel.ProductGroupDetailsList = productGroupDetailsList; } return(viewModel); }
/// <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); }