Example #1
0
 private void calculate_Owner_Payment(BuySellDoc bsd, PersonPayingPenalty ppp, decimal totalPaymentAmount)
 {
     ppp.From.Person = OwnerBiz.GetPersonForPlayer(bsd.OwnerId);
     ppp.From.Person.IsNullThrowException();
     ppp.From.Amount  = totalPaymentAmount;
     ppp.From.Comment = "Owner";
 }
Example #2
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);
                    }
                }
            }
        }
Example #3
0
        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);
        }
Example #4
0
 public MessageBiz(IRepositry <Message> entityDal, BizParameters bizParameters, PersonBiz personBiz, ProductBiz productBiz, OwnerBiz ownerBiz, PeopleMessageBiz peopleMessageBiz)
     : base(entityDal, bizParameters)
 {
     _personBiz        = personBiz;
     _productBiz       = productBiz;
     _ownerBiz         = ownerBiz;
     _peopleMessageBiz = peopleMessageBiz;
 }
Example #5
0
 public SaleOrderBiz(Repositry <BuySellDoc> entityDal, BizParameters bizParameters, OwnerBiz ownerBiz, CustomerBiz customerBiz, ProductBiz productBiz, BuySellDocBiz buySellDocBiz)
     : base(entityDal, bizParameters, ownerBiz, customerBiz, productBiz)
 {
     _ownerBiz     = ownerBiz;
     _customerBiz  = customerBiz;
     _productBiz   = productBiz;
     buySellDocBiz = _buySellDocBiz;
 }
Example #6
0
 public ProductBiz(UserBiz userBiz, IRepositry <Product> entityDal, MyWorkClassesProduct myWorkClassesProduct, ProductChildBiz productChildBiz, BizParameters bizParameters, LikeUnlikeBiz likeUnlikeBiz, OwnerBiz ownerBiz)
     : base(entityDal, bizParameters)
 {
     _myWorkClassesProduct = myWorkClassesProduct;
     _userBiz         = userBiz;
     _productChildBiz = productChildBiz;
     _likeUnlikeBiz   = likeUnlikeBiz;
     _ownerBiz        = ownerBiz;
     _bizParameters   = bizParameters;
 }
Example #7
0
        public override IList <ICommonWithId> GetListForIndex()
        {
            UserId.IsNullOrWhiteSpaceThrowException("You are not logged in");
            Owner owner = OwnerBiz.GetOwnerForUser(UserId);

            owner.IsNullThrowException("Owner not found.");

            IList <ProductChild> lst = FindAll().Where(x => x.OwnerId == owner.Id && x.Hide == IsShowHidden).ToList() as IList <ProductChild>;

            return(lst.Cast <ICommonWithId>().ToList());
        }
Example #8
0
 public MenuBiz(MenuPathMainBiz menuPathMainBiz, ProductBiz productBiz, IRepositry <MenuPathMain> entityDal, BizParameters bizParameters, CashTrxBiz cashTrxBiz, BankBiz bankBiz, OwnerBiz ownerBiz, AddressBiz addressBiz)
     : base(entityDal, bizParameters)
 {
     _menuPathMainBiz = menuPathMainBiz;
     _productBiz      = productBiz;
     _productChildBiz = productBiz.ProductChildBiz;
     //_likeUnlikeBiz = likeUnlikeBiz;
     _cashTrxBiz = cashTrxBiz;
     _bankBix    = bankBiz;
     _ownerBiz   = ownerBiz;
     //_addressBiz = addressBiz;
     _addressBiz = addressBiz;
 }
 /// <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;
         }
     }
 }
Example #10
0
        public void LoadSelectListsFor_GET(BuySellDoc buySellDoc)
        {
            buySellDoc.SelectListCustomer            = CustomerBiz.SelectList();
            buySellDoc.SelectListOwner               = OwnerBiz.SelectList();
            buySellDoc.SelectListAddressInformTo     = AddressBiz.SelectListInformAddressFor(UserId);
            buySellDoc.SelectListAddressShipTo       = AddressBiz.SelectListShipAddressFor(UserId);
            buySellDoc.SelectListVehicalTypeAccepted = VehicalTypeBiz.SelectList();

            load_VehicalTypeRequested_SelectList_Into_BuySellDoc(buySellDoc);
            load_VehicalTypeOffered_SelectList_Into_BuySellDoc(buySellDoc);
            load_Deliverymen_SelectList_Into_BuySellDoc(buySellDoc);
            load_Freight_Request_Into_String_Field(buySellDoc);
            load_ShipAddress_SelectList_Into_BuySellDoc(buySellDoc);
            load_Salesmen_SelectList_Into_BuySellDoc(buySellDoc);
        }
Example #11
0
 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;
 }
