Пример #1
0
        private void getPeopleFromProductChildOwners(string productChildId)
        {
            productChildId.IsNullOrWhiteSpaceThrowArgumentException("productChildId");
            ProductChild productChild = ProductChildBiz.Find(productChildId);

            getPeopleFromProductChildOwners(productChild);
        }
Пример #2
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);
            }
        }
Пример #3
0
        public void AddInitData_ProductChild()
        {
            //get the data
            List <ProductChildInitializer> dataList = GetDataListForChildProduct;

            if (dataList.IsNullOrEmpty())
            {
                ErrorsGlobal.Add("No data available.", MethodBase.GetCurrentMethod());
                throw new Exception(ErrorsGlobal.ToString());
            }


            foreach (ProductChildInitializer item in dataList)
            {
                ProductChild pc = new ProductChild();

                pc.Name           = item.ProductName;
                pc.Sell.SellPrice = item.SalePrice;
                Product product = FindForName(item.ParentName);
                product.IsNullThrowException();
                pc.ProductId = product.Id;
                pc.Product   = product;
                pc.ShipFromAddressComplex         = AddressComplex.SystemAddress_Complex();
                pc.IsNonRefundablePaymentAccepted = item.IsNonRefundablePaymentAccepted;

                if (product.ProductChildren.IsNull())
                {
                    product.ProductChildren = new List <ProductChild>();
                }

                product.ProductChildren.Add(pc);
                ProductChildBiz.CreateSave_ForInitializeOnly(pc);
            }
        }
Пример #4
0
        private void addProductChildren()
        {
            //get the data
            List <ProductChildInitializer> dataList = GetDataListForProductChild;

            if (dataList.IsNullOrEmpty())
            {
                ErrorsGlobal.Add("No data available.", MethodBase.GetCurrentMethod());
                throw new Exception(ErrorsGlobal.ToString());
            }


            foreach (ProductChildInitializer item in dataList)
            {
                Product p = FindByName(item.ParentName);
                p.IsNullThrowException("Parent Product not found! Programming error.");

                //check for duplicates.
                if (!p.ProductChildren.IsNull())
                {
                    ProductChild pFound = p.ProductChildren.FirstOrDefault(x => x.Name.ToLower() == item.ProductName.ToLower());
                    if (!pFound.IsNull())
                    {
                        continue;
                    }
                }
                ProductChild pc = new ProductChild();
                pc.Name = item.ProductName;

                getUser(item, pc);
                getParent(item, pc);
                getPicture(item, pc);
            }
            SaveChanges();
        }
Пример #5
0
        private void getPicture(ProductChildInitializer item, ProductChild pc)
        {
            IHasUploads pcHasuploads = pc as IHasUploads;

            pc.IsNullThrowException(string.Format("Programming Error. Product Child is not showing as IHasUploads. It is. Currently initializing '{0}'", item.ProductName));

            string originalname        = item.ProductName.RemoveAllSpaces().ToString();
            string relative_SrcPath    = pc.MiscFilesLocation_Initialization();
            string relative_targetPath = pc.MiscFilesLocation(UserName);

            string filenameNoExtention = getFileNameWithoutExtention(relative_SrcPath, originalname);


            if (!imageFileExists(filenameNoExtention))
            {
                return;
            }

            #region Copy File
            string originalnameWithoutExtention = originalname;
            List <UploadedFile> uploadedFileLst = new List <UploadedFile>();

            //copy the actual file to the new spot. We need to do it here so we can get it's new name
            //== COPY FILE
            string newNameWithMappedPathPlusExtention = CopyFile(relative_SrcPath, relative_targetPath, Path.ChangeExtension(originalnameWithoutExtention, ExtentionFound));

            //create the upload file
            UploadedFile uf = new UploadedFile(
                originalnameWithoutExtention,
                Path.GetFileNameWithoutExtension(newNameWithMappedPathPlusExtention),
                ExtentionFound,
                relative_targetPath);

            //add to uploadlist
            uploadedFileLst.Add(uf);

            #endregion
            if (!uploadedFileLst.IsNullOrEmpty())
            {
                foreach (UploadedFile file in uploadedFileLst)
                {
                    file.MetaData.Created.SetToTodaysDate(UserName, UserId);


                    //initializes navigation if it is null

                    //You need to add a refrence here to save the file in the UploadedFile as well.
                    file.ProductChild   = pc;
                    file.ProductChildId = pc.Id;

                    if (pcHasuploads.MiscFiles.IsNull())
                    {
                        pcHasuploads.MiscFiles = new List <UploadedFile>(); //intializing
                    }
                    pcHasuploads.MiscFiles.Add(file);

                    UploadedFileBiz.Create(CreateControllerCreateEditParameter(file as ICommonWithId));
                }
            }
        }
