Beispiel #1
0
        public SelectList MenuPath2_SelectList_FilteredFor(MenuPath1ENUM menuPath1Enum)
        {
            var allMenuPathMainsForMp1Lst = FindAllMenuPathMainsFor(menuPath1Enum)
                                            .ToList();

            if (allMenuPathMainsForMp1Lst.IsNull())
            {
                return(new SelectList(null));
            }

            HashSet <string> hashMp2Id = new HashSet <string>();

            foreach (MenuPathMain mpm in allMenuPathMainsForMp1Lst)
            {
                hashMp2Id.Add(mpm.MenuPath2Id);
            }

            if (hashMp2Id.IsNullOrEmpty())
            {
                return(new SelectList(null));
            }

            List <MenuPath2> Mp2Lst = new List <MenuPath2>();

            foreach (var mp2Id in hashMp2Id)
            {
                MenuPath2 mp2 = _menupath2Biz.Find(mp2Id);
                mp2.IsNullThrowException();
                Mp2Lst.Add(mp2);
            }

            SelectList selectList = _menupath2Biz.SelectList_Engine(Mp2Lst.AsQueryable());

            return(selectList);
        }
        private List <string> picturesForMenuPath(MenuPath1 mp1, MenuPath2 mp2)
        {
            //get all menupaths with mp1 and mp2
            mp1.IsNullThrowException();
            mp2.IsNullThrowException();

            List <MenuPathMain> mpmList = MenuPathMainBiz.FindAll().Where(x => x.MenuPath1Id == mp1.Id && x.MenuPath2Id == mp2.Id).ToList();

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

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

            foreach (MenuPathMain mpm in mpmList)
            {
                List <string> picListFromMpm = picturesForMenuPath(mpm);
                if (!picListFromMpm.IsNullOrEmpty())
                {
                    picList = picList.Concat(picListFromMpm).ToList();
                }
            }

            return(picList);
        }
Beispiel #3
0
        private void fixall(GlobalComment gc)
        {
            if (gc.Comment.IsNullOrWhiteSpace())
            {
                return;
            }

            gc.UserId.IsNullOrWhiteSpaceThrowException("User is not logged in");

            if (!gc.UserId.IsNullOrWhiteSpace())
            {
                ApplicationUser user = _userBiz.Find(gc.UserId);
                user.IsNullThrowException();
                //user.GlobalComments.Add(gc);
                gc.Name = UserName;
            }



            if (!gc.MenuPath1Id.IsNullOrWhiteSpace())
            {
                MenuPath1 m1 = _menuPathMainBiz.MenuPath1Biz.Find(gc.MenuPath1Id);
                m1.IsNullThrowException();
                m1.GlobalComments.Add(gc);
                return;
            }


            if (!gc.MenuPath2Id.IsNullOrWhiteSpace())
            {
                MenuPath2 m2 = _menuPathMainBiz.MenuPath2Biz.Find(gc.MenuPath2Id);
                m2.IsNullThrowException();
                m2.GlobalComments.Add(gc);
                return;
            }


            if (!gc.MenuPath3Id.IsNullOrWhiteSpace())
            {
                MenuPath3 m3 = _menuPathMainBiz.MenuPath3Biz.Find(gc.MenuPath3Id);
                m3.IsNullThrowException();
                m3.GlobalComments.Add(gc);
            }


            if (!gc.ProductId.IsNullOrWhiteSpace())
            {
                Product p = _productBiz.Find(gc.ProductId);
                p.IsNullThrowException();
                p.GlobalComments.Add(gc);
            }


            if (!gc.ProductChildId.IsNullOrWhiteSpace())
            {
                ProductChild pc = _productBiz.ProductChildBiz.Find(gc.ProductChildId);
                pc.IsNullThrowException();
                pc.GlobalComments.Add(gc);
            }
        }
Beispiel #4
0
        public void AddFeature(MenuFeatureModel menuFeatureModel)
        {
            //first get the parent
            menuFeatureModel.SelfCheck();

            MenuPath2 menuPath2 = Find(menuFeatureModel.ParentId);

            menuPath2.IsNullThrowException("menuPath2");

            MenuFeature menuFeature = MenuFeatureBiz.Find(menuFeatureModel.FeatureId);

            menuFeature.IsNullThrowException("menuFeature");

            if (menuFeature.MenuPath2s.IsNull())
            {
                menuFeature.MenuPath2s = new List <MenuPath2>();
            }

            if (menuPath2.MenuFeatures.IsNull())
            {
                menuPath2.MenuFeatures = new List <MenuFeature>();
            }

            menuFeature.MenuPath2s.Add(menuPath2);
            menuPath2.MenuFeatures.Add(menuFeature);
            SaveChanges();

            addFeatureToEveryProductWithMenuPath2(menuPath2, menuFeature);
        }
