Пример #1
0
        public override void BusinessRulesFor(ControllerCreateEditParameter parm)
        {
            MenuPathMain mpm = parm.Entity as MenuPathMain;

            base.BusinessRulesFor(parm);
            _menuPathMainBiz.BusinessRulesFor(parm);
        }
Пример #2
0
        private List <string> picturesForMenuPath(MenuPathMain mpm)
        {
            mpm.IsNullThrowExceptionArgument();

            if (mpm.Products_Fixed_And_Approved.IsNullOrEmpty())
            {
                return(null);
            }

            List <string> picList = new List <string>();

            foreach (var product in mpm.Products_Fixed_And_Approved)
            {
                if (product.ProductChildren_Fixed.IsNullOrEmpty())
                {
                    continue;
                }

                List <string> picListFmProducts = picturesForProducts(product);
                if (!picListFmProducts.IsNullOrEmpty())
                {
                    picList = picList.Concat(picListFmProducts).ToList();
                }
            }
            //first get main path
            //get all products
            return(picList);
        }
Пример #3
0
        //private void RemoveFeatures(Product product, List<ProductFeature> productFeatureList)
        //{
        //    //remove those features that are now not existant in any of the menu paths.

        //    if (productFeatureList.IsNullOrEmpty())
        //        return;

        //    if (product.ProductFeatures.IsNullOrEmpty())
        //        return;

        //    List<string> nameOfMenuFeaturesToRemoveLst = new List<string>();

        //    //first remove any feature that is not a part of menuFeaturesHashSet.
        //    //this means that some meap path has been removed, and then the feature must go.
        //    foreach (ProductFeature pf in productFeatureList)
        //    {

        //        ProductFeature pfFound = ProductFeatureBiz.FindAll().FirstOrDefault(x => x.Name == pf.Name);
        //        if (pfFound.IsNull())
        //        {
        //            //found, this menu feature no longer exists.
        //            nameOfMenuFeaturesToRemoveLst.Add(pf.Name);
        //        }
        //    }

        //    //now remove them from the product
        //    if (!nameOfMenuFeaturesToRemoveLst.IsNullOrEmpty())
        //    {
        //        foreach (string name in nameOfMenuFeaturesToRemoveLst)
        //        {
        //            ProductFeature pf = product.ProductFeatures.FirstOrDefault(x => x.Name == name);

        //            if (pf.IsNull())
        //                continue;

        //            pf.MetaData.IsDeleted = true;
        //            pf.MetaData.Deleted.SetToTodaysDate(UserId);
        //            pf.Comment = "Item was deleted as it was no longer part of a menu path. BusinessLibrary.fixProductFeatures.RemoveFeatures";

        //            ProductFeatureBiz.Update(pf);
        //        }
        //    }
        //}


        private HashSet <MenuFeature> getAllCurrentFeaturesFor(MenuPathMain mpm)
        {
            mpm.MenuPath1.IsNullThrowException("Menu Path 1 is null. Programming error.");
            List <MenuFeature> menuFeatures1 = mpm.MenuPath1.MenuFeatures.ToList();
            List <MenuFeature> menuFeatures2 = mpm.MenuPath2.MenuFeatures.ToList();
            List <MenuFeature> menuFeatures3 = mpm.MenuPath3.MenuFeatures.ToList();

            HashSet <MenuFeature> menuFeaturesHashSet = new HashSet <MenuFeature>();

            if (!menuFeatures1.IsNullOrEmpty())
            {
                foreach (MenuFeature mf in menuFeatures1)
                {
                    menuFeaturesHashSet.Add(mf);
                }
            }

            if (!menuFeatures2.IsNullOrEmpty())
            {
                foreach (MenuFeature mf in menuFeatures2)
                {
                    menuFeaturesHashSet.Add(mf);
                }
            }

            if (!menuFeatures3.IsNullOrEmpty())
            {
                foreach (MenuFeature mf in menuFeatures3)
                {
                    menuFeaturesHashSet.Add(mf);
                }
            }
            return(menuFeaturesHashSet);
        }
Пример #4
0
        public ShopVM Setup_To_Create_Shop_Get(string returnUrl, string menuPathMainId)
        {
            menuPathMainId.IsNullOrWhiteSpaceThrowException("No Menu Path");
            UserId.IsNullOrWhiteSpaceThrowException("You must be logged in to continue.");
            decimal ratePerMonth = getShopRatePerMonth();
            int     noOfMonths   = 1;
            decimal totalAmount  = ratePerMonth * noOfMonths;

            AddressStringWithNames customerAddress = getDefaultCustomerAddress();
            MenuPathMain           mpm             = MenuPathMainBiz.Find(menuPathMainId);

            mpm.IsNullThrowException("Menu Path not found");

            CashDistributionEngine cashDistributionEnginge = get_CashDistributionEngineAndCheckBalance(totalAmount, true);

            string explaintion = string.Format("{0}. All your products will be collected and will be shown in your shop. Note, every shop must have a unique name and will be created in its own area. This shop will be created in: ", cashDistributionEnginge.Message);



            List <string> shopNames = getShopNamesForCurrUser();
            string        shopName  = getAUniqueNameForShop();

            ShopVM shopCreate = new ShopVM("", shopName, explaintion, noOfMonths, ratePerMonth, returnUrl, shopNames, mpm, customerAddress);

            return(shopCreate);
        }
Пример #5
0
        private CashDistributionEngine get_CashDistributionEngineAndCheckBalance(decimal paymentAmount, bool isNonRefundablePaymentAllowed)
        {
            UserId.IsNullOrWhiteSpaceThrowException("You must be logged in");
            decimal amountToBuyShop = MenuPathMain.Payment_To_Buy_Shop();

            Person person = PersonBiz.GetPersonForUserId(UserId);

            person.IsNullThrowException();

            CashBalanceVM cashBalance = BalanceFor_Person(person.Id, CashStateENUM.Available);

            CashDistributionEngine cde = new CashDistributionEngine(
                cashBalance,
                paymentAmount,
                0,
                isNonRefundablePaymentAllowed);


            if (cde.CanBuy())
            {
                string msg = string.Format("You have a total balance of: Rs{0:N2}. Money = {1:N2}, Non Refundable Tokens {2:N2}. You can buy the shop for this month! The expected spending will be as follows: Money = Rs{3:N2}, Tokens = Rs{4:N2}",
                                           cde.CashBalance.Total(),
                                           cde.CashBalance.Refundable,
                                           cde.CashBalance.NonRefundable,
                                           cde.Refundable_Final,
                                           cde.NonRefundable_Final);

                cde.Message = msg;
                return(cde);
            }
            else
            {
                throw new Exception("You have a total balance of: Rs" + cde.CashBalance.Total().ToString("N2") + ". You do not have sufficent money to buy the shop.");
            }
        }
Пример #6
0
        private MenuPathMain getMainMenuPath(ShopVM shopCreate)
        {
            MenuPathMain mpm = MenuPathMainBiz.Find(shopCreate.MenuPathMainId);

            mpm.IsNullThrowException("Menu Path Not Found.");
            return(mpm);
        }
