//private List<string> getAndFixPictures(IHasMenuPaths mp) //{ // List<string> pictureAddresses = GetCurrItemsPictureList(mp as IHasUploads); // List<string> childProductPictures = GetMenuPathChildProductPicturesFor(mp); // if (!childProductPictures.IsNullOrEmpty()) // { // string blankPicAddress = UploadedFile.DefaultBlankPictureLocation(); // //add to pictureaddress // pictureAddresses = // pictureAddresses // .Concat(childProductPictures) // .ToList(); // pictureAddresses.Remove(blankPicAddress); // } // return pictureAddresses; //} ///// <summary> ///// this adds child product pictures to menu 1... about 5 ///// </summary> ///// <param name="menuPath"></param> ///// <returns></returns> ////private List<string> GetMenuPathChildProductPicturesFor(MenuPath1 mp1,MenuPath1 mp2,MenuPath1 mp3, Product product) //{ // if(product.IsNull()) // { // return picturesFromProducts(product); // } // if (mp3.IsNull()) // { // mp1.IsNullThrowException(); // mp2.IsNullThrowException(); // return picturesForMenuPath(mp1, mp2, mp3); // } // if (mp2.IsNull()) // { // mp1.IsNullThrowException(); // return picturesForMenuPath(mp1, mp2); // } // if (mp1.IsNull()) // { // return picturesForMenuPath(mp1); // } // return null; // List<string> pictureList = new List<string>(); // List<string> productImages = new List<string>(); // int noOfImages = 0; // int returnNoOfPictures = MenuPath1.MaxNumberOfPicturesInMenu(); // int getNoOfPicturesToSelectFrom = returnNoOfPictures * 20; // string defaultFileLocation = UploadedFile.DefaultBlankPictureLocation(); // //get child products // if (menuPath.MenuPathMains_Fixed.IsNullOrEmpty()) // return pictureList; // foreach (MenuPathMain mmp in menuPath.MenuPathMains_Fixed) // { // if (mmp.Products_Fixed_And_Approved.IsNullOrEmpty()) // continue; // foreach (var product in mmp.Products_Fixed_And_Approved) // { // if (noOfImages == getNoOfPicturesToSelectFrom) // break; // if (product.ProductChildren_Fixed.IsNullOrEmpty()) // continue; // productImages = getPicturesForProduct(product); // } // } // if (pictureList.IsNullOrEmpty()) // return pictureList; // //Randomize the list // List<string> pictureList_Random = pictureList.OrderBy(x => Guid.NewGuid()).ToList(); // if (pictureList_Random.Count > returnNoOfPictures) // return pictureList_Random.GetRange(0, returnNoOfPictures); // return pictureList_Random; //} private List <string> getRandomPictures(List <string> picList) { string defaultFileLocation = UploadedFile.DefaultBlankPictureLocation(); if (picList.IsNullOrEmpty()) { return(null); } picList.Remove(defaultFileLocation); if (picList.IsNullOrEmpty()) { return(null); } picList = picList.OrderBy(x => Guid.NewGuid()).ToList(); return(picList); }
private List <string> joinCurrPicsAndPictureAddresses(List <string> pictureAddresses, List <string> currPcs) { if (!currPcs.IsNullOrEmpty()) { currPcs.Remove(UploadedFile.DefaultBlankPictureLocation()); } if (!pictureAddresses.IsNullOrEmpty()) { pictureAddresses.Remove(UploadedFile.DefaultBlankPictureLocation()); } if (currPcs.IsNullOrEmpty()) { if (pictureAddresses.IsNullOrEmpty()) { } else { pictureAddresses = pictureAddresses.Concat(currPcs).ToList(); } } else { if (pictureAddresses.IsNullOrEmpty()) { pictureAddresses = currPcs; } else { //remove currPcs from pictureAddress //remove duplicates from CurrPic int returnNoOfPictures = MenuPath1.MaxNumberOfPicturesInMenu() + 1; currPcs = new HashSet <string>(currPcs).ToList(); if (!currPcs.IsNullOrEmpty()) { foreach (string currPic in currPcs) { pictureAddresses.Remove(currPic); } } if (pictureAddresses.IsNullOrEmpty()) { return(currPcs); } //now currPcs has its own pics //and picture address has its own if (currPcs.Count >= returnNoOfPictures) { return(currPcs.GetRange(0, returnNoOfPictures)); } else { int noOfPicsRequried = returnNoOfPictures - currPcs.Count; //if there are more pics in picture address than required.... if (pictureAddresses.Count >= noOfPicsRequried) { pictureAddresses = getRandomPictures(pictureAddresses); pictureAddresses = pictureAddresses.GetRange(0, noOfPicsRequried); } pictureAddresses = pictureAddresses.Concat(currPcs).ToList(); pictureAddresses = new HashSet <string>(pictureAddresses).ToList(); } } } return(pictureAddresses); }