Пример #6
0
        private void AddShippingAddressToOwnerPersonIfItIsNew(ProductChild pc)
        {
            Owner productChildOwner = pc.Owner;

            productChildOwner.IsNullThrowException();
            Person ownerPerson = productChildOwner.Person;

            ownerPerson.IsNullThrowException();
            AddressBiz addressBiz = OwnerBiz.AddressBiz;

            //get the address from the productChild
            AddressComplex shipFromAddressComplexInProductChild = pc.ShipFromAddressComplex;

            shipFromAddressComplexInProductChild.ErrorCheck();

            //if there is no address... there should be an error.
            if (!shipFromAddressComplexInProductChild.Error.IsNullOrWhiteSpace())
            {
                throw new Exception("You need to add the address of where the product is sitting");
            }

            //address is complete.
            //We need to make the unique name from this so that we can check it exists in the db
            AddressMain addressToSave = addressBiz.Factory() as AddressMain;

            addressToSave.LoadFor(shipFromAddressComplexInProductChild);
            addressToSave.Name = addressToSave.MakeUniqueName();
            //locate this address in Person

            //get all the addresses for the ownerPerson
            List <AddressMain> allAddressForOwnerPerson = addressBiz.FindAll().Where(x => x.PersonId == ownerPerson.Id).ToList();

            if (allAddressForOwnerPerson.IsNull())
            {
                //no addresses found. Its empty...
                //so add the new address
                addNewAddress(pc, ownerPerson, addressBiz, addressToSave);
            }
            {
                //addresses have been found
                //we do not update old addresses, we just add new ones, if they change.
                AddressMain addressFound = allAddressForOwnerPerson.FirstOrDefault(x => x.Name.ToLower() == addressToSave.Name.ToLower());

                if (addressFound.IsNull())
                {
                    //the address was not found.
                    //AddressComplex contains a new address
                    //Add it to the person's addresses

                    addNewAddress(pc, ownerPerson, addressBiz, addressToSave);
                }
                //else
                //{
                //    updateAddress(pc, addressBiz, addressToSave);
                //}
            }

            //otherwise do nothing
        }
Пример #7
0
        public override void Event_ModifyIndexItem(IndexListVM indexListVM, IndexItemVM indexItem, ICommonWithId icommonWithId)
        {
            base.Event_ModifyIndexItem(indexListVM, indexItem, icommonWithId);
            ProductChild productChild = ProductChild.Unbox(icommonWithId);

            indexItem.IsHidden = productChild.Hide;
            indexItem.IsTokenPaymentAccepted       = productChild.IsNonRefundablePaymentAccepted;
            indexItem.MenuManager                  = new MenuManager(null, null, productChild, MenuENUM.IndexMenuPath1, BreadCrumbManager, null, UserId, indexListVM.MenuManager.ReturnUrl, UserName);
            indexItem.MenuManager.PictureAddresses = GetCurrItemsPictureList(productChild);
            indexItem.Price = productChild.Sell.SellPrice;
        }