Пример #7
0
        //private ICollection<OwnersChildProductsWithLink> loadOwnersChildProductsWithLinks(HashSet<ProductChild> childProductsBelongingToUserFrom)
        //{
        //    if (childProductsBelongingToUserFrom.IsNullOrEmpty())
        //        return null;

        //    List<OwnersChildProductsWithLink> ownersChildProductsWithLinkLst = new List<OwnersChildProductsWithLink>();

        //    foreach (ProductChild productChild in childProductsBelongingToUserFrom)
        //    {
        //        string saleLink = createLandingPageLinkForProductChild(productChild);
        //        OwnersChildProductsWithLink ownersChildProductsWithLink = new OwnersChildProductsWithLink(productChild, saleLink);
        //    }

        //    return ownersChildProductsWithLinkLst;
        //}

        //private string createLandingPageLinkForProductChild(ProductChild productChild)
        //{
        //    //Url.Action("ProductChildLandingPage", "ProductChilds", new { productChildId = menuVar.IdForEdit, menuEnum = Model.MenuManager.MenuState.NextMenu, returnUrl = returnUrl });
        //}

        private MenuPathMain getMpm(string menuPathMainId)
        {
            menuPathMainId.IsNullOrWhiteSpaceThrowArgumentException("menuPathMainId");
            MenuPathMain mpm = MenuPathMainBiz.Find(menuPathMainId);

            mpm.IsNullThrowException("mpm");
            return(mpm);
        }
Пример #8
0
        public override void Fix(ControllerCreateEditParameter parm)
        {
            base.Fix(parm);
            MenuPathMain mpm = new MenuPathMain();

            mpm = parm.Entity as MenuPathMain;
            getMenuPaths(mpm);
            fixName(mpm);
        }
Пример #9
0
        private static decimal getTotalPayment(ShopVM shopCreate)
        {
            if (shopCreate.NoOfMonths == 0)
            {
                throw new Exception("No of months is zero");
            }

            //see if User has the money to do what they want.
            decimal paymentAmount = MenuPathMain.Payment_To_Buy_Shop() * shopCreate.NoOfMonths;

            return(paymentAmount);
        }
Пример #10
0
        private async Task <List <ICommonWithId> > indexMenuPath3_DataListAsync(ControllerIndexParams parms)
        {
            parms.MenuPathMainId.IsNullOrWhiteSpaceThrowException("Main Menu Path Id not received.");

            MenuPathMain mpm = await FindAsync(parms.MenuPathMainId);

            mpm.IsNullThrowException("MenuPathMain not found.");

            List <MenuPathMain> uniqueListOfMainPaths = UniqueListOfMainPath_IDs(mpm.MenuPath1Id, mpm.MenuPath2Id);

            //===========================================
            List <MenuPathMain> mpms_Distinct_With_Live_Products_And_Shops = get_All_Live_Products_And_Shops();
            //===========================================

            //update the count of Menu2Path
            MenuPath2 mp2 = MenuPathMainBiz.MenuPath2Biz.FindAll().FirstOrDefault(x => x.Id == mpm.MenuPath2Id);

            if (!mp2.IsNull())
            {
                if (!UserId.IsNullOrWhiteSpace())
                {
                    //these can be wrng if they also describe other paths
                    //this is how many times this particular picture has been clicked
                    mp2.NoOfVisits.AddOne(UserId, UserName);
                    await MenuPathMainBiz.MenuPath2Biz.UpdateAndSaveAsync(mp2);
                }
            }


            if (uniqueListOfMainPaths.IsNullOrEmpty())
            {
                return(null);
            }


            foreach (MenuPathMain mpm2 in uniqueListOfMainPaths)
            {
                //check to see if these items have any sale items
                if (mpms_Distinct_With_Live_Products_And_Shops.Contains(mpm2))
                {
                    mpm2.HasLiveProductChildren = true;
                    mpm2.NoOfItems = mpm2.ProductChildren_Fixed_Not_Hidden.Count;
                    mpm2.NoOfShops = mpm2.Product_Shops_Not_Expired.Count;
                }
            }
            List <ICommonWithId> mpmlst = uniqueListOfMainPaths.Cast <ICommonWithId>().ToList();


            return(mpmlst);
        }
Пример #11
0
        /// <summary>
        /// When the Product is created from the productMenu, then its; menuPathMainId is sent along with it
        /// This will be its first MenuPathMain. User can add more as required.
        /// </summary>
        /// <param name="parm"></param>
        /// <param name="product"></param>
        private void addMenuPathMainSentFromView(ControllerIndexParams parm, Product product)
        {
            if (!parm.MenuPathMainId.IsNullOrWhiteSpace())
            {
                if (product.MenuPathMains.IsNull())
                {
                    product.MenuPathMains = new List <MenuPathMain>();
                }

                MenuPathMain mpm = MenuPathMainBiz.Find(parm.MenuPathMainId);
                mpm.IsNullThrowException("Menu Path main not found");
                product.MenuPathMains.Add(mpm);
            }
        }
Пример #12
0
        //private List<string> GetProductPicturesForWrapper(Product product)
        //{

        //    //int noOfImages = 0;
        //    int returnNoOfPictures = MenuPath1.MaxNumberOfPicturesInMenu();
        //    //int getNoOfPicturesToSelectFrom = returnNoOfPictures * 20;



        //    //get products pictures
        //    List<string> pictureAddresses = GetCurrItemsPictureList(product);

        //    List<string> pictureList = getPicturesForProduct(product);

        //    if (pictureList.IsNullOrEmpty())
        //        return pictureAddresses;

        //    //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> getPicturesForProduct(Product product)
        //{
        //    int noOfImages = 0;
        //    int returnNoOfPictures = MenuPath1.MaxNumberOfPicturesInMenu();
        //    int getNoOfPicturesToSelectFrom = returnNoOfPictures * 20;
        //    string defaultFileLocation = UploadedFile.DefaultBlankPictureLocation();

        //    List<string> pictureList = new List<string>();
        //    foreach (ProductChild pchild in product.ProductChildren_Fixed)
        //    {
        //        if (noOfImages == getNoOfPicturesToSelectFrom)
        //            break;

        //        if (pchild.MiscFiles_Fixed.IsNullOrEmpty())
        //            continue;

        //        //getImageAddressOf()
        //        //get one from each product until we have 5
        //        foreach (UploadedFile upf in pchild.MiscFiles_Fixed)
        //        {
        //            if (noOfImages == getNoOfPicturesToSelectFrom)
        //                break;

        //            if (!upf.IsImage())
        //                continue;

        //            string imageLocation = getImageAddressOf(upf);

        //            if (imageLocation.IsNullOrWhiteSpace())
        //                continue;

        //            if (imageLocation.ToLower() == defaultFileLocation.ToLower())
        //                continue;

        //            pictureList.Add(imageLocation);
        //            noOfImages++;
        //            break;
        //        }

        //    }
        //    return pictureList;

        //}



        /// <summary>
        /// this counts the views of Mp2
        /// </summary>
        /// <param name="mpm"></param>
        /// <returns></returns>
        private long getMp2Count(MenuPathMain mpm)
        {
            if (mpm.IsNull())
            {
                return(0);
            }

            long count = MenuPathMainBiz
                         .FindAll()
                         .Where(x => x.MenuPath1Id == mpm.MenuPath1Id && x.MenuPath2Id == mpm.MenuPath2Id)
                         .Sum(y => y.NoOfVisits.Amount);

            return(count);
        }