Beispiel #5
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 #6
0
        public override void Event_ModifyIndexItem(IndexListVM indexListVM, IndexItemVM indexItem, InterfacesLibrary.SharedNS.ICommonWithId icommonWithId)
        {
            base.Event_ModifyIndexItem(indexListVM, indexItem, icommonWithId);
            MenuPath2 mp2 = icommonWithId as MenuPath2;

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

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


            indexItem.MenuManager.PictureAddresses = GetCurrItemsPictureList(mp2);
        }
Beispiel #7
0
        public override void FixChildEntityForCreate(MenuPath2Feature mp2f)
        {
            mp2f.MenuPath2Id.IsNullOrWhiteSpaceThrowArgumentException("The MenuPath2Id is null in MenuPath2FeatureBiz.FixChildEntityForCreate");

            //get the parent MenuPath2
            MenuPath2 mp2 = MenuPath2Biz.Find(mp2f.MenuPath2Id);

            //Add the feauture to it.
            if (mp2.MenuPath2Features.IsNull())
            {
                mp2.MenuPath2Features = new List <MenuPath2Feature>();
            }

            mp2.MenuPath2Features.Add(mp2f);
            base.FixChildEntityForCreate(mp2f);
        }
Beispiel #8
0
        public void DeleteFeature(MenuFeatureDeleteModel menuFeatureDeleteModel)
        {
            menuFeatureDeleteModel.SelfCheckIdsAndReturnOnly();

            MenuFeature menuFeature = MenuFeatureBiz.Find(menuFeatureDeleteModel.MenuFeatureId);

            menuFeature.IsNullThrowException("menuFeature");

            MenuPath2 menuPath2 = Find(menuFeatureDeleteModel.MenuPathId);

            menuPath2.IsNullThrowException("menuPath2");



            menuFeature.MenuPath2s.Remove(menuPath2);
            menuPath2.MenuFeatures.Remove(menuFeature);
            SaveChanges();
        }
Beispiel #9
0
        private void addFeatureToEveryProductWithMenuPath2(MenuPath2 menuPath2, MenuFeature menuFeature)
        {
            //Now add the feature to every product that has menu1 as its path.
            //first find all the menuMains that contain MenuPath1
            if (menuPath2.MenuPathMains.IsNullOrEmpty())
            {
                return;
            }

            List <MenuPathMain> menuPathMainList = menuPath2.MenuPathMains.ToList();
            //Now get all the products that have theseMenuPaths as their path.
            HashSet <Product> productHashList = new HashSet <Product>();

            foreach (var menuPathMain in menuPathMainList)
            {
                if (!menuPathMain.Products_Fixed.IsNullOrEmpty())
                {
                    List <Product> menuPathMainProductList = menuPathMain.Products_Fixed.ToList();
                    foreach (var prod in menuPathMainProductList)
                    {
                        productHashList.Add(prod);
                    }
                }
            }

            if (productHashList.IsNullOrEmpty())
            {
                return;
            }

            foreach (var prod2 in productHashList)
            {
                ProductFeature pf = new ProductFeature();
                pf.ProductId     = prod2.Id;
                pf.Product       = prod2;
                pf.MenuFeatureId = menuFeature.Id;
                pf.MenuFeature   = menuFeature;
                pf.Name          = menuFeature.Name;

                ProductFeatureBiz.CreateAndSave(pf);
            }
            SaveChanges();
        }
        //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);
            }
        }
Beispiel #11
0
        public void CreateNewFeature(CreateNewFeatureModel model)
        {
            model.SelfCheck();
            MenuFeature menuFeature = MenuFeatureBiz.FindByName(model.FeatureName);

            if (menuFeature.IsNull())
            {
                menuFeature = MenuFeatureBiz.Factory() as MenuFeature;
                menuFeature.IsNullThrowException("menuFeature");

                menuFeature.Name = model.FeatureName;
                MenuFeatureBiz.CreateAndSave(menuFeature);
            }
            //create the new feature.

            MenuPath2 menupath2 = Find(model.ParentId);

            menupath2.IsNullThrowException("menupath2");

            //taking a short cut.
            MenuFeatureModel menuFeatureModel = new MenuFeatureModel(model.ParentId, "", menuFeature.Id, model.ReturnUrl);

            AddFeature(menuFeatureModel);
        }
