private IQueryable <BuySellDoc> getAllSaleOrders_For(string userId) { //we need to be able to get all the sale orders here without the userid //userId.IsNullOrWhiteSpaceThrowArgumentException("You are not logged in."); //when selling, the user is the owner IQueryable <BuySellDoc> saleOrdersIq = FindAll(); if (userId.IsNullOrWhiteSpace()) { return(saleOrdersIq); } Owner owner; try { owner = OwnerBiz.GetPlayerFor(userId); owner.IsNullThrowException("Owner "); } catch (Exception e) { ErrorsGlobal.Add("No Owner is attached", MethodBase.GetCurrentMethod(), e); throw new Exception(ErrorsGlobal.ToString()); } //get all sale orders for Owner saleOrdersIq = saleOrdersIq .Where(x => x.OwnerId == owner.Id); return(saleOrdersIq); }
/// <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; } } }
private List <string> getShopNamesForCurrUser() { Owner currUserOwner = OwnerBiz.GetPlayerFor(UserId); currUserOwner.IsNullThrowException("You must be authourized to sell to continue"); List <Product> shops = ProductBiz.FindAll().Where(x => x.OwnerId == currUserOwner.Id).ToList(); List <string> shopNames = new List <string>(); if (shops.IsNullOrEmpty()) { } else { foreach (Product shop in shops) { string name = string.Format("{0} NO Path. This will not show. Expires: {1}, Is Expired? {2}", shop.FullName(), shop.ShopExpiryDate.Date_NotNull_Min.ToLongDateString(), shop.IsShopExpired ? "Yes" : "No"); MenuPathMain mpm = shop.MenuPathMains.FirstOrDefault(); if (mpm.IsNull()) { } else { name = string.Format("{0} - {1} - {2} - {3} expires: {4}, Is Expired? {5}", mpm.MenuPath1.FullName(), mpm.MenuPath2.FullName(), mpm.MenuPath3.FullName(), shop.FullName(), shop.ShopExpiryDate.Date_NotNull_Min.ToLongDateString(), shop.IsShopExpired ? "Yes" : "No"); } shopNames.Add(name); } } return(shopNames); }
public override async Task <IList <ICommonWithId> > GetListForIndexAsync(ControllerIndexParams parms) { //get user's customer and owner Customer customer = CustomerBiz.GetPlayerFor(UserId); Owner owner = OwnerBiz.GetPlayerFor(UserId); //now, get all the payment trx for this person List <BuySellDoc> allTrx = await FindAllAsync(); List <BuySellDoc> filteredTrx; //now reduce this list so the user is customer or seller if (customer.IsNull()) { if (owner.IsNull()) { //filteredTrx = allTrx.Where(x => x.CustomerId == customerId).AsQueryable(); return(null); } else { filteredTrx = allTrx.Where(x => x.OwnerId == owner.Id).ToList(); } } else { if (owner.IsNull()) { filteredTrx = allTrx.Where(x => x.CustomerId == customer.Id).ToList(); } else { filteredTrx = allTrx.Where(x => x.CustomerId == customer.Id || x.OwnerId == owner.Id).ToList(); } } //cast and return the list var lstIcommonwithId = allTrx.Cast <ICommonWithId>().ToList(); return(lstIcommonwithId); }
public override void BusinessRulesFor(ControllerCreateEditParameter parm) { if (IsCreate) { Product product = Product.Unbox(parm.Entity); product.IsUnApproved = false; 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); product.MainMenuIdForShop.IsNullOrWhiteSpaceThrowException(); MenuPathMain mpm = MenuPathMainBiz.Find(product.MainMenuIdForShop); mpm.IsNullThrowException(); if (mpm.Products.IsNull()) { mpm.Products = new List <Product>(); } if (product.MenuPathMains.IsNull()) { product.MenuPathMains = new List <MenuPathMain>(); } mpm.Products.Add(product); product.MenuPathMains.Add(mpm); } base.BusinessRulesFor(parm); }
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); }
//OLD //this is thecontroller which routes all the variables to their proper places public UserMoneyAccount GetMoneyAccount(string userId, bool isAdmin, UserMoneyAccount userMoneyAccount) { if (userId.IsNullOrWhiteSpace()) { return(userMoneyAccount); } Owner owner = OwnerBiz.GetPlayerFor(userId); if (owner.IsNull()) { return(new UserMoneyAccount()); } #region Sale Orders decimal personOpenSaleOrders_InMoney = getSaleOrders_InMoney(userId, BuySellDocStateENUM.RequestUnconfirmed); double personOpenSaleOrders_InQuantity = getSaleOrders_Count(userId, BuySellDocStateENUM.RequestUnconfirmed); decimal personClosedSaleOrders_InMoney = getSaleOrders_InMoney(userId, BuySellDocStateENUM.Closed); double personClosedSaleOrders_InQuantity = getSaleOrders_Count(userId, BuySellDocStateENUM.Closed); decimal person_InProccessSaleOrders_InMoney = getSaleOrders_InMoney(userId, BuySellDocStateENUM.InProccess); double person_InProccessSaleOrders_InQuantity = getSaleOrders_Count(userId, BuySellDocStateENUM.InProccess); decimal personCanceledSaleOrders_InMoney = getSaleOrders_InMoney(userId, BuySellDocStateENUM.Canceled); double personCanceledSaleOrders_InQuantity = getSaleOrders_Count(userId, BuySellDocStateENUM.Canceled); decimal personBackSaleOrders_InMoney = getSaleOrders_InMoney(userId, BuySellDocStateENUM.BackOrdered); double personBackSaleOrderedOrders_InQuantity = getSaleOrders_Count(userId, BuySellDocStateENUM.BackOrdered); decimal personSaleCredits_InMoney = 0; double personSaleCredits_InQuantity = 0; decimal personSaleQuotations_InMoney = 0; double personSaleQuotations_InQuantity = 0; decimal systemOpenSaleOrders_InMoney = 0; double systemOpenSaleOrders_InQuantity = 0; decimal systemClosedSaleOrders_InMoney = 0; double systemClosedSaleOrders_InQuantity = 0; decimal system_InProccessSaleOrders_InMoney = 0; double system_InProccessSaleOrders_InQuantity = 0; decimal systemCanceledSaleOrders_InMoney = 0; double systemCanceledSaleOrders_InQuantity = 0; decimal systemBackSaleOrders_InMoney = 0; double systemBackSaleOrderedOrders_InQuantity = 0; decimal systemSaleCredits_InMoney = 0; double systemSaleCredits_InQuantity = 0; decimal systemSaleQuotations_InMoney = 0; double systemSaleQuotations_InQuantity = 0; if (isAdmin) { systemOpenSaleOrders_InMoney = getSaleOrders_InMoney("", BuySellDocStateENUM.New); systemOpenSaleOrders_InQuantity = getSaleOrders_Count("", BuySellDocStateENUM.New); systemClosedSaleOrders_InMoney = getSaleOrders_InMoney(userId, BuySellDocStateENUM.Closed); systemClosedSaleOrders_InQuantity = getSaleOrders_Count("", BuySellDocStateENUM.Closed); system_InProccessSaleOrders_InMoney = getSaleOrders_InMoney(userId, BuySellDocStateENUM.InProccess); system_InProccessSaleOrders_InQuantity = getSaleOrders_Count("", BuySellDocStateENUM.InProccess); systemCanceledSaleOrders_InMoney = getSaleOrders_InMoney(userId, BuySellDocStateENUM.Canceled); systemCanceledSaleOrders_InQuantity = getSaleOrders_Count("", BuySellDocStateENUM.Canceled); systemBackSaleOrders_InMoney = getSaleOrders_InMoney(userId, BuySellDocStateENUM.BackOrdered); systemBackSaleOrderedOrders_InQuantity = getSaleOrders_Count("", BuySellDocStateENUM.BackOrdered); systemSaleCredits_InMoney = getSaleOrders_InMoney(userId, BuySellDocStateENUM.Credit); systemSaleCredits_InQuantity = getSaleOrders_Count("", BuySellDocStateENUM.Credit); systemSaleQuotations_InMoney = getSaleOrders_InMoney(userId, BuySellDocStateENUM.Quotation); systemSaleQuotations_InQuantity = getSaleOrders_Count("", BuySellDocStateENUM.Quotation); } //after getting their values, they are initialized in the class userMoneyAccount.InitializeSalesOrders( personOpenSaleOrders_InMoney, personOpenSaleOrders_InQuantity, personClosedSaleOrders_InMoney, personClosedSaleOrders_InQuantity, person_InProccessSaleOrders_InMoney, person_InProccessSaleOrders_InQuantity, personCanceledSaleOrders_InMoney, personCanceledSaleOrders_InQuantity, personBackSaleOrders_InMoney, personBackSaleOrderedOrders_InQuantity, personSaleCredits_InMoney, personSaleCredits_InQuantity, personSaleQuotations_InMoney, personSaleQuotations_InQuantity, systemOpenSaleOrders_InMoney, systemOpenSaleOrders_InQuantity, systemClosedSaleOrders_InMoney, systemClosedSaleOrders_InQuantity, system_InProccessSaleOrders_InMoney, system_InProccessSaleOrders_InQuantity, systemCanceledSaleOrders_InMoney, systemCanceledSaleOrders_InQuantity, systemBackSaleOrders_InMoney, systemBackSaleOrderedOrders_InQuantity, systemSaleCredits_InMoney, systemSaleCredits_InQuantity, systemSaleQuotations_InMoney, systemSaleQuotations_InQuantity); #endregion #region Purchase Orders decimal personOpenPurchaseOrders_InMoney = getPurchaseOrders_InMoney(userId, BuySellDocStateENUM.RequestUnconfirmed); double personOpenPurchaseOrders_InQuantity = getPurchaseOrders_Count(userId, BuySellDocStateENUM.RequestUnconfirmed); decimal personClosedPurchaseOrders_InMoney = getPurchaseOrders_InMoney(userId, BuySellDocStateENUM.Closed); double personClosedPurchaseOrders_InQuantity = getPurchaseOrders_Count(userId, BuySellDocStateENUM.Closed); decimal person_InProccessPurchaseOrders_InMoney = getPurchaseOrders_InMoney(userId, BuySellDocStateENUM.InProccess); double person_InProccessPurchaseOrders_InQuantity = getPurchaseOrders_Count(userId, BuySellDocStateENUM.InProccess); decimal personCanceledPurchaseOrders_InMoney = getPurchaseOrders_InMoney(userId, BuySellDocStateENUM.Canceled); double personCanceledPurchaseOrders_InQuantity = getPurchaseOrders_Count(userId, BuySellDocStateENUM.Canceled); decimal personBackPurchaseOrders_InMoney = getPurchaseOrders_InMoney(userId, BuySellDocStateENUM.BackOrdered); double personBackPurchaseOrderedOrders_InQuantity = getPurchaseOrders_Count(userId, BuySellDocStateENUM.BackOrdered); decimal personPurchaseCredits_InMoney = 0; double personPurchaseCredits_InQuantity = 0; decimal personPurchaseQuotations_InMoney = 0; double personPurchaseQuotations_InQuantity = 0; decimal systemOpenPurchaseOrders_InMoney = 0; double systemOpenPurchaseOrders_InQuantity = 0; decimal systemClosedPurchaseOrders_InMoney = 0; double systemClosedPurchaseOrders_InQuantity = 0; decimal system_InProccessPurchaseOrders_InMoney = 0; double system_InProccessPurchaseOrders_InQuantity = 0; decimal systemCanceledPurchaseOrders_InMoney = 0; double systemCanceledPurchaseOrders_InQuantity = 0; decimal systemBackPurchaseOrders_InMoney = 0; double systemBackPurchaseOrderedOrders_InQuantity = 0; decimal systemPurchaseCredits_InMoney = 0; double systemPurchaseCredits_InQuantity = 0; decimal systemPurchaseQuotations_InMoney = 0; double systemPurchaseQuotations_InQuantity = 0; if (isAdmin) { systemOpenPurchaseOrders_InMoney = getPurchaseOrders_InMoney("", BuySellDocStateENUM.RequestUnconfirmed); systemOpenPurchaseOrders_InQuantity = getPurchaseOrders_Count("", BuySellDocStateENUM.RequestUnconfirmed); systemClosedPurchaseOrders_InMoney = getPurchaseOrders_InMoney(userId, BuySellDocStateENUM.Closed); systemClosedPurchaseOrders_InQuantity = getPurchaseOrders_Count("", BuySellDocStateENUM.Closed); system_InProccessPurchaseOrders_InMoney = getPurchaseOrders_InMoney(userId, BuySellDocStateENUM.InProccess); system_InProccessPurchaseOrders_InQuantity = getPurchaseOrders_Count("", BuySellDocStateENUM.InProccess); systemCanceledPurchaseOrders_InMoney = getPurchaseOrders_InMoney(userId, BuySellDocStateENUM.Canceled); systemCanceledPurchaseOrders_InQuantity = getPurchaseOrders_Count("", BuySellDocStateENUM.Canceled); systemBackPurchaseOrders_InMoney = getPurchaseOrders_InMoney(userId, BuySellDocStateENUM.BackOrdered); systemBackPurchaseOrderedOrders_InQuantity = getPurchaseOrders_Count("", BuySellDocStateENUM.BackOrdered); systemPurchaseCredits_InMoney = getPurchaseOrders_InMoney(userId, BuySellDocStateENUM.Credit); systemPurchaseCredits_InQuantity = getPurchaseOrders_Count("", BuySellDocStateENUM.Credit); systemPurchaseQuotations_InMoney = getPurchaseOrders_InMoney(userId, BuySellDocStateENUM.Quotation); systemPurchaseQuotations_InQuantity = getPurchaseOrders_Count("", BuySellDocStateENUM.Quotation); } userMoneyAccount.InitializePurchaseOrders( personOpenPurchaseOrders_InMoney, personOpenPurchaseOrders_InQuantity, personClosedPurchaseOrders_InMoney, personClosedPurchaseOrders_InQuantity, person_InProccessPurchaseOrders_InMoney, person_InProccessPurchaseOrders_InQuantity, personCanceledPurchaseOrders_InMoney, personCanceledPurchaseOrders_InQuantity, personBackPurchaseOrders_InMoney, personBackPurchaseOrderedOrders_InQuantity, personPurchaseCredits_InMoney, personPurchaseCredits_InQuantity, personPurchaseQuotations_InMoney, personPurchaseQuotations_InQuantity, systemOpenPurchaseOrders_InMoney, systemOpenPurchaseOrders_InQuantity, systemClosedPurchaseOrders_InMoney, systemClosedPurchaseOrders_InQuantity, system_InProccessPurchaseOrders_InMoney, system_InProccessPurchaseOrders_InQuantity, systemCanceledPurchaseOrders_InMoney, systemCanceledPurchaseOrders_InQuantity, systemBackPurchaseOrders_InMoney, systemBackPurchaseOrderedOrders_InQuantity, systemPurchaseCredits_InMoney, systemPurchaseCredits_InQuantity, systemPurchaseQuotations_InMoney, systemPurchaseQuotations_InQuantity); #endregion return(userMoneyAccount); }
IQueryable <BuySellDoc> getByDocumentType_For(string userId, IQueryable <BuySellDoc> iq_allOrders, BuySellDocumentTypeENUM buySellDocumentTypeEnum) { //userId.IsNullOrWhiteSpaceThrowArgumentException("You are not logged in."); switch (buySellDocumentTypeEnum) { case BuySellDocumentTypeENUM.Sale: { try { //all orders are returned because this is the admin //if (userId.IsNullOrWhiteSpace()) // return iq_allOrders; if (userId.IsNullOrWhiteSpace()) { return(BuySellDoc.IQueryable_GetSaleDocs(iq_allOrders, "")); } Owner owner = OwnerBiz.GetPlayerFor(userId); owner.IsNullThrowException("No Owner"); return(BuySellDoc.IQueryable_GetSaleDocs(iq_allOrders, owner.Id)); } catch (Exception e) { ErrorsGlobal.Add("Problem getting sales.", MethodBase.GetCurrentMethod(), e); throw new Exception(ErrorsGlobal.ToString()); } } case BuySellDocumentTypeENUM.Purchase: { try { //all orders are returned because this is the admin //if (userId.IsNullOrWhiteSpace()) // return iq_allOrders; if (userId.IsNullOrWhiteSpace()) { return(BuySellDoc.IQueryable_GetPurchaseDocs(iq_allOrders, "")); } Customer customer = CustomerBiz.GetPlayerFor(userId); customer.IsNullThrowException("Customer"); return(BuySellDoc.IQueryable_GetPurchaseDocs(iq_allOrders, customer.Id)); } catch (Exception e) { ErrorsGlobal.Add("Problem getting purchases", MethodBase.GetCurrentMethod(), e); throw new Exception(ErrorsGlobal.ToString()); } } case BuySellDocumentTypeENUM.Delivery: { try { //all orders are returned because this is the admin if (userId.IsNullOrWhiteSpace()) { return(BuySellDoc.IQueryable_GetDeliveryDocs(iq_allOrders, "")); } Deliveryman deliveryMan = DeliverymanBiz.GetPlayerFor(userId); deliveryMan.IsNullThrowException("deliveryMan"); return(BuySellDoc.IQueryable_GetDeliveryDocs(iq_allOrders, deliveryMan.Id)); } catch (Exception e) { ErrorsGlobal.Add("Problem getting purchases", MethodBase.GetCurrentMethod(), e); throw new Exception(ErrorsGlobal.ToString()); } } case BuySellDocumentTypeENUM.Salesman: { try { if (userId.IsNullOrWhiteSpace()) { return(BuySellDoc.IQueryable_GetSalesmanDocs(iq_allOrders, "")); } Salesman salesman = SalesmanBiz.GetPlayerFor(userId); salesman.IsNullThrowException("Salesman"); return(BuySellDoc.IQueryable_GetSalesmanDocs(iq_allOrders, salesman.Id)); } catch (Exception e) { ErrorsGlobal.Add("Problem getting purchases", MethodBase.GetCurrentMethod(), e); throw new Exception(ErrorsGlobal.ToString()); } } case BuySellDocumentTypeENUM.Unknown: default: throw new Exception("Unknown document type"); } }
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); } }
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); }