Пример #13
0
        public override void Event_ModifyIndexItem(IndexListVM indexListVM, IndexItemVM indexItem, InterfacesLibrary.SharedNS.ICommonWithId icommonWithId)
        {
            base.Event_ModifyIndexItem(indexListVM, indexItem, icommonWithId);
            MenuPath3 mp3 = icommonWithId as MenuPath3;

            mp3.IsNullThrowException("Unable to unbox");
            //send in a MenuPathMain that is a part of this MenuPath3
            MenuPathMain mpm = mp3.MenuPathMains.FirstOrDefault();

            indexItem.MenuManager = new MenuManager(mpm, null, null, MenuENUM.EditMenuPath3, BreadCrumbManager, null, UserId, indexListVM.MenuManager.ReturnUrl, UserName);


            indexItem.MenuManager.PictureAddresses = GetCurrItemsPictureList(mp3);
        }
Пример #14
0
        public ShopVM Setup_Shop_For_Edit_Get(string returnUrl, string productId)
        {
            productId.IsNullOrWhiteSpaceThrowException("productId");
            returnUrl.IsNullOrWhiteSpaceThrowException("returnUrl");

            //locate the shop
            Product product = ProductBiz.Find(productId);

            product.IsNullThrowException("product");

            //now we have the shop...
            MenuPathMain menuPathMain = product.MenuPathMains_Fixed.FirstOrDefault();

            menuPathMain.IsNullThrowException("menuPathMain");
            string menuPathMainId = menuPathMain.Id;

            menuPathMainId.IsNullOrWhiteSpaceThrowException("menuPathMainId");


            List <string> shopNames    = getShopNamesForCurrUser();
            int           noOfMonths   = 1;
            decimal       ratePerMonth = getShopRatePerMonth();
            decimal       totalAmount  = ratePerMonth * noOfMonths;

            CashDistributionEngine cashDistributionEnginge = get_CashDistributionEngineAndCheckBalance(totalAmount, true);

            string explaintion = string.Format("{0}. All your products will be collected and will be shown in your shop. Note, every shop must have a unique name and will be created in its own area. This shop will be created in: ", cashDistributionEnginge.Message);

            AddressStringWithNames customerAddress = getDefaultCustomerAddress();

            ShopVM shopCreate = new ShopVM(
                product.Id,
                product.Name,
                explaintion,
                noOfMonths,
                ratePerMonth,
                returnUrl,
                shopNames,
                menuPathMain,
                customerAddress,
                product.MiscFiles_Fixed);

            shopCreate.Id = product.Id;

            return(shopCreate);
        }
Пример #15
0
        /// <summary>
        /// This adds all the selected Menu Paths.
        /// </summary>
        /// <param name="iproduct"></param>
        private void addSelectedMenuPathMain(IProduct iproduct)
        {
            Product product = iproduct as Product;

            product.IsNullThrowException("Product could not be boxed.");

            List <CheckBoxItem> selectedPaths = product.CheckedBoxesList.Where(x => x.IsTrue == true).ToList();

            //there are none to add
            if (selectedPaths.IsNullOrEmpty())
            {
                return;
            }

            if (product.MenuPathMains.IsNull())
            {
                product.MenuPathMains = new List <MenuPathMain>();
            }


            //Now add the selected paths to the product.
            foreach (var cbi in selectedPaths)
            {
                //first check to see if the selected path is part of the product.
                MenuPathMain mpm = product.MenuPathMains.FirstOrDefault(x => x.Id == cbi.Id);

                //Path has been found. It is already a part of the product.
                if (!mpm.IsNull())
                {
                    continue;
                }


                mpm = MenuPathMainBiz.FindAll().FirstOrDefault(x => x.Id == cbi.Id);
                mpm.IsNullThrowException("Main path not found! Programming error.");

                product.MenuPathMains.Add(mpm);
                mpm.Products.Add(product);

                Update(product);
                MenuPathMainBiz.Update(mpm);
            }
        }
Пример #16
0
        private List <string> getShopNamesForCurrUser()
        {
            Owner currUserOwner = OwnerBiz.GetPlayerFor(UserId);

            currUserOwner.IsNullThrowException("You must be authourized to sell to continue");

            List <Product> shops     = ProductBiz.FindAll().Where(x => x.OwnerId == currUserOwner.Id).ToList();
            List <string>  shopNames = new List <string>();

            if (shops.IsNullOrEmpty())
            {
            }
            else
            {
                foreach (Product shop in shops)
                {
                    string name = string.Format("{0} NO Path. This will not show. Expires: {1}, Is Expired? {2}",
                                                shop.FullName(),
                                                shop.ShopExpiryDate.Date_NotNull_Min.ToLongDateString(),
                                                shop.IsShopExpired ? "Yes" : "No");

                    MenuPathMain mpm = shop.MenuPathMains.FirstOrDefault();

                    if (mpm.IsNull())
                    {
                    }
                    else
                    {
                        name = string.Format("{0} - {1} - {2} - {3} expires: {4}, Is Expired? {5}",
                                             mpm.MenuPath1.FullName(),
                                             mpm.MenuPath2.FullName(),
                                             mpm.MenuPath3.FullName(),
                                             shop.FullName(),
                                             shop.ShopExpiryDate.Date_NotNull_Min.ToLongDateString(),
                                             shop.IsShopExpired ? "Yes" : "No");
                    }


                    shopNames.Add(name);
                }
            }
            return(shopNames);
        }
Пример #17
0
        /// <summary>
        /// This removes all the unselected Menupaths from the product.
        /// </summary>
        /// <param name="product"></param>
        private static void removeUnselectedMenuPaths(IProduct product)
        {
            //Nothing to remove.
            if (product.MenuPathMains.IsNullOrEmpty())
            {
                return;
            }


            //get all the ids of the unselected MenuPaths
            var emptyPaths = product
                             .CheckedBoxesList
                             .Where(x => x.IsTrue == false)
                             .Select(x => x.Id)
                             .ToList();

            //get all the ids of the current MenuPaths
            var currMenuPathsInProduct = product.MenuPathMains.Select(x => x.Id);

            //there is something to delete
            if (!currMenuPathsInProduct.IsNull())
            {
                List <string> currMpmLst = new List <string>();
                foreach (string s in currMenuPathsInProduct)
                {
                    currMpmLst.Add(s);
                }

                foreach (var id in currMpmLst)
                {
                    //If found in the unselected... remove it.
                    if (emptyPaths.Contains(id))
                    {
                        MenuPathMain mpm = product.MenuPathMains.FirstOrDefault(x => x.Id == id);
                        mpm.IsNullThrowException("Menu Path was not found. Programming error.");
                        product.MenuPathMains.Remove(mpm);
                        mpm.Products.Remove((Product)product);
                    }
                }
            }
        }