Пример #8
0
        private void AddPhoneNumberToOwnerPersonIfItsNew(ProductChild pc)
        {
            Owner productChildOwner = pc.Owner;

            productChildOwner.IsNullThrowException();
            Person ownerPerson = productChildOwner.Person;

            ownerPerson.IsNullThrowException();

            //check if a phone number has been entered
            pc.ShipFromAddressComplex.Phone.IsNullOrWhiteSpace();
        }
Пример #9
0
        public List <ProductChildFeature> Get_All_ProductChild_Features_For(ProductChild productChild)
        {
            productChild.IsNullThrowExceptionArgument();

            if (productChild.ProductChildFeatures.IsNullOrEmpty())
            {
                return(null);
            }

            List <ProductChildFeature> productChildFeatures = productChild.ProductChildFeatures.OrderBy(x => x.Name).ToList();

            return(productChildFeatures);
        }
Пример #10
0
        public override void AddEntityRecordIntoUpload(UploadedFile uploadedFile, ProductChild entity, IUserHasUploadsTypeENUM iuserHasUploadsTypeEnum)
        {
            ///    uploadFile.FileDoc = filedoc;
            ///    uploadFile.Id = filedoc.Id;

            uploadedFile.ProductChild   = entity;
            uploadedFile.ProductChildId = entity.Id;
            if (entity.MiscFiles.IsNull())
            {
                entity.MiscFiles = new List <UploadedFile>();
            }
            entity.MiscFiles.Add(uploadedFile);
        }
Пример #11
0
        public override IQueryable <ProductChild> GetDataToCheckDuplicateName(ProductChild productChild)
        {
            var data = base.GetDataToCheckDuplicateName(productChild);

            string ownerId = productChild.OwnerId;

            ownerId.IsNullOrWhiteSpaceThrowException("OwnerId");

            var dataForOwner = data.Where(x => x.OwnerId == ownerId &&
                                          x.IdentificationNumber == productChild.IdentificationNumber &&
                                          x.SerialNumber == productChild.SerialNumber);

            return(dataForOwner);
        }
Пример #12
0
        public override void ErrorCheck(ControllerCreateEditParameter parm)
        {
            base.ErrorCheck(parm);

            ProductChild productChild = parm.Entity as ProductChild;

            //address should exist.
            productChild.ShipFromAddressComplex.ErrorCheck();

            if (!productChild.ShipFromAddressComplex.Error.IsNullOrWhiteSpace())
            {
                throw new Exception(productChild.ShipFromAddressComplex.Error);
            }
        }
Пример #13
0
        private static void addNewAddress(ProductChild pc, Person ownerPerson, AddressBiz addressBiz, AddressMain addressToSave)
        {
            pc.ShipFromAddressId = addressToSave.Id;

            if (addressToSave.ProductChilds.IsNull())
            {
                addressToSave.ProductChilds = new List <ProductChild>();
            }

            addressToSave.ProductChilds.Add(pc);

            ownerPerson.Addresses.Add(addressToSave);
            addressToSave.PersonId = ownerPerson.Id;
            addressBiz.Create(addressToSave);
        }
Пример #14
0
        //this recieves a list of selected product children Ids from MessageParameter and then gets the
        //product children and returns them
        private List <ProductChild> getProductChildrenFromCheckItem(MessageParameter msgParam)
        {
            List <ProductChild> selectedList = new List <ProductChild>();

            if (!msgParam.GetProductChildrenAddyFromCheckItems().IsNullOrEmpty())
            {
                foreach (string pChildAddy in msgParam.GetProductChildrenAddyFromCheckItems())
                {
                    ProductChild productChild = ProductChildBiz.Find(pChildAddy);
                    productChild.IsNullThrowException("productChild");
                    selectedList.Add(productChild);
                }
            }

            return(selectedList);
        }
Пример #15
0
        private void getParent(ProductChildInitializer item, ProductChild pc)
        {
            //Get the parent;
            Product p = FindByName(item.ParentName);

            p.IsNullThrowException("Product Not found. Initialization Data error.");

            pc.Product   = p;
            pc.ProductId = p.Id;

            if (p.ProductChildren.IsNull())
            {
                p.ProductChildren = new List <ProductChild>();
            }

            p.ProductChildren.Add(pc);
        }