Example #12
0
        public BuySellDocumentTypeENUM IsSaleOrPurchaseOrDelivery(BuySellDoc buySellDoc)
        {
            if (buySellDoc.BuySellDocumentTypeEnum == BuySellDocumentTypeENUM.Delivery)
            {
                return(BuySellDocumentTypeENUM.Delivery);
            }

            if (buySellDoc.CustomerId.IsNullOrWhiteSpace() && buySellDoc.OwnerId.IsNullOrWhiteSpace())
            {
                ErrorsGlobal.Add("Both Customer and Owner are empty.", "Event_CreateViewAndSetupSelectList");
                throw new Exception();
            }

            if (buySellDoc.CustomerId.IsNullOrWhiteSpace())
            {
                //this is a purchase order
                return(BuySellDocumentTypeENUM.Sale);
            }
            if (buySellDoc.OwnerId.IsNullOrWhiteSpace())
            {
                //this is a sale.
                return(BuySellDocumentTypeENUM.Purchase);
            }

            ApplicationUser ownerUser = OwnerBiz.GetUserForEntityrWhoIsNotAdminFor(buySellDoc.OwnerId);

            ownerUser.IsNullThrowException();

            if (UserId == ownerUser.Id)
            {
                return(BuySellDocumentTypeENUM.Sale);
            }



            //get the CustomerUser
            ApplicationUser customerUser = CustomerBiz.GetUserForEntityrWhoIsNotAdminFor(buySellDoc.CustomerId);

            customerUser.IsNullThrowException();
            if (UserId == customerUser.Id)
            {
                return(BuySellDocumentTypeENUM.Purchase);
            }

            //if(buySellDoc.)
            throw new Exception("Unknown type");
        }
Example #13
0
        private void calculate_Owner_Amount_When_Receiving_Penalty(BuySellDoc bsd, Person systemPerson, PersonPayingPenalty ppp, decimal totalPaymentAmount)
        {
            ppp.Owner.Clear();
            //get the maximum commission payable on the freight and sale
            decimal maxPayableAccordingToMaxCommission_Amount = getFreightAndProductCommissionAdded(bsd) * totalPaymentAmount;


            ppp.Owner.Person = OwnerBiz.GetPersonForPlayer(bsd.OwnerId);
            ppp.Owner.Person.IsNullThrowException();
            ppp.Owner.Comment = "Owner";
            ppp.Owner.Amount  = totalPaymentAmount - maxPayableAccordingToMaxCommission_Amount;

            if (ppp.Owner.Amount != 0)
            {
                ppp.Owner.Percent = ppp.Owner.Amount / totalPaymentAmount;
            }
        }
Example #14
0
        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);
        }
Example #15
0
        //private void fixDeliveryMan(BuySellDoc buySellDoc)
        //{
        //    if (buySellDoc.DeliverymanId.IsNullOrWhiteSpace())
        //    {
        //        buySellDoc.DeliverymanId = null;
        //    }
        //}

        private void fixSeller(BuySellDoc buySellDoc)
        {
            if (buySellDoc.OwnerId.IsNullOrWhiteSpace())
            {
                if (buySellDoc.Owner.IsNull())
                {
                    throw new Exception("No owner found!");
                }
                buySellDoc.OwnerId = buySellDoc.Owner.Id;
            }
            else
            {
                if (buySellDoc.Owner.IsNull())
                {
                    buySellDoc.Owner = OwnerBiz.Find(buySellDoc.OwnerId);
                    buySellDoc.Owner.IsNullThrowException("Owner not found");
                }
            }
        }
Example #16
0
        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);
        }
Example #17
0
        /// <summary>
        /// This throws an exception if the deliveryman and the vendor are the same.
        /// </summary>
        /// <param name="freightOfferAcceptedTrx"></param>
        /// <param name="buyselldoc"></param>
        private void exceptionSellerAndDeliveryManIsTheSame(FreightOfferTrx freightOfferAcceptedTrx, BuySellDoc buyselldoc)
        {
            //do not allow if the DeliveryPerson and the VendorPerson and currentUser are the same
            UserId.IsNullOrWhiteSpaceThrowException();

            Person deliveryPerson = DeliverymanBiz.GetPersonForPlayer(freightOfferAcceptedTrx.DeliverymanId);
            Person sellerPerson   = OwnerBiz.GetPersonForPlayer(buyselldoc.OwnerId);
            Person userPerson     = UserBiz.GetPersonFor(UserId);

            deliveryPerson.IsNullThrowException();
            sellerPerson.IsNullThrowException();
            deliveryPerson.Id.IsNullOrWhiteSpaceThrowException();
            sellerPerson.Id.IsNullOrWhiteSpaceThrowException();
            userPerson.IsNullThrowException();

            if (deliveryPerson.Id == sellerPerson.Id && userPerson.Id == sellerPerson.Id && buyselldoc.BuySellDocStateEnum == BuySellDocStateENUM.ReadyForPickup)
            {
                throw new Exception("You are the seller. You cannot bid for this. If you want to deliver the item, ask the customer to accept you.");
            }
        }