Пример #18
0
        private void MakeName(MenuPathMain entity)
        {
            MenuPath1 menu1;
            MenuPath2 menu2;
            MenuPath3 menu3;

            if (!entity.MenuPath1Id.IsNullOrWhiteSpace())
            {
                menu1 = _menupath1Biz.Find(entity.MenuPath1Id);
            }
            else
            {
                menu1 = entity.MenuPath1;
            }

            if (!entity.MenuPath2Id.IsNullOrWhiteSpace())
            {
                menu2 = _menupath2Biz.Find(entity.MenuPath2Id);
            }
            else
            {
                menu2 = entity.MenuPath2;
            }

            if (!entity.MenuPath3Id.IsNullOrWhiteSpace())
            {
                menu3 = _menupath3Biz.Find(entity.MenuPath3Id);
            }
            else
            {
                menu3 = entity.MenuPath3;
            }


            menu1.IsNullThrowException();
            menu2.IsNullThrowException();
            menu3.IsNullThrowException();

            entity.Name = entity.MakeName(menu1.Name, menu2.Name, menu3.Name);
        }
Пример #19
0
        //this would be same as the MenuPathMain
        private void getPeopleFromMp3Etc(MenuPathMain mpm)
        {
            mpm.IsNullThrowExceptionArgument("mpm");
            mpm.MenuPath3Id.IsNullOrWhiteSpaceThrowException("MenuPath3 is null");

            if (mpm.Products_Fixed.IsNullOrEmpty())
            {
                return;
            }

            foreach (var product in mpm.Products_Fixed)
            {
                getPeopleFromProductEtc(product);
            }


            //get the likes
            MenuPath1 mp1 = mpm.MenuPath1;

            if (!mp1.LikeUnlikes.IsNullOrEmpty())
            {
                AddLikes(mp1.LikeUnlikes);
            }


            MenuPath2 mp2 = mpm.MenuPath2;

            if (!mp2.LikeUnlikes.IsNullOrEmpty())
            {
                AddLikes(mp2.LikeUnlikes);
            }


            MenuPath3 mp3 = mpm.MenuPath3;

            if (!mp3.LikeUnlikes.IsNullOrEmpty())
            {
                AddLikes(mp3.LikeUnlikes);
            }
        }
Пример #20
0
        private async Task <List <ICommonWithId> > indexProduct_DataListAsync(ControllerIndexParams parms)
        {
            //get the menupathMain
            MenuPathMain mpm = await FindAsync(parms.MenuPathMainId);

            mpm.IsNullThrowException("Menu Path does note exist. Something is wrong.");

            //Get all the products listed by it
            List <Product> listOfProducts = mpm.Products_Fixed_And_Approved;

            //update the count of Menu3Path
            MenuPath3 mp3 = MenuPathMainBiz.MenuPath3Biz.FindAll().FirstOrDefault(x => x.Id == mpm.MenuPath3Id);

            if (!mp3.IsNull())
            {
                if (!UserId.IsNullOrWhiteSpace())
                {
                    mpm.NoOfVisits.AddOne(UserId, UserName);
                    MenuPathMainBiz.Update(mpm);

                    //these can be wrng if they also describe other paths
                    //this is how many times this particular picture has been clicked

                    mp3.NoOfVisits.AddOne(UserId, UserName);
                    await MenuPathMainBiz.MenuPath3Biz.UpdateAndSaveAsync(mp3);
                }
            }



            if (listOfProducts.IsNullOrEmpty())
            {
                return(null);
            }


            List <ICommonWithId> pclst = listOfProducts.Cast <ICommonWithId>().ToList();

            return(pclst);
        }
Пример #21
0
        public override void BusinessRulesFor(ControllerCreateEditParameter parm)
        {
            if (IsCreate)
            {
                Product product = Product.Unbox(parm.Entity);
                product.IsUnApproved = false;

                Owner owner = OwnerBiz.GetPlayerFor(UserId);
                owner.IsNullThrowException("You must first become a seller. Go to ' I Want To...' to become a seller.");

                product.OwnerId = owner.Id;

                if (owner.Shops.IsNull())
                {
                    owner.Shops = new List <Product>();
                }

                owner.Shops.Add(product);


                product.MainMenuIdForShop.IsNullOrWhiteSpaceThrowException();
                MenuPathMain mpm = MenuPathMainBiz.Find(product.MainMenuIdForShop);

                mpm.IsNullThrowException();
                if (mpm.Products.IsNull())
                {
                    mpm.Products = new List <Product>();
                }
                if (product.MenuPathMains.IsNull())
                {
                    product.MenuPathMains = new List <MenuPathMain>();
                }
                mpm.Products.Add(product);
                product.MenuPathMains.Add(mpm);
            }

            base.BusinessRulesFor(parm);
        }
Пример #22
0
        //public void DeleteFeature(ProductFeatureDeleteModel productFeatureDeleteModel)
        //{
        //    productFeatureDeleteModel.SelfCheckIdsAndReturnOnly();

        //    ProductFeature productFeature = ProductFeatureBiz.Find(productFeatureDeleteModel.ProductFeatureId);
        //    productFeature.IsNullThrowException("productFeature");

        //    Product product = Find(productFeatureDeleteModel.ProductId);
        //    product.IsNullThrowException("product");



        //    productFeature.Products.Remove(product);
        //    product.ProductFeatures.Remove(productFeature);
        //    SaveChanges();
        //}


        public void FixMenuPaths(ControllerIndexParams parm)
        {
            if (parm.MenuPathMainId.IsNullOrWhiteSpace())
            {
                return;
            }

            parm.Entity.IsNullThrowExceptionArgument("Entity");


            string  menuPathMainId = parm.MenuPathMainId;
            Product product        = parm.Entity as Product;

            product.IsNullThrowException("product");

            //get the menuPath
            MenuPathMain mpm = MenuPathMainBiz.Find(menuPathMainId);

            mpm.IsNullThrowException("mpm");

            product.MenuPathMains.Add(mpm);
            product.MainMenuIdForShop = mpm.Id;
        }
Пример #23
0
        private void getMenuPaths(MenuPathMain entity)
        {
            entity.MenuPath1Id.IsNullOrWhiteSpaceThrowException();
            entity.MenuPath2Id.IsNullOrWhiteSpaceThrowException();
            entity.MenuPath3Id.IsNullOrWhiteSpaceThrowException();

            if (entity.MenuPath1.IsNull())
            {
                entity.MenuPath1 = _menupath1Biz.Find(entity.MenuPath1Id);
                entity.MenuPath1.IsNullThrowException();
            }

            if (entity.MenuPath2.IsNull())
            {
                entity.MenuPath2 = _menupath2Biz.Find(entity.MenuPath2Id);
                entity.MenuPath2.IsNullThrowException();
            }

            if (entity.MenuPath3.IsNull())
            {
                entity.MenuPath3 = _menupath3Biz.Find(entity.MenuPath3Id);
                entity.MenuPath3.IsNullThrowException();
            }
        }