Пример #16
0
        public void LogPersonsVisit(string UserId, ProductChild productChild)
        {
            UserId.IsNullOrWhiteSpaceThrowArgumentException("UserId");
            Person person = UserBiz.GetPersonFor(UserId);

            person.IsNullThrowException("Person for user not found");

            //if (productChild.VisitorPeople.IsNull())
            //    productChild.VisitorPeople = new List<Person>();


            //if (person.VisitedProductChildren.IsNull())
            //    person.VisitedProductChildren = new List<ProductChild>();

            //productChild.VisitorPeople.Add(person);
            //person.VisitedProductChildren.Add(productChild);
            SaveChanges();
        }
Пример #17
0
        private void getUser(ProductChildInitializer item, ProductChild pc)
        {
            //   throw new NotImplementedException();

            ////get user
            //ApplicationUser user = UserBiz.FindAll().FirstOrDefault(x =>
            //    x.UserName.ToLower() == item.UserName.ToLower());

            //user.IsNullThrowException(string.Format("User '{0}' Not found. Erronious starting data.", item.UserName));

            //pc.User = user;
            //pc.UserId = user.Id;

            //if (user.ProductChildren.IsNull())
            //    user.ProductChildren = new List<ProductChild>();

            //user.ProductChildren.Add(pc);
        }
Пример #18
0
        private void addNewAddress(ICommonWithId entity, Person person, AddressBiz addressBiz, AddressMain addressToSave)
        {
            ProductChild pc = entity as ProductChild;

            pc.IsNullThrowException();

            pc.ShipFromAddressId = addressToSave.Id;

            if (addressToSave.ProductChilds.IsNull())
            {
                addressToSave.ProductChilds = new List <ProductChild>();
            }

            addressToSave.ProductChilds.Add(pc);

            person.Addresses.Add(addressToSave);
            addressToSave.PersonId = person.Id;
            addressBiz.Create(addressToSave);
        }
Пример #19
0
        public void FixProductChildFeatures(ProductChild productChild)
        {
            productChild.IsNullThrowExceptionArgument("productChild");
            productChild.Product.IsNullThrowException("Product");
            IProduct iproduct = productChild.Product;

            //get all the product features.
            List <ProductFeature> list_Of_ProductFeatures =
                get_All_Product_Features_For(iproduct);

            List <ProductChildFeature> list_Of_ProductChild_Features =
                Get_All_ProductChild_Features_For(productChild);

            List <ProductChildFeature> list_Of_Missing_ProductChild_Features_In_ProductChild =
                get_List_Of_Missing_ProductChild_Features_In_ProductChild(list_Of_ProductFeatures, list_Of_ProductChild_Features);

            //add all missing features from the product to the product child.
            productChild = add_Missing_ProductChildFeatures_To_ProductChild(productChild, list_Of_Missing_ProductChild_Features_In_ProductChild);
        }
Пример #20
0
        ProductChild add_Missing_ProductChildFeatures_To_ProductChild(
            ProductChild productChild,
            List <ProductChildFeature> list_Of_Missing_ProductChild_Features_In_ProductChild)
        {
            if (list_Of_Missing_ProductChild_Features_In_ProductChild.IsNullOrEmpty())
            {
                return(productChild);
            }

            if (productChild.ProductChildFeatures.IsNull())
            {
                productChild.ProductChildFeatures = new List <ProductChildFeature>();
            }

            foreach (ProductChildFeature pc in list_Of_Missing_ProductChild_Features_In_ProductChild)
            {
                productChild.ProductChildFeatures.Add(pc);
            }

            return(productChild);
        }