Beispiel #12
0
        public bool AddAndSaveComment(GlobalComment gc)
        {
            if (gc.Comment.IsNullOrWhiteSpace())
            {
                return(false);
            }

            gc.UserId.IsNullOrWhiteSpaceThrowException("No user is logged in!");


            if (!gc.MenuPath1Id.IsNullOrWhiteSpace())
            {
                MenuPath1 m1 = _menuPathMainBiz.MenuPath1Biz.Find(gc.MenuPath1Id);
                m1.IsNullThrowException();
                m1.GlobalComments.Add(gc);
            }


            if (!gc.MenuPath2Id.IsNullOrWhiteSpace())
            {
                MenuPath2 m2 = _menuPathMainBiz.MenuPath2Biz.Find(gc.MenuPath2Id);
                m2.IsNullThrowException();
                m2.GlobalComments.Add(gc);
            }


            if (!gc.MenuPath3Id.IsNullOrWhiteSpace())
            {
                MenuPath3 m3 = _menuPathMainBiz.MenuPath3Biz.Find(gc.MenuPath3Id);
                m3.IsNullThrowException();
                m3.GlobalComments.Add(gc);
            }


            if (!gc.ProductId.IsNullOrWhiteSpace())
            {
                Product p = _productBiz.Find(gc.ProductId);
                p.IsNullThrowException();
                p.GlobalComments.Add(gc);
            }


            if (!gc.ProductChildId.IsNullOrWhiteSpace())
            {
                ProductChild pc = _productBiz.ProductChildBiz.Find(gc.ProductChildId);
                pc.IsNullThrowException();
                pc.GlobalComments.Add(gc);
            }

            if (!gc.UserId.IsNullOrWhiteSpace())
            {
                ApplicationUser user = _userBiz.Find(gc.UserId);
                user.IsNullThrowException();
                //user.GlobalComments.Add(gc);
            }

            gc.Name = UserName;

            ControllerCreateEditParameter parm = new ControllerCreateEditParameter();

            parm.Entity = gc as ICommonWithId;

            CreateAndSave(parm);
            return(true);
        }
Beispiel #13
0
        public LikeUnlikeParameters AddLikeAndReturnCount(string menuPath1Id, string menuPath2Id, string menuPath3Id, string productId, string productChildId, string userId, bool isLike, string comment)
        {
            userId.IsNullOrWhiteSpaceThrowException("No user is logged in!");
            Person person = UserBiz.GetPersonFor(userId);

            person.IsNullThrowException("Person");
            string personId = person.Id;

            personId.IsNullOrWhiteSpaceThrowException("personId");

            LikeUnlike likeUnlike = Factory() as LikeUnlike;

            likeUnlike.Initialize(menuPath1Id, menuPath2Id, menuPath3Id, productId, productChildId, personId, isLike, comment);

            if (!menuPath1Id.IsNullOrWhiteSpace())
            {
                likeUnlike.MenuPath1Id = menuPath1Id;
                MenuPath1 m1 = _menuPathMainBiz.MenuPath1Biz.Find(menuPath1Id);
                m1.IsNullThrowException();
                m1.LikeUnlikes.Add(likeUnlike);
            }


            if (!menuPath2Id.IsNullOrWhiteSpace())
            {
                likeUnlike.MenuPath2Id = menuPath2Id;
                MenuPath2 m2 = _menuPathMainBiz.MenuPath2Biz.Find(menuPath2Id);
                m2.IsNullThrowException();
                m2.LikeUnlikes.Add(likeUnlike);
            }


            if (!menuPath3Id.IsNullOrWhiteSpace())
            {
                likeUnlike.MenuPath3Id = menuPath3Id;
                MenuPath3 m3 = _menuPathMainBiz.MenuPath3Biz.Find(menuPath3Id);
                m3.IsNullThrowException();
                m3.LikeUnlikes.Add(likeUnlike);
            }


            if (!productId.IsNullOrWhiteSpace())
            {
                likeUnlike.ProductId = productId;
            }
            else
            {
                productId = null;
            }

            if (!productChildId.IsNullOrWhiteSpace())
            {
                likeUnlike.ProductChildId = productChildId;
            }
            else
            {
                productChildId = null;
            }

            if (!personId.IsNullOrWhiteSpace())
            {
                likeUnlike.PersonId = personId;
                person.IsNullThrowException();
                person.LikeUnlikes.Add(likeUnlike);
            }
            //if it is a like delete the similar dislike. If it is a dislike delete the similar like
            bool relatedOppoisteDeleted = deleteTheRelatedLikeUnlike(menuPath1Id, menuPath2Id, menuPath3Id, productId, productChildId, personId, isLike);

            CreateAndSave(CreateControllerCreateEditParameter(likeUnlike as ICommonWithId));

            return(Count(
                       menuPath1Id,
                       menuPath2Id,
                       menuPath3Id,
                       productId,
                       productChildId,
                       userId,
                       relatedOppoisteDeleted));
        }
Beispiel #14
0
 public override void AddEntityRecordIntoUpload(UploadedFile uploadFile, MenuPath2 entity, IUserHasUploadsTypeENUM iuserHasUploadsTypeEnum)
 {
     uploadFile.MenuPath2Id = entity.Id;
     uploadFile.MenuPath2   = entity;
     ;
 }
Beispiel #15
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();
        }