Пример #24
0
        //This supplies a dummy MenuPathMain for the Back to List in the Create.
        protected IMenuManager makeMenuManager(ControllerIndexParams parm)
        {
            MenuPathMain mpm = null;
            Product      p   = null;
            ProductChild pc  = null;

            switch (parm.MenuEnum)
            {
            case EnumLibrary.EnumNS.MenuENUM.IndexMenuPath2:
            case EnumLibrary.EnumNS.MenuENUM.IndexMenuPath3:
            case EnumLibrary.EnumNS.MenuENUM.IndexMenuProduct:

                parm.MenuPathMainId.IsNullOrWhiteSpaceThrowException();
                string mpmId = parm.MenuPathMainId;
                mpm = Find(mpmId);
                mpm.IsNullThrowException();
                break;

            case EnumLibrary.EnumNS.MenuENUM.IndexMenuProductChild:

                parm.ProductId.IsNullOrWhiteSpaceThrowException();
                string pId = parm.ProductId;
                p = ProductBiz.Find(pId);
                p.IsNullThrowException();
                break;

            case EnumLibrary.EnumNS.MenuENUM.IndexMenuProductChildLandingPage:

                parm.ProductChildId.IsNullOrWhiteSpaceThrowException();
                string productChildId = parm.ProductChildId;
                pc = ProductChildBiz.Find(productChildId);
                pc.IsNullThrowException();

                //add the features
                pc.AllFeatures = ProductChildBiz.Get_All_ProductChild_Features_For(pc);
                break;

            case EnumLibrary.EnumNS.MenuENUM.IndexMenuPath1:
            case EnumLibrary.EnumNS.MenuENUM.EditMenuPath1:
            case EnumLibrary.EnumNS.MenuENUM.EditMenuPath2:
            case EnumLibrary.EnumNS.MenuENUM.EditMenuPath3:
            case EnumLibrary.EnumNS.MenuENUM.EditMenuPathMain:
            case EnumLibrary.EnumNS.MenuENUM.EditMenuProduct:
            case EnumLibrary.EnumNS.MenuENUM.EditMenuProductChild:
            case EnumLibrary.EnumNS.MenuENUM.CreateMenuPath1:
            case EnumLibrary.EnumNS.MenuENUM.CreateMenuPath2:
            case EnumLibrary.EnumNS.MenuENUM.CreateMenuPath3:
            case EnumLibrary.EnumNS.MenuENUM.CreateMenuPathMenuPathMain:
            case EnumLibrary.EnumNS.MenuENUM.CreateMenuProduct:
            case EnumLibrary.EnumNS.MenuENUM.CreateMenuProductChild:
            default:
                break;
            }

            MenuManager mm = new MenuManager(mpm, p, pc, parm.MenuEnum, parm.BreadCrumbManager, parm.LikeUnlikeCounter, UserId, parm.ReturnUrl, UserName);

            mm.BreadCrumbManager = parm.BreadCrumbManager;
            //mm.IndexMenuVariables.IsAdmin = UserBiz.IsAdmin(UserId);


            if (!UserId.IsNullOrWhiteSpace())
            {
                Person person = CashTrxBiz.PersonBiz.GetPersonForUserId(UserId);
                if (person.IsNull())
                {
                    //mm.UserMoneyAccount = new UserMoneyAccount();
                }
                else
                {
                    bool isBank = BankBiz.IsBanker_User(UserId);
                    //swithched off to get rid of error. MAY NEED IT BACK!
                    //mm.UserMoneyAccount = MoneyAccountForPerson(person.Id, isBank);
                }
            }


            return(mm as IMenuManager);
        }