Пример #21
0
        /// <summary>
        /// Every Owner can add only One product of a specific name.
        /// We need to load the product in this at a higher level because we are unable to access ProductBiz here
        /// </summary>
        /// <param name="parm"></param>
        public override void Fix(ControllerCreateEditParameter parm)
        {
            UserId.IsNullOrWhiteSpaceThrowException("You are not logged in.");

            ProductChild pc = parm.Entity as ProductChild;

            pc.IsNullThrowException("Unable to unbox Product Child");

            //Product comes from the controller.
            pc.ProductId.IsNullOrWhiteSpaceThrowException("There is no parent Product");
            pc.Product.IsNullThrowException("Product Has not been loaded!");


            if (pc.Name.IsNullOrWhiteSpace())
            {
                pc.Name = pc.Product.Name;
            }

            //we need to load the owner in because the name is used to create
            //a directory for the uploads.
            //first get the Owners Id
            Owner owner = OwnerBiz.GetOwnerForUser(UserId);

            owner.IsNullThrowException("Owner not found!");
            pc.OwnerId = owner.Id;
            pc.Owner   = owner;

            ////I dont want to add the features. I will add them temporarily when it is being presented,
            ////addProductFeatures(pc);
            FixProductChildFeatures(pc);

            base.Fix(parm);

            //check the address. If the address is a new address, make it past of the database for the ProductChild Owner
            //check if the address exists

            AddShippingAddressToOwnerPersonIfItIsNew(pc);
            //AddPhoneNumberToOwnerPersonIfItsNew(pc);
        }
Пример #22
0
        private void getPeopleFromProductChildOwners(ProductChild productChild)
        {
            productChild.IsNullThrowExceptionArgument("productChild");
            productChild.Owner.IsNullThrowException("child owner is null");
            productChild.Owner.Person.IsNullThrowException("child owner person is null");

            peopleInProductChildren.Add(productChild.Owner.Person);

            //this is where we get all the child products owned by user in the current subset
            if (!OwnerForUser.IsNull())
            {
                if (productChild.OwnerId == OwnerForUser.Id)
                {
                    productChild.Selected = true;
                    childProductsBelongingToUserFrom.Add(productChild);
                }
            }

            //get the likes/unlike people for the product
            if (!productChild.LikeUnlikes_Fixed.IsNullOrEmpty())
            {
                AddLikes(productChild.LikeUnlikes_Fixed);
            }
        }
Пример #23
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;
            }
        }
Пример #24
0
        /// <summary>
        /// Use this to create buy sell orders programatically
        /// </summary>
        /// <param name="productChild"></param>
        /// <param name="ownerProductChild"></param>
        /// <param name="quantity"></param>
        /// <param name="customerUser"></param>
        /// <param name="selectListOwner"></param>
        /// <param name="selectListCustomer"></param>
        /// <param name="addressBillToId"></param>
        /// <param name="addressShipToId"></param>
        /// <param name="selectListBillTo"></param>
        /// <param name="selectListShipTo"></param>
        /// <param name="buySellDocStateEnum"></param>
        /// <returns></returns>


        public BuySellDoc CreateSale(
            ProductChild productChild,
            Owner ownerProductChild,
            int quantity,
            decimal salePrice,
            Customer customerUser,
            System.Web.Mvc.SelectList selectListOwner,
            System.Web.Mvc.SelectList selectListCustomer,
            string addressBillToId,
            string addressShipToId,
            System.Web.Mvc.SelectList selectListBillTo,
            System.Web.Mvc.SelectList selectListShipTo,
            BuySellDocStateENUM buySellDocStateEnum,
            BuySellDocStateModifierENUM buySellDocStateModifierEnum,
            DateTime pleasePickupOnDate_End,
            DateTime expectedDeliveryDate,
            string shopId)
        {
            BuySellDoc sale = BuySellDocBiz.Factory() as BuySellDoc;

            sale.ShopId = shopId;

            sale.Initialize(
                ownerProductChild.Id,
                customerUser.Id,
                addressBillToId,
                addressShipToId,
                selectListOwner,
                selectListCustomer,
                selectListBillTo,
                selectListShipTo);

            if (pleasePickupOnDate_End == DateTime.MaxValue || pleasePickupOnDate_End == DateTime.MinValue)
            {
            }
            else
            {
                sale.PleasePickupOnDate_End = pleasePickupOnDate_End;
            }

            if (expectedDeliveryDate == DateTime.MaxValue || expectedDeliveryDate == DateTime.MinValue)
            {
            }
            else
            {
                sale.ExpectedDeliveryDate = expectedDeliveryDate;
            }


            //dont really need this, but it is good for consistancy.
            sale.BuySellDocumentTypeEnum     = BuySellDocumentTypeENUM.Purchase;
            sale.BuySellDocStateModifierEnum = buySellDocStateModifierEnum;
            sale.BuySellDocStateEnum         = buySellDocStateEnum;
            sale.ExpectedDeliveryDate        = expectedDeliveryDate;
            BuySellItem buySellItem = new BuySellItem(sale.Id, productChild.Id, quantity, salePrice, productChild.FullName());

            sale.Add(buySellItem);



            BuySellDocBiz.GetDefaultVehicalType(sale);
            //add the owners address
            sale.AddressShipFromId = productChild.ShipFromAddressId;

            setStatusDate(sale);
            ControllerCreateEditParameter parm = new ControllerCreateEditParameter();

            parm.Entity       = sale as ICommonWithId;
            parm.GlobalObject = GetGlobalObject();
            getCustomerSalesmanAndOwnerSalesman(sale);


            //add the payment amount.



            BuySellDocBiz.Create(parm);

            return(sale);
        }
