Beispiel #1
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);
        }
Beispiel #2
0
        //public override string[] GetDataForStringArrayFormat
        //{
        //    get
        //    {
        //        return ProductCategoryMainArray.DataArray();
        //    }
        //}


        public override void AddInitData()
        {
            //get the data
            List <MenuPathMainHelper> dataList = new DatastoreNS.MenuPathMainInitilizingDataList().DataList();

            if (!dataList.IsNullOrEmpty())
            {
                foreach (var item in dataList)
                {
                    if (item.MenuPath1.IsNullOrWhiteSpace())
                    {
                        ErrorsGlobal.Add(string.Format("Menu Path 1 '{0}' not found", item.MenuPath1), MethodBase.GetCurrentMethod());
                        throw new Exception(ErrorsGlobal.ToString());
                    }


                    MenuPath1 menu1 = _menupath1Biz.FindByName(item.MenuPath1);
                    MenuPath2 menu2 = _menupath2Biz.FindByName(item.MenuPath2);
                    MenuPath3 menu3 = _menupath3Biz.FindByName(item.MenuPath3);

                    MenuPathMain pcm = new MenuPathMain();

                    pcm.MenuPath1   = menu1;
                    pcm.MenuPath1Id = menu1.Id;

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

                    menu1.MenuPathMains.Add(pcm);



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

                    pcm.MenuPath2   = menu2;
                    pcm.MenuPath2Id = menu2.Id;
                    if (menu2.MenuPathMains.IsNull())
                    {
                        menu2.MenuPathMains = new List <MenuPathMain>();
                    }
                    menu2.MenuPathMains.Add(pcm);

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

                    pcm.MenuPath3   = menu3;
                    pcm.MenuPath3Id = menu3.Id;
                    if (menu3.MenuPathMains.IsNull())
                    {
                        menu3.MenuPathMains = new List <MenuPathMain>();
                    }
                    menu3.MenuPathMains.Add(pcm);

                    CreateSave_ForInitializeOnly(pcm);
                }
            }
            //SaveChanges();
        }