Пример #25
0
        /// <summary>
        /// The Menu will always run the MenuBiz.
        /// We do not care about the MenuManager in the ICommonWithId level. That is used in Create/Edit
        /// We need to load the MenuManager with the correct MainMenuPath so that it can be used in the _IndexMiddlePart - TiledPictures.cshtml
        /// We cant use the one in the list because that is a single one and the one that is used in the itme needs to have the
        /// MenuPath1 id. Moreover, the Id of the IndexItem is MenuPathMainId, so it is of no use.
        /// I want the menu's to be dimmed if they have no products. Moreover, The pictures from products need to bubble up to the top, at least 5...
        /// </summary>
        /// <param name="indexListVM"></param>
        /// <param name="indexItem"></param>
        /// <param name="icommonWithId"></param>
        public override void Event_ModifyIndexItem(IndexListVM indexListVM, IndexItemVM indexItem, ICommonWithId icommonWithId)
        {
            //The icommonWithId is the item that is running in the Forloop in the calling procedure
            //The icommonWithId comes here for the first 3 menus as a MenuPathMain item.
            //Then on the 4th it comes as a product.
            //You must select the correct MenuState Here as well
            base.Event_ModifyIndexItem(indexListVM, indexItem, icommonWithId);
            int returnNoOfPictures = MenuPath1.MaxNumberOfPicturesInMenu() + 1;


            MenuPathMain mpm          = icommonWithId as MenuPathMain;
            ProductChild productChild = icommonWithId as ProductChild;
            Product      product      = icommonWithId as Product;


            LikeUnlikeParameters likeUnlikeCounter;
            //UploadedFile uf;
            List <string> pictureAddresses = new List <string>();
            List <string> currPcs          = new List <string>();

            //List<string> lstOfPictures = new List<string>();
            //string theUserId = indexListVM.UserId ?? "";
            string theUserId = UserId;



            MenuEnumForDefaultPicture = indexListVM.MenuManager.MenuState.MenuEnum;
            switch (indexListVM.MenuManager.MenuState.MenuEnum)
            {
            case MenuENUM.IndexMenuPath1:
                mpm.IsNullThrowException();
                mpm.MenuPath1.IsNullThrowException();

                //get the likes and unlikes for MenuPath1
                likeUnlikeCounter            = LikeUnlikeBiz.Count(mpm.MenuPath1.Id, null, null, null, null, theUserId, false);
                likeUnlikeCounter.KindOfLike = "Event_ModifyIndexItem.MenuENUM.IndexMenuPath1";

                indexItem.MenuManager = new MenuManager(mpm, product, productChild, MenuENUM.IndexMenuPath1, BreadCrumbManager, likeUnlikeCounter, UserId, indexListVM.MenuManager.ReturnUrl, UserName);

                indexItem.PictureViews = mpm.MenuPath1.NoOfVisits.Amount;

                //we need to change the image address to image of MenuPath1

                currPcs          = GetCurrItemsPictureList(mpm.MenuPath1 as IHasUploads);
                pictureAddresses = picturesForMenuPath(mpm.MenuPath1);

                //pictureAddresses = joinCurrPicsAndPictureAddresses(pictureAddresses, currPcs);

                if (!currPcs.IsNullOrEmpty())
                {
                    pictureAddresses = pictureAddresses.Concat(currPcs).ToList();
                }

                indexItem.Name               = mpm.MenuPath1.FullName();
                indexItem.Description        = mpm.MenuPath1.DetailInfoToDisplayOnWebsite;
                indexItem.HasProductsForSale = mpm.HasLiveProductChildren;
                indexItem.NoOfItems          = mpm.NoOfItems;
                indexItem.NoOfShops          = mpm.NoOfShops;
                break;


            case MenuENUM.IndexMenuPath2:
                mpm.IsNullThrowException();
                mpm.MenuPath2.IsNullThrowException();
                indexItem.Description = mpm.MenuPath2.DetailInfoToDisplayOnWebsite;

                //uf = mpm.MenuPath2.MiscFiles.FirstOrDefault(x => !x.MetaData.IsDeleted);
                //getPictureList(indexItem, mpm.MenuPath2);

                //indexItem.ImageAddressStr = getImage(uf);
                indexItem.Name               = mpm.MenuPath2.FullName();
                likeUnlikeCounter            = LikeUnlikeBiz.Count(null, mpm.MenuPath2.Id, null, null, null, theUserId, false);
                likeUnlikeCounter.KindOfLike = "Event_ModifyIndexItem.MenuENUM.IndexMenuPath2";
                indexItem.MenuManager        = new MenuManager(mpm, product, productChild, MenuENUM.IndexMenuPath2, BreadCrumbManager, likeUnlikeCounter, UserId, indexListVM.MenuManager.ReturnUrl, UserName);


                indexItem.CompleteMenuPathViews = getMp2Count(mpm);
                indexItem.PictureViews          = mpm.MenuPath2.NoOfVisits.Amount;

                indexItem.HasProductsForSale = mpm.HasLiveProductChildren;
                indexItem.NoOfItems          = mpm.NoOfItems;
                indexItem.NoOfShops          = mpm.NoOfShops;

                currPcs          = GetCurrItemsPictureList(mpm.MenuPath2 as IHasUploads);
                pictureAddresses = picturesForMenuPath(mpm.MenuPath1, mpm.MenuPath2);

                //pictureAddresses = joinCurrPicsAndPictureAddresses(pictureAddresses, currPcs);


                break;



            case MenuENUM.IndexMenuPath3:
                mpm.IsNullThrowException();
                //mpm.MenuPath3.IsNullThrowException(""); //this means there are no menu 3s. This is not allowed.
                if (mpm.MenuPath3.IsNull())
                {
                    return;
                }


                indexItem.Description = mpm.MenuPath3.DetailInfoToDisplayOnWebsite;
                //uf = mpm.MenuPath3.MiscFiles.FirstOrDefault(x => !x.MetaData.IsDeleted);

                //indexItem.ImageAddressStr = getImage(uf);
                //getPictureList(indexItem, mpm.MenuPath3);

                indexItem.Name    = mpm.MenuPath3.FullName();
                likeUnlikeCounter = LikeUnlikeBiz.Count(null, null, mpm.MenuPath3.Id, null, null, theUserId, false);

                likeUnlikeCounter.KindOfLike = "Event_ModifyIndexItem.MenuENUM.IndexMenuPath3";
                indexItem.MenuManager        = new MenuManager(mpm, product, productChild, MenuENUM.IndexMenuPath3, BreadCrumbManager, likeUnlikeCounter, UserId, indexListVM.MenuManager.ReturnUrl, UserName);

                indexItem.PictureViews          = mpm.MenuPath3.NoOfVisits.Amount;
                indexItem.CompleteMenuPathViews = mpm.NoOfVisits.Amount;

                indexItem.HasProductsForSale = mpm.HasLiveProductChildren;

                indexItem.NoOfItems = mpm.NoOfItems;
                indexItem.NoOfShops = mpm.NoOfShops;


                currPcs          = GetCurrItemsPictureList(mpm.MenuPath3 as IHasUploads);
                pictureAddresses = picturesForMenuPath(mpm);
                //pictureAddresses = joinCurrPicsAndPictureAddresses(pictureAddresses, currPcs);


                break;



            case MenuENUM.IndexMenuProduct:     //Products are coming
                product.IsNullThrowException();
                indexItem.Description = product.DetailInfoToDisplayOnWebsite;

                //uf = product.MiscFiles.FirstOrDefault(x => !x.MetaData.IsDeleted);

                likeUnlikeCounter            = LikeUnlikeBiz.Count(null, null, null, product.Id, null, theUserId, false);
                likeUnlikeCounter.KindOfLike = "Event_ModifyIndexItem.MenuENUM.IndexMenuProduct";
                indexItem.MenuManager        = new MenuManager(mpm, product, productChild, MenuENUM.IndexMenuProduct, BreadCrumbManager, likeUnlikeCounter, UserId, indexListVM.MenuManager.ReturnUrl, UserName);

                currPcs = GetCurrItemsPictureList(product as IHasUploads);
                if (product.IsShop)
                {
                    pictureAddresses = getShopPictures(product);
                }
                else
                {
                    pictureAddresses = picturesForProducts(product);
                }


                indexItem.MenuManager.PictureAddresses = pictureAddresses;

                indexItem.PictureViews          = product.NoOfVisits.Amount;
                indexItem.CompleteMenuPathViews = product.NoOfVisits.Amount;

                indexItem.HasProductsForSale = product.HasLiveProductChildren;
                indexItem.NoOfItems          = product.ProductChildren_Fixed_Not_Hidden.Count;

                markUserAsOwnerOfShop(indexItem, product);
                indexItem.IsShop = product.IsShop;
                if (indexItem.IsShopAndOwnerOfShop)
                {
                    indexItem.ShopExpiresStr = ExpiryDateInNoOfDays(product.ShopExpiryDate.Date_NotNull_Max);
                }
                break;


            case MenuENUM.IndexMenuProductChild:
                productChild.IsNullThrowException();
                indexItem.Description            = productChild.DetailInfoToDisplayOnWebsite;
                indexItem.IsTokenPaymentAccepted = productChild.IsNonRefundablePaymentAccepted;
                indexItem.IsHidden = productChild.Hide;

                likeUnlikeCounter            = LikeUnlikeBiz.Count(null, null, null, null, productChild.Id, theUserId, false);
                likeUnlikeCounter.KindOfLike = "Event_ModifyIndexItem.MenuENUM.IndexMenuProductChild";
                indexItem.MenuManager        = new MenuManager(mpm, product, productChild, MenuENUM.IndexMenuProductChild, BreadCrumbManager, likeUnlikeCounter, UserId, indexListVM.MenuManager.ReturnUrl, UserName);

                Person person = UserBiz.GetPersonFor(UserId);
                if (!person.IsNull())
                {
                    string userPersonId         = person.Id;
                    string productChildPersonId = productChild.Owner.PersonId;
                    indexItem.MenuManager.IndexMenuVariables.updateRequiredProperties(userPersonId, productChildPersonId);
                }

                //get the pictures list from the productChild
                currPcs = GetCurrItemsPictureList(productChild);

                ////if none are available get them from the product
                //if (pictureAddresses.IsNullOrEmpty())
                //{
                //    productChild.Product.IsNullThrowException();
                //    pictureAddresses = GetCurrItemsPictureList(productChild.Product);

                //}

                indexItem.PictureViews          = productChild.NoOfVisits.Amount;
                indexItem.CompleteMenuPathViews = productChild.NoOfVisits.Amount;

                indexItem.Price = productChild.Sell.SellPrice;
                break;


            case MenuENUM.EditMenuPath1:
            case MenuENUM.EditMenuPath2:
            case MenuENUM.EditMenuPath3:
            case MenuENUM.EditMenuPathMain:
            case MenuENUM.EditMenuProduct:
            case MenuENUM.EditMenuProductChild:
            case MenuENUM.CreateMenuPath1:
            case MenuENUM.CreateMenuPath2:
            case MenuENUM.CreateMenuPath3:
            case MenuENUM.CreateMenuPathMenuPathMain:
            case MenuENUM.CreateMenuProduct:
            case MenuENUM.CreateMenuProductChild:
            default:
                likeUnlikeCounter            = LikeUnlikeBiz.Count(null, null, null, null, null, theUserId, false);
                likeUnlikeCounter.KindOfLike = "Event_ModifyIndexItem.Default";

                break;
            }



            pictureAddresses = joinCurrPicsAndPictureAddresses(pictureAddresses, currPcs);

            string startSort = getStartSort(indexItem, indexListVM);

            indexItem.Input1SortString = startSort + indexItem.Input1SortString;
            indexItem.Input2SortString = startSort + indexItem.Input2SortString;
            indexItem.Input3SortString = startSort + indexItem.Input3SortString;

            if (pictureAddresses.IsNullOrEmpty())
            {
                pictureAddresses = GetDefaultPicture();
            }

            indexItem.MenuManager.PictureAddresses = pictureAddresses;


            indexItem.MenuManager.LikeUnlikesCounter = likeUnlikeCounter;
            indexItem.MenuManager.BreadCrumbManager  = indexListVM.MenuManager.BreadCrumbManager;

            if (!UserId.IsNullOrWhiteSpace())
            {
                Person person = UserBiz.GetPersonFor(UserId);
                person.IsNullThrowException("person");
                indexItem.MenuManager.UserPersonId = person.Id;
            }
        }
