コード例 #1
0
ファイル: AddFeature.cs プロジェクト: dovanduy/Library
        private void saveFeature(MenuFeatureModel menuFeatureModel)
        {
            menuFeatureModel.SelfCheck();
            MenuPath1 menuPath1 = Find(menuFeatureModel.ParentId);

            menuPath1.IsNullThrowException("menuPath1");

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

            menuFeature.IsNullThrowException("menuFeature");

            if (menuFeature.MenuPath1s.IsNull())
            {
                menuFeature.MenuPath1s = new List <MenuPath1>();
            }

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

            menuFeature.MenuPath1s.Add(menuPath1);
            menuPath1.MenuFeatures.Add(menuFeature);
            SaveChanges();

            addFeatureToEveryProductWithMenuPath1(menuPath1, menuFeature);
        }
コード例 #2
0
ファイル: Fix.cs プロジェクト: dovanduy/Library
        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);
            }
        }
コード例 #3
0
ファイル: Initialization.cs プロジェクト: dovanduy/Library
        //public override string[] GetDataForStringArrayFormat
        //{
        //    get
        //    {
        //        return MenuPath1Array.DataArray();
        //    }
        //}


        public override void AddInitData()
        {
            MenuPath1ENUM[] dataList = MenuPath1Array.DataArray2();

            dataList.IsNullOrEmptyThrowException("No data");

            for (int i = 0; i < dataList.Length; i++)
            {
                MenuPath1 mp1 = Factory() as MenuPath1;
                mp1.Name          = mp1.CreateNameFromEnum(dataList[i]);
                mp1.MenuPath1Enum = dataList[i];

                bool recordExists   = !FindByName(mp1.Name).IsNull();
                bool recordIsUnkown = mp1.Name.ToLower() == "unknown";

                if (recordIsUnkown)
                {
                    Dal.Detach(mp1);
                    continue;
                }
                if (recordExists)
                {
                    Dal.Detach(mp1);
                    continue;
                }
                CreateSave_ForInitializeOnly(mp1);
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public override void Event_ModifyIndexItem(IndexListVM indexListVM, IndexItemVM indexItem, ICommonWithId icommonWithId)
        {
            base.Event_ModifyIndexItem(indexListVM, indexItem, icommonWithId);
            MenuPath1 mp1 = icommonWithId as MenuPath1;

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

            //mpm.IsNullThrowException("mpm");

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


            indexItem.MenuManager.PictureAddresses = GetCurrItemsPictureList(mp1);
        }
コード例 #6
0
        public override void FixChildEntityForCreate(MenuPath1Feature mp1f)
        {
            mp1f.MenuPath1Id.IsNullOrWhiteSpaceThrowArgumentException("The MenuPath1Id is null in MenuPath1FeatureBiz.FixChildEntityForCreate");

            //get the parent MenuPath1
            MenuPath1 mp1 = MenuPath1Biz.Find(mp1f.MenuPath1Id);

            //Add the feauture to it.
            if (mp1.MenuPath1Features.IsNull())
            {
                mp1.MenuPath1Features = new List <MenuPath1Feature>();
            }

            mp1.MenuPath1Features.Add(mp1f);
            base.FixChildEntityForCreate(mp1f);
        }
コード例 #7
0
ファイル: AddFeature.cs プロジェクト: dovanduy/Library
        public void DeleteFeature(MenuFeatureDeleteModel menuFeatureDeleteModel)
        {
            menuFeatureDeleteModel.SelfCheckIdsAndReturnOnly();

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

            menuFeature.IsNullThrowException("menuFeature");

            MenuPath1 menuPath1 = Find(menuFeatureDeleteModel.MenuPathId);

            menuPath1.IsNullThrowException("menuPath1");



            menuFeature.MenuPath1s.Remove(menuPath1);
            menuPath1.MenuFeatures.Remove(menuFeature);
            SaveChanges();
        }
コード例 #8
0
ファイル: AddFeature.cs プロジェクト: dovanduy/Library
        private void addFeatureToEveryProductWithMenuPath1(MenuPath1 menuPath1, MenuFeature menuFeature)
        {
            //Now add the feature to every product that has menu1 as its path.
            //first find all the menuMains that contain MenuPath1
            if (menuPath1.MenuPathMains.IsNullOrEmpty())
            {
                return;
            }

            List <MenuPathMain> menuPathMainList = menuPath1.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();
        }
コード例 #9
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);
            }
        }
コード例 #10
0
ファイル: AddFeature.cs プロジェクト: dovanduy/Library
        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.

            MenuPath1 menupath1 = Find(model.ParentId);

            menupath1.IsNullThrowException("menupath1");

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

            AddFeature(menuFeatureModel);
        }
コード例 #11
0
ファイル: Uploads.cs プロジェクト: dovanduy/Library
        //private readonly IRepositry<UploadedFile> _uploadFileDAL;

        /// <summary>
        /// This is where all the uploaded Files will be saved
        /// </summary>
        /// <returns></returns>
        //public override string Event_SaveLocationForUploadedFiles()
        //{
        //    return MyConstants.SAVE_LOCATION_PRODUCT_CATEGORY1;
        //}


        public override void AddEntityRecordIntoUpload(UploadedFile uploadFile, MenuPath1 entity, IUserHasUploadsTypeENUM iuserHasUploadsTypeEnum)
        {
            uploadFile.MenuPath1Id = entity.Id;
            uploadFile.MenuPath1   = entity;
        }
コード例 #12
0
        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);
        }
コード例 #13
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;
            }
        }
コード例 #14
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);
        }
コード例 #15
0
ファイル: Initialization.cs プロジェクト: dovanduy/Library
        //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();
        }
コード例 #16
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);
        }
コード例 #17
0
ファイル: Add.cs プロジェクト: dovanduy/Library
        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));
        }