private void getPeopleFromProductEtc(string productId)
        {
            productId.IsNullOrWhiteSpaceThrowArgumentException("productId");
            Product product = ProductBiz.Find(productId);

            product.IsNullThrowException("product not found");
            getPeopleFromProductEtc(product);
        }
Beispiel #2
0
        public ShopVM Setup_Shop_For_Edit_Get(string returnUrl, string productId)
        {
            productId.IsNullOrWhiteSpaceThrowException("productId");
            returnUrl.IsNullOrWhiteSpaceThrowException("returnUrl");

            //locate the shop
            Product product = ProductBiz.Find(productId);

            product.IsNullThrowException("product");

            //now we have the shop...
            MenuPathMain menuPathMain = product.MenuPathMains_Fixed.FirstOrDefault();

            menuPathMain.IsNullThrowException("menuPathMain");
            string menuPathMainId = menuPathMain.Id;

            menuPathMainId.IsNullOrWhiteSpaceThrowException("menuPathMainId");


            List <string> shopNames    = getShopNamesForCurrUser();
            int           noOfMonths   = 1;
            decimal       ratePerMonth = getShopRatePerMonth();
            decimal       totalAmount  = ratePerMonth * noOfMonths;

            CashDistributionEngine cashDistributionEnginge = get_CashDistributionEngineAndCheckBalance(totalAmount, true);

            string explaintion = string.Format("{0}. All your products will be collected and will be shown in your shop. Note, every shop must have a unique name and will be created in its own area. This shop will be created in: ", cashDistributionEnginge.Message);

            AddressStringWithNames customerAddress = getDefaultCustomerAddress();

            ShopVM shopCreate = new ShopVM(
                product.Id,
                product.Name,
                explaintion,
                noOfMonths,
                ratePerMonth,
                returnUrl,
                shopNames,
                menuPathMain,
                customerAddress,
                product.MiscFiles_Fixed);

            shopCreate.Id = product.Id;

            return(shopCreate);
        }
Beispiel #3
0
        private void ifShopPurchaseThenDeleteShopAndMarkReject(BuySellDoc bsd)
        {
            //is this a shop BuySellDoc
            if (bsd.ShopId.IsNullOrWhiteSpace())
            {
                return;
            }

            //locate the shop in products and make it deleted
            Product shop = ProductBiz.Find(bsd.ShopId);

            shop.IsNullThrowException();
            shop.MetaData.IsDeleted = true;
            shop.MetaData.Deleted.SetToTodaysDate(UserName, UserId);
            clearAllStatus(bsd);
            bsd.BuySellDocStateEnum = BuySellDocStateENUM.Rejected;
            bsd.Rejected.SetToTodaysDate(UserName, UserId);

            ProductBiz.Update(shop);
        }
        //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);
        }
Beispiel #5
0
        public async Task <ShopCreatedSuccessfullyVM> Setup_To_Edit_Shop_Post_Async(ShopVM shopVm, string button, HttpPostedFileBase[] httpMiscUploadedFiles)
        {
            UserId.IsNullOrWhiteSpaceThrowException("You are not logged in.");
            shopVm.IsNullThrowExceptionArgument("Shop");
            button.IsNullOrWhiteSpaceThrowArgumentException("button");
            Owner userOwner = OwnerBiz.GetPlayerFor(UserId);

            userOwner.IsNullThrowException("You are not authourized to create a shop. Please become a seller first.");
            if (button == "accept")
            {
                //locate the shop

                if (shopVm.NoOfMonths == 0)
                {
                    throw new Exception("No of months is zero");
                }
                decimal salePrice = MenuPathMain.Payment_To_Buy_Shop();
                int     quantity  = shopVm.NoOfMonths;

                //see if User has the money to do what they want.
                decimal paymentAmount = salePrice * quantity;

                bool isNonRefundablePaymentAllowed = true;
                CashDistributionEngine cde         = get_CashDistributionEngineAndCheckBalance(paymentAmount, isNonRefundablePaymentAllowed);

                //get the shop Child Product
                ProductChild shopBuySellItem = ProductChildBiz.FindForName(ProductChild.GetShopName());
                shopBuySellItem.IsNullThrowException("Shop not found");

                Owner ownerOfProductChild = shopBuySellItem.Owner;
                ownerOfProductChild.IsNullThrowException("No Product Child Owner");

                Customer customerUser = getCustomerOfUser();

                Product product = ProductBiz.Find(shopVm.Id);
                product.IsNullThrowException("product");
                string shopId = product.Id;
                updateTheProductFromTheShopVm(product, shopVm);

                SelectList selectListOwner      = null;
                SelectList selectListCustomer   = null;
                SelectList selectListBillTo     = null;
                SelectList selectListShipTo     = null;
                string     addressBillToId      = "";
                string     addressShipToId      = "";
                DateTime   expectedDeliveryDate = DateTime.Now;
                DateTime   guaranteePeriodEnds  = DateTime.Now;


                BuySellDoc sale = CreateSale(
                    shopBuySellItem,
                    ownerOfProductChild,
                    quantity,
                    salePrice,
                    customerUser,
                    selectListOwner,
                    selectListCustomer,
                    addressBillToId,
                    addressShipToId,
                    selectListBillTo,
                    selectListShipTo,
                    BuySellDocStateENUM.RequestUnconfirmed,
                    BuySellDocStateModifierENUM.Accept,
                    expectedDeliveryDate,
                    guaranteePeriodEnds,
                    shopId);

                product.BuySellDocs.Add(sale);

                ControllerCreateEditParameter parm = new ControllerCreateEditParameter(
                    product as ICommonWithId,
                    httpMiscUploadedFiles,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null,
                    MenuENUM.EditDefault,
                    UserName,
                    UserId,
                    shopVm.ReturnUrl,
                    null, //globalObject not required for products
                    button);

                await ProductBiz.UpdateAndSaveAsync(parm);


                MenuPathMain mpm = product.MenuPathMains_Fixed.FirstOrDefault();

                decimal  refundable_Spent    = cde.Refundable_Final;
                decimal  nonRefundable_spent = cde.NonRefundable_Final;
                string   shopName            = product.FullName();
                string   mp1Name             = mpm.MenuPath1.FullName();
                string   mp2Name             = mpm.MenuPath2.FullName();
                string   mp3Name             = mpm.MenuPath3.FullName();
                int      numberOfMonths      = quantity;
                DateTime expiryDate          = product.ShopExpiryDate.Date_NotNull_Min;

                ShopCreatedSuccessfullyVM shopCreatedSuccessfully = new ShopCreatedSuccessfullyVM(
                    refundable_Spent,
                    nonRefundable_spent,
                    shopName,
                    mp1Name,
                    mp2Name,
                    mp3Name,
                    numberOfMonths,
                    expiryDate,
                    shopVm.ReturnUrl);

                return(shopCreatedSuccessfully);
            }

            return(null);
        }