Пример #25
0
        public string AddToSale(string userId, string productChildId, string poNumber, DateTime poDate)
        {
            userId.IsNullOrWhiteSpaceThrowException("No user");

            double totalThisItem = 0;

            //who is the owner:The product Child owner is the owner
            //get the productChild

            productChildId.IsNullOrWhiteSpaceThrowException("No Product");
            ProductChild productChild = ProductChildBiz.Find(productChildId);

            productChild.IsNullThrowException("productChild");



            //get the product child's owner
            Owner ownerProductChild = productChild.Owner;

            ownerProductChild.IsNullThrowException("productChildOwner");

            //get the owner
            //Get the select list for owner
            Person ownerPerson = ownerProductChild.Person;

            ownerPerson.IsNullThrowException("ownerPerson");
            System.Web.Mvc.SelectList ownerSelectList = OwnerBiz.SelectListOnlyWith(ownerProductChild);


            ////the user is the customer user;
            //get the customer
            Customer customerUser = CustomerBiz.GetPlayerFor(userId);

            //Get the select list for Customer
            //remove the owner from the list... owner cannot sell to self.
            System.Web.Mvc.SelectList customerSelectList = CustomerBiz.SelectListWithout(ownerPerson);
            System.Web.Mvc.SelectList selectListOwner    = OwnerBiz.SelectListOnlyWith(ownerProductChild);
            System.Web.Mvc.SelectList selectListCustomer = CustomerBiz.SelectListWithout(ownerPerson);

            //this is the address in the customer
            AddressMain    addressBillTo          = customerUser.DefaultBillAddress;
            AddressMain    addressShipTo          = customerUser.DefaultShipAddress;
            AddressComplex addressShipFromComplex = productChild.ShipFromAddressComplex;

            string addressBillToId = "";
            string addressShipToId = "";

            if (!addressBillTo.IsNull())
            {
                addressBillToId = addressBillTo.Id;
            }

            if (!addressShipTo.IsNull())
            {
                addressShipToId = addressShipTo.Id;
            }


            //Get the select list for AddressInform
            System.Web.Mvc.SelectList selectListBillTo = AddressBiz.SelectListBillAddressCurrentUser();
            //Get the select list for AddressShipTo
            System.Web.Mvc.SelectList selectListShipTo = AddressBiz.SelectListShipAddressCurrentuser();



            //check to see if there is any open sale which belongs to the same buyer and seller
            BuySellDoc sale = BuySellDocBiz.GetOpenSaleWithSameCustomerAndSeller(customerUser.Id, ownerProductChild.Id, productChild);

            //create the itemList.
            List <BuySellItem> buySellItems = new List <BuySellItem>();
            string             shopId       = "";

            if (sale.IsNull())
            {
                //otherwise add a new sale
                sale = CreateSale(
                    productChild,
                    ownerProductChild,
                    1,
                    productChild.Sell.SellPrice,
                    customerUser,
                    selectListOwner,
                    selectListCustomer,
                    addressBillToId,
                    addressShipToId,
                    selectListBillTo,
                    selectListShipTo,
                    BuySellDocStateENUM.RequestUnconfirmed,
                    BuySellDocStateModifierENUM.Unknown,
                    DateTime.Now,
                    DateTime.Now,
                    shopId);

                totalThisItem++;
            }

            else
            {
                //dont really need this, but it is good for consistancy.
                sale.BuySellDocumentTypeEnum = BuySellDocumentTypeENUM.Purchase;
                sale.BuySellDocStateEnum     = BuySellDocStateENUM.RequestUnconfirmed;

                //now check to see if it is the same item... or is it a new item
                //get list of items for the sale
                List <BuySellItem> itemList = sale.BuySellItems.Where(x => x.MetaData.IsDeleted == false).ToList();

                if (itemList.IsNullOrEmpty())
                {
                    BuySellItem buySellItem = new BuySellItem(sale.Id, productChild.Id, 1, productChild.Sell.SellPrice, productChild.FullName());
                    sale.Add(buySellItem);
                }
                else
                {
                    //there are items in the list
                    BuySellItem itemFound = itemList.FirstOrDefault(x => x.ProductChildId == productChild.Id);
                    if (itemFound.IsNull())
                    {
                        BuySellItem buySellItem = new BuySellItem(sale.Id, productChild.Id, 1, productChild.Sell.SellPrice, productChild.FullName());
                        sale.Add(buySellItem);
                    }
                    else
                    {
                        totalThisItem                     = itemFound.Quantity.Order;
                        itemFound.Quantity.Order         += 1;
                        itemFound.Quantity.Order_Original = itemFound.Quantity.Order;
                        //itemFound.Quantity.Ship += 1;
                    }
                }

                totalThisItem++;
                sale.AddressShipFromComplex = addressShipFromComplex;

                BuySellDocBiz.GetDefaultVehicalType(sale);
                sale.AddressShipFromId = productChild.ShipFromAddressId;

                sale.RequestUnconfirmed.SetToTodaysDate(UserName, UserId);

                ControllerCreateEditParameter parm = new ControllerCreateEditParameter();
                parm.Entity       = sale as ICommonWithId;
                parm.GlobalObject = GetGlobalObject();

                BuySellDocBiz.Update(parm);
            }

            BuySellDocBiz.SaveChanges();
            string message = string.Format("Success. You ordered {0:N2} for {1:N2} (X{2:N2})", productChild.FullName(), productChild.Sell.SellPrice, totalThisItem);

            return(message);
        }
