public BuySellDocBiz(IRepositry <BuySellDoc> entityDal, BuySellItemBiz buySellItemBiz, BizParameters bizParameters, OwnerBiz ownerBiz, CustomerBiz customerBiz, ShopBiz shopBiz, DeliverymanBiz deliverymanBiz, FreightOfferTrxBiz freightOfferTrxBiz, VehicalTypeBiz vehicalTypeBiz, MessageBiz messageBiz, PeopleMessageBiz peopleMessageBiz, SalesmanBiz salesmanBiz, BuySellDocHistoryBiz buySellDocHistoryBiz) : base(entityDal, bizParameters) { _ownerBiz = ownerBiz; _customerBiz = customerBiz; _shopBiz = shopBiz; _buySellBiz = entityDal as BuySellDocBiz; _buySellItemBiz = buySellItemBiz; _freightOfferTrxBiz = freightOfferTrxBiz; _deliverymanBiz = deliverymanBiz; _vehicalTypeBiz = vehicalTypeBiz; _messageBiz = messageBiz; _peopleMessageBiz = peopleMessageBiz; _salesmanBiz = salesmanBiz; _buySellDocHistoryBiz = buySellDocHistoryBiz; }
public async Task <ShopCreatedSuccessfullyVM> Setup_To_Create_Shop_Post_Async(ShopVM shopCreate, string button, HttpPostedFileBase[] httpMiscUploadedFiles) { UserId.IsNullOrWhiteSpaceThrowException("You are not logged in."); shopCreate.MenuPathMainId.IsNullOrWhiteSpaceThrowException("Main Menu Path not received"); Owner userOwner = OwnerBiz.GetPlayerFor(UserId); userOwner.IsNullThrowException("You are not authourized to create a shop. Please become a seller first."); if (button == "accept") { //CashDistributionEngine cde; //int quantity; //Product product; //MenuPathMain mpm; //ControllerCreateEditParameter parm = setup_Shop_Into_ControllerCreateEditParameter(shopCreate, button, httpMiscUploadedFiles, userOwner, out cde, out quantity, out product, out mpm, out parm); decimal paymentAmount = MenuPathMain.Payment_To_Buy_Shop(); decimal commissionPct = BuySellDoc.Get_Maximum_Commission_Product_Percent(); bool isNonRefundablePaymentAllowed = true; CashDistributionEngine cde = get_CashDistributionEngineAndCheckBalance(paymentAmount, isNonRefundablePaymentAllowed); //check the name, if it is already used, throw error and return to create screen if (isShopNameExists(shopCreate.ShopName)) { string err = string.Format("The shop name '{0}' already exists... sorry. Try again.", shopCreate.ShopName); throw new Exception(err); } //create the shop int quantity = shopCreate.NoOfMonths; if (quantity == 0) { throw new Exception("The quantity is zero. This is not allowed"); } Customer customerUser = getCustomerOfUser(); SelectList selectListOwner = null; SelectList selectListCustomer = null; SelectList selectListBillTo = null; SelectList selectListShipTo = null; string addressBillToId = ""; string addressShipToId = ""; decimal salePrice = MenuPathMain.Payment_To_Buy_Shop(); DateTime expectedDeliveryDate = DateTime.Now; DateTime guaranteePeriodEnds = DateTime.Now; //MenuPathMain mpm = MenuPathMainBiz.Find(shopCreate.MenuPathMainId); //mpm.IsNullThrowException("Menu Path Main is null"); MenuPathMain mpm = getMainMenuPath(shopCreate); Product product = setup_Product_For_Shop(shopCreate, userOwner); //get the shop Child Product ProductChild shopBuySellItem = ProductChildBiz.FindForName(ProductChild.GetShopName()); shopBuySellItem.IsNullThrowException("Shop not found"); string shopId = product.Id; Owner ownerOfProductChild = shopBuySellItem.Owner; ownerOfProductChild.IsNullThrowException("No Product Child Owner"); 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, shopCreate.ReturnUrl, GetGlobalObject(), button); await ShopBiz.CreateAndSaveAsync(parm); 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, shopCreate.ReturnUrl); //BuySellDocBiz.SaveChanges(); return(shopCreatedSuccessfully); } else { string err = string.Format("You caneled the operation."); throw new Exception(err); } }