Пример #26
0
        private async Task <List <ICommonWithId> > indexMenuPath2_DataListAsync(ControllerIndexParams parms)
        {
            parms.MenuPathMainId.IsNullOrWhiteSpaceThrowException();
            MenuPathMain mpm = await FindAsync(parms.MenuPathMainId);

            mpm.IsNullThrowException("Main path not found.");

            //===========================================
            List <MenuPathMain> mpms_Distinct_With_Live_Products_And_Shops = get_All_Live_Products_And_Shops();
            //===========================================

            var allMenuPathMain = await FindAllAsync();

            var allMenuPathMainWithMenuPath1 = allMenuPathMain.Where(x => x.MenuPath1Id == mpm.MenuPath1Id).ToList();


            //update the count of Menu1Path
            MenuPath1 mp1 = MenuPathMainBiz.MenuPath1Biz.FindAll().FirstOrDefault(x => x.Id == mpm.MenuPath1Id);

            if (!mp1.IsNull())
            {
                if (!UserId.IsNullOrWhiteSpace())
                {
                    mp1.NoOfVisits.AddOne(UserId, UserName);
                    await MenuPathMainBiz.MenuPath1Biz.UpdateAndSaveAsync(mp1);
                }
            }

            List <string> listOfMenuPath2Ids = UniqueListOfMenuPath2_IDs(allMenuPathMainWithMenuPath1);

            if (listOfMenuPath2Ids.IsNullOrEmpty())
            {
                return(null);
            }

            List <ICommonWithId> mpmlst = new List <ICommonWithId>();

            foreach (var mp2Id in listOfMenuPath2Ids)
            {
                MenuPathMain mpmInner = allMenuPathMainWithMenuPath1
                                        .Where(x => x.MenuPath2Id == mp2Id)
                                        .FirstOrDefault();

                if (!mpmInner.IsNull())
                {
                    if (!mpms_Distinct_With_Live_Products_And_Shops.IsNullOrEmpty())
                    {
                        MenuPathMain mpm_liveOne = mpms_Distinct_With_Live_Products_And_Shops
                                                   .FirstOrDefault(x => x.MenuPath1Id == mpmInner.MenuPath1Id && x.MenuPath2Id == mpmInner.MenuPath2Id);
                        if (!mpm_liveOne.IsNull())
                        {
                            mpmInner.HasLiveProductChildren = true;
                            mpmInner.NoOfItems = mpm_liveOne.ProductChildren_Fixed_Not_Hidden.Count;
                            mpmInner.NoOfShops = mpm_liveOne.Product_Shops_Not_Expired.Count;
                        }
                    }

                    mpmlst.Add(mpmInner);
                }
            }

            if (mpmlst.IsNullOrEmpty())
            {
                return(null);
            }

            return(mpmlst);
        }
Пример #27
0
        private void addProducts()
        {
            //get the data
            List <ProductInitializerHelper> dataList = GetDataListForProduct;

            if (!dataList.IsNullOrEmpty())
            {
                foreach (ProductInitializerHelper prodInitHelper in dataList)
                {
                    //check to see if the product exists... if it does continue.
                    Product p = FindByName(prodInitHelper.Name);

                    if (!p.IsNull())
                    {
                        continue;
                    }

                    p              = new Product();
                    p.Name         = prodInitHelper.Name;
                    p.IsUnApproved = false;
                    //p.UomVolume = UomVolumeBiz.FindByName(prodInitHelper.UomVolumeName);
                    //p.UomVolume.IsNullThrowException();

                    //p.UomDimensions = UomLengthBiz.FindByName(prodInitHelper.UomLengthName);
                    //p.UomDimensions.IsNullThrowException();

                    //p.UomWeightActual = UomWeightBiz.FindByName(prodInitHelper.UomShipWeightName);


                    //p.UomWeightListed = UomWeightBiz.FindByName(prodInitHelper.UomWeightListedName);
                    //p.UomWeightListed.IsNullThrowException();

                    //p.UomPurchase = UomQuantityBiz.FindByName(prodInitHelper.UomPurchaseName);
                    //p.UomPurchase.IsNullThrowException();

                    //p.UomSale = UomQuantityBiz.FindByName(prodInitHelper.UomSaleName);
                    //p.UomSale.IsNullThrowException();

                    //p.Dimensions.Height = prodInitHelper.Height;
                    //p.Dimensions.Width = prodInitHelper.Width;
                    //p.Dimensions.Length = prodInitHelper.Length;
                    //p.UomDimensionsId = p.UomDimensions.Id;
                    //p.UomVolumeId = p.UomVolume.Id;
                    //p.UomDimensionsId = p.UomDimensions.Id;
                    //p.WeightActual = prodInitHelper.ShipWeight;
                    //p.UomWeightActualId = p.UomWeightActual.Id;

                    //p.UomWeightListedId = p.UomWeightListed.Id;
                    //p.UomPurchaseId = p.UomPurchase.Id;
                    //p.UomSaleId = p.UomSale.Id;

                    //p.WeightListed = prodInitHelper.WeightListed;
                    //p.Volume = prodInitHelper.ShipVolume;

                    if (ErrorsGlobal.HasErrors)
                    {
                        throw new Exception(ErrorsGlobal.ToString());
                    }



                    #region Menu Path

                    if (prodInitHelper.Menupaths.IsNull())
                    {
                    }
                    else
                    {
                        foreach (MenuPathHelper mph in prodInitHelper.Menupaths)
                        {
                            MenuPathMain mpm = MenuPathMainBiz.FindAll().FirstOrDefault(x =>
                                                                                        x.MenuPath1.Name.ToLower() == mph.MenuPath1Name.ToLower() &&
                                                                                        x.MenuPath2.Name.ToLower() == mph.MenuPath2Name.ToLower() &&
                                                                                        x.MenuPath3.Name.ToLower() == mph.MenuPath3Name.ToLower());

                            if (mpm.IsNull())
                            {
                                continue;
                            }

                            if (p.MenuPathMains.IsNull())
                            {
                                p.MenuPathMains = new List <MenuPathMain>();
                            }

                            p.MenuPathMains.Add(mpm);

                            if (mpm.Products.IsNull())
                            {
                                mpm.Products = new List <Product>();
                            }

                            mpm.Products.Add(p);
                        }
                    }
                    #endregion



                    #region ProductIdentifier
                    if (prodInitHelper.ProductIdentifiers.IsNull())
                    {
                    }
                    else
                    {
                        foreach (string piStr in prodInitHelper.ProductIdentifiers)
                        {
                            ProductIdentifier pi = ProductIdentifierBiz.Find(piStr);

                            if (!pi.IsNull())
                            {
                                throw new Exception(string.Format("Duplicate product Identifier: '{0}'", piStr));
                            }

                            pi = ProductIdentifierBiz.Factory() as ProductIdentifier;

                            pi.Name      = piStr;
                            pi.Product   = p;
                            pi.ProductId = p.Id;

                            if (p.ProductIdentifiers.IsNull())
                            {
                                p.ProductIdentifiers = new List <ProductIdentifier>();
                            }

                            p.ProductIdentifiers.Add(pi);
                        }
                    }
                    #endregion
                    CreateSave_ForInitializeOnly(p);
                }
            }

            AddInitData_ProductChild();
        }