Пример #26
0
 private void updateAddress(ProductChild pc, AddressBiz addressBiz, AddressMain addressToSave)
 {
     pc.ShipFromAddressId = addressToSave.Id;
     addressBiz.Update(addressToSave);
 }
Пример #27
0
        /// <summary>
        /// This is being used for Pickups.
        /// </summary>
        /// <param name="indexListVM"></param>
        /// <param name="indexItemVM"></param>
        /// <param name="icommonWithId"></param>
        public override void Event_ModifyIndexItem(IndexListVM indexListVM, IndexItemVM indexItemVM, ICommonWithId icommonWithId)
        {
            base.Event_ModifyIndexItem(indexListVM, indexItemVM, icommonWithId);

            //conversions
            BuySellItem buySellItem = icommonWithId as BuySellItem;

            buySellItem.IsNullThrowException();
            buySellItem.ProductChild.IsNullThrowException();

            ProductChild productChild = buySellItem.ProductChild;

            productChild.IsNullThrowException();
            indexItemVM.Description = productChild.DetailInfoToDisplayOnWebsite;


            BuySellDoc buySellDoc = buySellItem.BuySellDoc;

            buySellDoc.IsNullThrowException();

            UploadedFile uf = productChild.MiscFiles.FirstOrDefault(x => !x.MetaData.IsDeleted);

            //product child has no image?
            if (uf.IsNull())
            {
                uf = productChild.Product.MiscFiles.FirstOrDefault(x => !x.MetaData.IsDeleted);
            }

            indexItemVM.MenuManager = new MenuManager(null, null, productChild, MenuENUM.IndexMenuProductChild, BreadCrumbManager, new LikeUnlikeParameters(0, 0, ""), UserId, indexListVM.MenuManager.ReturnUrl, UserName);

            //get the pictures list from the productChild
            List <string> pictureAddresses = GetCurrItemsPictureList(productChild);

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

            indexItemVM.MenuManager.PictureAddresses = pictureAddresses;
            //indexItem.PictureViews = productChild.NoOfVisits.Amount;
            //indexItem.CompleteMenuPathViews = productChild.NoOfVisits.Amount;

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

            AddEntryToIndex = buySellItem.BuySellDocStateEnum == BuySellDocStateENUM.ReadyForPickup;

            string countyName = buySellDoc.AddressShipToComplex.CountryName;
            string cityName   = buySellDoc.AddressShipToComplex.CityName;
            string townName   = buySellDoc.AddressShipToComplex.TownName;

            //add the price into the 2nd heading

            if (!countyName.IsNullOrWhiteSpace() && !cityName.IsNullOrWhiteSpace() && !townName.IsNullOrWhiteSpace())
            {
                indexItemVM.Amount2ndLine = string.Format("{0} {1}, {2}", townName, cityName, countyName);
            }
            else
            {
                if (!countyName.IsNullOrWhiteSpace() && !cityName.IsNullOrWhiteSpace() && townName.IsNullOrWhiteSpace())
                {
                    indexItemVM.Amount2ndLine = string.Format("{0}, {1}", cityName, countyName);
                }
                else
                {
                    throw new Exception("Address incomplete");
                }
            }

            indexItemVM.IsPickup = true;
            indexItemVM.ParentId = buySellDoc.Id;
            //buySellDoc.BuySellDocumentTypeEnum = BuySellDocumentTypeENUM.Delivery;
        }
