示例#1
0
        private void addOwner(Product p)
        {
            if (IsCreate)
            {
                if (!UserId.IsNullOrWhiteSpace())
                {
                    //user is logged in
                    //make sure the user is an Owner

                    Owner owner = OwnerBiz.GetOwnerForUser(UserId);
                    if (!owner.IsNull())
                    {
                        //user is an owner
                        //Now this user will own this product.
                        p.OwnerId = owner.Id;

                        if (owner.Shops.IsNull())
                        {
                            owner.Shops = new List <Product>();
                        }
                        owner.Shops.Add(p);
                    }
                }
            }
        }
示例#2
0
 public override void InitializeMenuManagerForEntity(ControllerIndexParams parm, InterfacesLibrary.SharedNS.ICommonWithId entity)
 {
     base.InitializeMenuManagerForEntity(parm, entity);
     if (!UserId.IsNullOrWhiteSpace())
     {
         Person person = UserBiz.GetPersonFor(UserId);
         person.IsNullThrowException("person");
         entity.MenuManager.UserPersonId = person.Id;
     }
 }
示例#3
0
        public override async Task CreateAndSaveAsync(ModelsClassLibrary.ModelsNS.SharedNS.ControllerCreateEditParameter parm)
        {
            Product product = Product.Unbox(parm.Entity);

            if (UserId.IsNullOrWhiteSpace())
            {
                return;
            }

            await base.CreateAndSaveAsync(parm);
        }
示例#4
0
 /// <summary>
 /// This marks the user as an owner of the shop. Basicly if the OwnerId in product has a value, then it is a shop.
 /// if ownerId of the shop matches the ownerId of the user, then the user is the owner of the shop
 /// </summary>
 /// <param name="indexItem"></param>
 /// <param name="product"></param>
 private void markUserAsOwnerOfShop(IndexItemVM indexItem, Product product)
 {
     if (!UserId.IsNullOrWhiteSpace())
     {
         Owner owner = OwnerBiz.GetPlayerFor(UserId);
         if (owner.IsNull())
         {
         }
         else
         {
             indexItem.IsShopAndOwnerOfShop = product.OwnerId == owner.Id;
         }
     }
 }
示例#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);
        }
示例#6
0
        /// <summary>
        /// This will return Product Children.
        /// </summary>
        /// <param name="parms"></param>
        /// <returns></returns>
        private async Task <List <ICommonWithId> > indexProductChild_DataListAsync(ControllerIndexParams parms)
        {
            //Get the product

            parms.ProductId.IsNullOrWhiteSpaceThrowException();
            Product product = await ProductBiz.FindAsync(parms.ProductId);

            //parent product cannot be null. It is some kind of programming error if it is.
            product.IsNullThrowException(string.Format("Product not found. Id ='{0}'", parms.ProductId));


            //update the number of visits
            if (!UserId.IsNullOrWhiteSpace())
            {
                product.NoOfVisits.AddOne(UserId, UserName);
                await ProductBiz.UpdateAndSaveAsync(product);
            }
            //get all its child products and display them

            List <ProductChild> children;

            //see if the product is a shop
            if (product.OwnerId.IsNullOrWhiteSpace())
            {
                //this is not a shop.
                children = productChildren(product);
            }
            else
            {
                //this is a shop
                children = shopChildren(product);
            }

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

            List <ICommonWithId> childrenAsIcommonLst = children.Cast <ICommonWithId>().ToList();

            return(childrenAsIcommonLst);
        }
示例#7
0
        private async Task <List <ICommonWithId> > indexProduct_DataListAsync(ControllerIndexParams parms)
        {
            //get the menupathMain
            MenuPathMain mpm = await FindAsync(parms.MenuPathMainId);

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

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

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

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

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

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



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


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

            return(pclst);
        }
示例#8
0
        public override void CreateAndSave(ModelsClassLibrary.ModelsNS.SharedNS.ControllerCreateEditParameter parm)
        {
            Product product = Product.Unbox(parm.Entity);

            if (UserId.IsNullOrWhiteSpace())
            {
                return;
            }

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

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

            base.CreateAndSave(parm);
        }
示例#9
0
 private void addRemoveApprover(Product p)
 {
     if (UserId.IsNullOrWhiteSpace())
     {
         return;
     }
     //if user is not approver dont let him do anything
     //todo
     if (p.IsUnApproved)
     {
         //remove the old info.
         p.ApprovedBy = new DateAndByComplex();
     }
     else
     {
         if (p.ApprovedBy.By.IsNullOrWhiteSpace())
         {
             if (p.ApprovedBy.By.IsNullOrWhiteSpace())
             {
                 p.ApprovedBy.SetToTodaysDate(UserName, UserId);
             }
         }
     }
 }
示例#10
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);
        }
示例#11
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;
            }
        }