Пример #28
0
        /// <summary>
        /// This returns a unique list of ProductCategory1Ids
        /// </summary>
        /// <returns></returns>
        private async Task <List <ICommonWithId> > IndexMenuPath1_DataListAsync()
        {
            //find all live product children
            //get their products
            //get all shops that are live
            //get all menupaths of shops and products
            //get all menupaths where MenuPath1Id == id


            List <MenuPathMain> mpms_Distinct_With_Live_Products_And_Shops = get_All_Live_Products_And_Shops();
            List <string>       mp1List_Live = UniqueLiveMpm1List(mpms_Distinct_With_Live_Products_And_Shops);
            //=====================================


            //we need to return MenuPathMain List because the Index needs it.
            List <ICommonWithId> pclst = new List <ICommonWithId>();

            List <MenuPathMain> allMenuMain = await FindAllAsync();

            if (allMenuMain.IsNullOrEmpty())
            {
                return(null);
            }

            List <string> listOfMenuPath1Ids = UniqueMenuMainWithMenu1(allMenuMain);

            if (listOfMenuPath1Ids.IsNullOrEmpty())
            {
                return(null);
            }

            foreach (var id in listOfMenuPath1Ids)
            {
                List <MenuPathMain> mpmList = allMenuMain.Where(x => x.MenuPath1Id == id).ToList();
                MenuPathMain        mpm     = mpmList.FirstOrDefault(x => x.MenuPath1Id == id);

                if (mpm.MenuPath1Id.IsNullOrWhiteSpace())
                {
                    continue;
                }

                if (mp1List_Live.Contains(mpm.MenuPath1Id))
                {
                    mpm.HasLiveProductChildren = true;
                }

                if (mpm.HasLiveProductChildren)
                {
                    if (!mpmList.IsNullOrEmpty())
                    {
                        foreach (var mpm_counter in mpmList)
                        {
                            mpm.NoOfItems += mpm_counter.ProductChildren_Fixed_Not_Hidden.Count;
                            mpm.NoOfShops += mpm_counter.Product_Shops_Not_Expired.Count;
                        }
                    }
                }
                pclst.Add(mpm);
            }

            return(pclst);
        }
Пример #29
0
        private void WireUpMessageWithPeople(MenuPathMain mpm, string productId, string productChildId, List <Person> toPeople, Message message, Person fromPerson, MenuENUM menuEnum)
        {
            throw new NotImplementedException();

            //fromPerson.Messages.Add(message);

            //foreach (Person toPerson in toPeople)
            //{
            //    PeopleMessage pm = new PeopleMessage();

            //    pm.MessageId = message.Id;
            //    pm.PersonId = toPerson.Id;

            //    toPerson.MessagesToPeople.Add(pm);
            //    message.ToPeople.Add(pm);
            //}
            //switch (menuEnum)
            //{


            //    case MenuENUM.IndexMenuPath1:
            //        MenuPath1 mp1 = mpm.MenuPath1;
            //        mp1.IsNullThrowException("MenuPath1 not found");

            //        if (mp1.Messages.IsNull())
            //            mp1.Messages = new List<Message>();

            //        mp1.Messages.Add(message);
            //        message.MenuPath1Id = mp1.Id;
            //        break;


            //    case MenuENUM.IndexMenuPath2:
            //        MenuPath2 mp2 = mpm.MenuPath2;
            //        mp2.IsNullThrowException("MenuPath2 not found");

            //        if (mp2.Messages.IsNull())
            //            mp2.Messages = new List<Message>();

            //        mp2.Messages.Add(message);
            //        message.MenuPath2Id = mp2.Id;
            //        break;


            //    case MenuENUM.IndexMenuPath3:
            //        MenuPath3 mp3 = mpm.MenuPath3;
            //        mp3.IsNullThrowException("MenuPath3 not found");

            //        if (mp3.Messages.IsNull())
            //            mp3.Messages = new List<Message>();

            //        mp3.Messages.Add(message);
            //        message.MenuPath3Id = mp3.Id;
            //        break;


            //    case MenuENUM.IndexMenuProduct:
            //        Product product = ProductBiz.Find(productId);
            //        product.IsNullThrowException("Product not found");

            //        if (product.Messages.IsNull())
            //            product.Messages = new List<Message>();

            //        product.Messages.Add(message);
            //        message.MenuPath3Id = product.Id;

            //        break;


            //    case MenuENUM.IndexMenuProductChild:
            //        ProductChild productChild = ProductChildBiz.Find(productChildId);
            //        productChild.IsNullThrowException("Product Child not found");

            //        if (productChild.Messages.IsNull())
            //            productChild.Messages = new List<Message>();

            //        productChild.Messages.Add(message);
            //        message.MenuPath3Id = productChild.Id;
            //        break;


            //    case MenuENUM.IndexDefault:
            //    default:
            //        break;
            //}
        }
Пример #30
0
 private void fixName(MenuPathMain entity)
 {
     entity.Name = entity.MakeName(entity.MenuPath1.Name, entity.MenuPath2.Name, entity.MenuPath3.Name);
 }