Example #18
0
        //public override async Task<IList<ICommonWithId>> GetListForIndexAsync(ControllerIndexParams parameters)
        //{
        //    IList<ProductChild> lst = await FindAllAsync();
        //    lst = lst.Where(x => x.Hide == IsDontShowHidden).ToList() as IList<ProductChild>;
        //    return lst.Cast<ICommonWithId>().ToList();
        //}
        public override async Task <IList <ICommonWithId> > GetListForIndexAsync(ControllerIndexParams parameters)
        {
            //var lstEntities = await FindAllAsync();
            UserId.IsNullOrWhiteSpaceThrowException("You are not logged in");
            Owner owner = OwnerBiz.GetOwnerForUser(UserId);

            owner.IsNullThrowException("Owner not found.");
            List <ProductChild> lstEntities;

            if (IsShowHidden)
            {
                lstEntities = await FindAll().Where(x => x.OwnerId == owner.Id && x.Hide == IsShowHidden).ToListAsync();
            }
            else
            {
                lstEntities = await FindAll().Where(x => x.OwnerId == owner.Id).ToListAsync();
            }
            IList <ICommonWithId> lstIcom = lstEntities.Cast <ICommonWithId>().ToList();

            return(lstIcom);
        }
Example #19
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);
        }
Example #20
0
        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);
        }
Example #21
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);
        }
Example #22
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);
        }
Example #23
0
        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");
            }
        }
Example #24
0
        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);
            }
        }
Example #25
0
        private void createMessageFor(RejectCancelDeleteInbetweenClass rcdbc, BuySellDoc buySellDoc)
        {
            string        fromPersonId   = "";
            string        toPersonId     = "";
            Person        fromPerson     = null;
            List <string> listOfToPeople = new List <string>();

            string buySellDocId   = buySellDoc.Id;
            Person ownerPerson    = OwnerBiz.GetPersonForPlayer(buySellDoc.OwnerId);
            Person customerPerson = CustomerBiz.GetPersonForPlayer(buySellDoc.CustomerId);

            ownerPerson.IsNullThrowException();
            customerPerson.IsNullThrowException();
            switch (buySellDoc.BuySellDocumentTypeEnum)
            {
            case BuySellDocumentTypeENUM.Sale:
                fromPersonId = ownerPerson.Id;
                fromPerson   = ownerPerson;
                toPersonId   = customerPerson.Id;
                listOfToPeople.Add(toPersonId);
                break;

            case BuySellDocumentTypeENUM.Purchase:
                toPersonId   = ownerPerson.Id;
                fromPersonId = customerPerson.Id;
                fromPerson   = customerPerson;
                listOfToPeople.Add(toPersonId);

                break;

            case BuySellDocumentTypeENUM.Delivery:
                Person deliveryPerson = DeliverymanBiz.GetPersonForPlayer(buySellDoc.DeliverymanId);
                deliveryPerson.IsNullThrowException();

                fromPersonId = deliveryPerson.Id;
                fromPerson   = deliveryPerson;
                listOfToPeople.Add(ownerPerson.Id);
                listOfToPeople.Add(customerPerson.Id);
                break;

            case BuySellDocumentTypeENUM.Unknown:
            default:
                throw new Exception("Unknown document type");
            }

            Message message = new Message(
                fromPersonId,
                fromPerson,
                listOfToPeople,
                rcdbc.Subject,
                rcdbc.Comment,
                MessageENUM.Free,
                null);

            if (buySellDoc.Messages.IsNull())
            {
                buySellDoc.Messages = new List <Message>();
            }

            buySellDoc.Messages.Add(message);
            message.BuySellDocId = buySellDoc.Id;

            message.ListOfToPeopleId.IsNullOrEmptyThrowException();
            foreach (var pplId in message.ListOfToPeopleId)
            {
                Person person = PersonBiz.Find(pplId);
                person.IsNullThrowException();

                PeopleMessage pplMsg = new PeopleMessage();
                pplMsg.IsNullThrowException();
                pplMsg.PersonId  = pplId;
                pplMsg.Person    = person;
                pplMsg.MessageId = message.Id;
                PeopleMessageBiz.Create(pplMsg);
            }
            MessageBiz.Create(message);
        }
Example #26
0
        //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);
        }
Example #27
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);
        }
Example #28
0
 public ProductChildBiz(IRepositry <ProductChild> entityDal, BizParameters bizParameters, OwnerBiz ownerBiz, ProductChildFeatureBiz productChildFeatureBiz)
     : base(entityDal, bizParameters)
 {
     _ownerBiz = ownerBiz;
     _productChildFeatureBiz = productChildFeatureBiz;
 }