示例#12
0
        private void deliveryman_Makes_Bid_To_Pickup(BuySellDoc buySellDoc)
        {
            if (UserId.IsNullOrWhiteSpace())
            {
                return;
            }


            if (buySellDoc.FreightOfferDecimal > 0)
            {
                //we have an offer
                DateParameter dp = new DateParameter();
                dp.BeginDate = buySellDoc.PleasePickupOnDate_Start;
                dp.EndDate   = buySellDoc.PleasePickupOnDate_End;

                if (dp.IsDateWithinBeginAndEndDatesInclusive(buySellDoc.OfferedPickupOnDate))
                {
                    string buySellDocId = buySellDoc.Id;
                    buySellDoc = Find(buySellDocId);
                    buySellDoc.IsNullThrowException();

                    //the pick up is today or later.
                    //the user is the deliveryman here
                    Deliveryman deliveryman = DeliverymanBiz.GetPlayerFor(UserId);
                    deliveryman.IsNullThrowException();


                    //create an offer
                    FreightOfferTrx frtOff = new FreightOfferTrx(
                        buySellDoc.Id,
                        deliveryman.Id,
                        buySellDoc.FreightOfferDecimal,
                        buySellDoc.OfferedPickupOnDate,
                        buySellDoc.ExpectedDeliveryDate,
                        buySellDoc.CommentByDeliveryman,
                        buySellDoc.VehicalTypeOfferedId);

                    //used later
                    frtOff.Deliveryman = deliveryman;
                    frtOff.BuySellDoc  = buySellDoc;


                    //we will only create if there is not one bid from this deliveryman
                    //for this document. If there is already a bid, then all fields will be updated.
                    //the change will only be allowed if the status of the buyselldoc is

                    //check to see if a bid already exists.
                    //this locates an earlier bid and then updates it.

                    FreightOfferTrx frtOffTrxFound = FreightOfferTrxBiz.FindAll().FirstOrDefault(x => x.BuySellDocId == buySellDocId && x.DeliverymanId == deliveryman.Id);
                    if (frtOffTrxFound.IsNull())
                    {
                        //create a new bid.
                        buySellDoc.FreightOfferTrxs.Add(frtOff);
                        FreightOfferTrxBiz.Create(frtOff);
                    }
                    else
                    {
                        //update the old bid.
                        frtOffTrxFound.UpdatePropertiesDuringModify(frtOff as ICommonWithId);
                        FreightOfferTrxBiz.Update(frtOffTrxFound);
                    }
                }
            }
        }
示例#13
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);
        }
示例#14
0
        public ProductChild LoadProductChildForLandingPage(string productChildId, string searchFor, string returnUrl)
        {
            //ProductChild productChild = _icrudBiz.Factory() as ProductChild;
            //productChildId.IsNullThrowExceptionArgument("Id not received. Bad Request");

            ProductChild productChild = Find(productChildId);

            productChild.IsNullThrowException("Product Child not found.");

            string productIdDud      = "";
            string isandForSearchDud = "";
            string selectIdDud       = "";
            string menuPathMainIdDud = "";
            string logoAddress       = "";
            string buttonDud         = "";
            //string sortByDud = "";
            LikeUnlikeParameters likeUnlikeParameters = null;

            bool isMenuDud   = false;
            bool isUserAdmin = false;
            BuySellDocumentTypeENUM buySellDocumentTypeEnum = BuySellDocumentTypeENUM.Unknown; //DUD
            BuySellDocStateENUM     BuySellDocStateEnum     = BuySellDocStateENUM.Unknown;     //dud

            if (!UserId.IsNullOrWhiteSpace())
            {
                isUserAdmin = UserBiz.IsAdmin(UserId);
            }

            ControllerIndexParams parms = new ControllerIndexParams(
                productChildId,
                menuPathMainIdDud,
                searchFor,
                isandForSearchDud,
                selectIdDud,
                MenuENUM.IndexMenuProductChildLandingPage,
                SortOrderENUM.Item1_Asc,
                logoAddress,
                productChild,
                productChild,
                UserId,
                UserName,
                isUserAdmin,
                isMenuDud,
                BreadCrumbManager,
                ActionNameENUM.Unknown,
                likeUnlikeParameters,
                productIdDud,
                returnUrl,
                buySellDocumentTypeEnum,
                BuySellDocStateEnum,
                buttonDud);

            InitializeMenuManagerForEntity(parms);

            //IHasUploads hasUploadsEntity = parms.Entity as IHasUploads;
            //MenuManager menuManager = new MenuManager(parms.Entity.MenuManager.MenuPathMain, null, null, parms.Menu.MenuEnum, BreadCrumbManager, parms.LikeUnlikeCounter, UserId, parms.ReturnUrl, UserName);
            IMenuManager menuManager = parms.Entity.MenuManager;

            if (menuManager.IndexMenuVariables.IsNull())
            {
                menuManager.IndexMenuVariables = new IndexMenuVariables(UserId);
            }



            Person person = UserBiz.GetPersonFor(UserId);

            if (!person.IsNull())
            {
                string userPersonId         = person.Id;
                string productChildPersonId = productChild.Owner.PersonId;
                menuManager.IndexMenuVariables.updateRequiredProperties(userPersonId, productChildPersonId);
            }



            List <string> pictureAddresses = GetCurrItemsPictureList(productChild);

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

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



            menuManager.PictureAddresses = pictureAddresses;

            ////also add the ProductChildperson and UserPerson
            //Person userPerson = UserBiz.GetPersonFor(UserId);

            //if (!productChild.Owner.IsNull())
            //    menuManager.IndexMenuVariables.ProductChildPersonId = productChild.Owner.PersonId;

            productChild.AllFeatures = Get_All_ProductChild_Features_For(productChild);



            if (UserId.IsNullOrEmpty())
            {
                //Log an annonymous user as a visitor
            }
            else
            {
                //Log user as visitor to this product child
                LogPersonsVisit(UserId, productChild);
            }


            return(productChild);
        }