Пример #28
0
        public BuySellDoc GetOpenSaleWithSameCustomerAndSeller(string customerId, string ownerProductChildId, ProductChild productChild)
        {
            customerId.IsNullThrowExceptionArgument("customerId");
            ownerProductChildId.IsNullThrowExceptionArgument("ownerProductChildId");
            productChild.IsNullThrowExceptionArgument("productChild");

            BuySellDoc buysSellDoc = FindAll().FirstOrDefault(x =>
                                                              x.CustomerId == customerId &&
                                                              x.OwnerId == ownerProductChildId &&
                                                              x.BuySellDocStateEnum == BuySellDocStateENUM.RequestUnconfirmed);

            //make sure the product addresses are also the same.
            if (buysSellDoc.IsNull())
            {
                return(buysSellDoc);
            }

            if (productChild.ShipFromAddress.IsNull())
            {
                productChild.ShipFromAddressId.IsNullOrWhiteSpaceThrowException();

                productChild.ShipFromAddress = AddressBiz.Find(productChild.ShipFromAddressId);
                productChild.ShipFromAddress.IsNullThrowException();
            }
            productChild.ShipFromAddressComplex = productChild.ShipFromAddress.ToAddressComplex();

            if (buysSellDoc.AddressShipFromComplex.Equals(productChild.ShipFromAddressComplex))
            {
                return(buysSellDoc);
            }

            return(null);
        }
Пример #29
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);
        }
Пример #30
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);
        }