Exemplo n.º 1
0
        public BuySellDoc GetOpenSaleWithSameCustomerAndSeller(string customerId, string ownerProductChildId, ProductChild productChild)
        {
            customerId.IsNullThrowExceptionArgument("customerId");
            ownerProductChildId.IsNullThrowExceptionArgument("ownerProductChildId");
            productChild.IsNullThrowExceptionArgument("productChild");

            BuySellDoc buysSellDoc = FindAll().FirstOrDefault(x =>
                                                              x.CustomerId == customerId &&
                                                              x.OwnerId == ownerProductChildId &&
                                                              x.BuySellDocStateEnum == BuySellDocStateENUM.RequestUnconfirmed);

            //make sure the product addresses are also the same.
            if (buysSellDoc.IsNull())
            {
                return(buysSellDoc);
            }

            if (productChild.ShipFromAddress.IsNull())
            {
                productChild.ShipFromAddressId.IsNullOrWhiteSpaceThrowException();

                productChild.ShipFromAddress = AddressBiz.Find(productChild.ShipFromAddressId);
                productChild.ShipFromAddress.IsNullThrowException();
            }
            productChild.ShipFromAddressComplex = productChild.ShipFromAddress.ToAddressComplex();

            if (buysSellDoc.AddressShipFromComplex.Equals(productChild.ShipFromAddressComplex))
            {
                return(buysSellDoc);
            }

            return(null);
        }
Exemplo n.º 2
0
        private void AddShippingAddressToOwnerPersonIfItIsNew(ProductChild pc)
        {
            Owner productChildOwner = pc.Owner;

            productChildOwner.IsNullThrowException();
            Person ownerPerson = productChildOwner.Person;

            ownerPerson.IsNullThrowException();
            AddressBiz addressBiz = OwnerBiz.AddressBiz;

            //get the address from the productChild
            AddressComplex shipFromAddressComplexInProductChild = pc.ShipFromAddressComplex;

            shipFromAddressComplexInProductChild.ErrorCheck();

            //if there is no address... there should be an error.
            if (!shipFromAddressComplexInProductChild.Error.IsNullOrWhiteSpace())
            {
                throw new Exception("You need to add the address of where the product is sitting");
            }

            //address is complete.
            //We need to make the unique name from this so that we can check it exists in the db
            AddressMain addressToSave = addressBiz.Factory() as AddressMain;

            addressToSave.LoadFor(shipFromAddressComplexInProductChild);
            addressToSave.Name = addressToSave.MakeUniqueName();
            //locate this address in Person

            //get all the addresses for the ownerPerson
            List <AddressMain> allAddressForOwnerPerson = addressBiz.FindAll().Where(x => x.PersonId == ownerPerson.Id).ToList();

            if (allAddressForOwnerPerson.IsNull())
            {
                //no addresses found. Its empty...
                //so add the new address
                addNewAddress(pc, ownerPerson, addressBiz, addressToSave);
            }
            {
                //addresses have been found
                //we do not update old addresses, we just add new ones, if they change.
                AddressMain addressFound = allAddressForOwnerPerson.FirstOrDefault(x => x.Name.ToLower() == addressToSave.Name.ToLower());

                if (addressFound.IsNull())
                {
                    //the address was not found.
                    //AddressComplex contains a new address
                    //Add it to the person's addresses

                    addNewAddress(pc, ownerPerson, addressBiz, addressToSave);
                }
                //else
                //{
                //    updateAddress(pc, addressBiz, addressToSave);
                //}
            }

            //otherwise do nothing
        }
Exemplo n.º 3
0
        //PersonBiz _personBiz;


        public BankBiz(IRepositry <Bank> entityDal, BizParameters bizParameters, BankCategoryBiz bankCategoryBiz, AddressBiz addressBiz, CashTrxBiz cashTrxBiz)
            : base(entityDal, bizParameters, addressBiz, cashTrxBiz)
        {
            //_personBiz = personBiz;
            _bankCategoryBiz = bankCategoryBiz;
            _addressBiz      = addressBiz;
            _cashTrxBiz      = cashTrxBiz;
        }
Exemplo n.º 4
0
        public void AddPickupAddress(BuySellDoc buySellDoc)
        {
            //add the PickUp From Address to the Complex
            buySellDoc.AddressShipFromId.IsNullOrWhiteSpaceThrowException("AddressShipFromId");
            AddressMain addressShipFrom = AddressBiz.Find(buySellDoc.AddressShipFromId);

            addressShipFrom.IsNullThrowException("addressShipFrom");

            buySellDoc.AddressShipFromString  = addressShipFrom.AddressWithoutContacts();
            buySellDoc.AddressShipFromComplex = addressShipFrom.ToAddressComplex();
        }
Exemplo n.º 5
0
 private void fixBillTo(BuySellDoc buySellDoc)
 {
     if (buySellDoc.AddressBillToId.IsNullOrWhiteSpace())
     {
         buySellDoc.AddressBillToId = null;
     }
     else
     {
         buySellDoc.AddressBillTo = AddressBiz.Find(buySellDoc.AddressBillToId);
         buySellDoc.AddressBillTo.IsNullThrowException("Bill To Address not found");
     }
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
0
 public void FillAddressShipToComplex(BuySellDoc buySellDoc)
 {
     if (buySellDoc.AddressShipTo.IsNull())
     {
         if (buySellDoc.AddressShipToId.IsNullOrWhiteSpace())
         {
             buySellDoc.AddressShipToComplex = new AddressComplex();
             return;
         }
         buySellDoc.AddressShipTo = AddressBiz.Find(buySellDoc.AddressShipToId);
         buySellDoc.AddressShipTo.IsNullThrowException();
     }
     buySellDoc.AddressShipToComplex = buySellDoc.AddressShipTo.ToAddressComplex();
 }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        private static void addNewAddress(ProductChild pc, Person ownerPerson, AddressBiz addressBiz, AddressMain addressToSave)
        {
            pc.ShipFromAddressId = addressToSave.Id;

            if (addressToSave.ProductChilds.IsNull())
            {
                addressToSave.ProductChilds = new List <ProductChild>();
            }

            addressToSave.ProductChilds.Add(pc);

            ownerPerson.Addresses.Add(addressToSave);
            addressToSave.PersonId = ownerPerson.Id;
            addressBiz.Create(addressToSave);
        }
Exemplo n.º 10
0
        private void addNewAddress(ICommonWithId entity, Person person, AddressBiz addressBiz, AddressMain addressToSave)
        {
            ProductChild pc = entity as ProductChild;

            pc.IsNullThrowException();

            pc.ShipFromAddressId = addressToSave.Id;

            if (addressToSave.ProductChilds.IsNull())
            {
                addressToSave.ProductChilds = new List <ProductChild>();
            }

            addressToSave.ProductChilds.Add(pc);

            person.Addresses.Add(addressToSave);
            addressToSave.PersonId = person.Id;
            addressBiz.Create(addressToSave);
        }
Exemplo n.º 11
0
 private void loadAddressShipTo(BuySellDoc buysellDoc)
 {
     if (buysellDoc.AddressShipTo.IsNull())
     {
         if (buysellDoc.AddressShipToId.IsNullOrWhiteSpace())
         {
             //do nothing
         }
         else
         {
             buysellDoc.AddressShipTo        = AddressBiz.Find(buysellDoc.AddressShipToId);
             buysellDoc.AddressShipToComplex = buysellDoc.AddressShipTo.ToAddressComplex();
         }
     }
     else
     {
         buysellDoc.AddressShipToComplex = buysellDoc.AddressShipTo.ToAddressComplex();
     }
 }
Exemplo n.º 12
0
        private void createAndAssignNew_ShipToAddress(BuySellDoc buySellDoc)
        {
            AddressMain addressToSave = AddressBiz.Factory() as AddressMain;

            addressToSave.LoadFor(buySellDoc.AddressShipToComplex);
            addressToSave.Name = addressToSave.MakeUniqueName();

            if (addressToSave.BuySellDocs.IsNull())
            {
                addressToSave.BuySellDocs = new List <BuySellDoc>();
            }

            addressToSave.BuySellDocs.Add(buySellDoc);

            addressToSave.PersonId = buySellDoc.Customer.PersonId;
            buySellDoc.Customer.Person.Addresses.Add(addressToSave);

            buySellDoc.AddressShipToId = addressToSave.Id;
            AddressBiz.Create(addressToSave);
        }
Exemplo n.º 13
0
        public async Task <IActionResult> GetMemberInfoAsync(string userGuid)
        {
            if (string.IsNullOrWhiteSpace(userGuid))
            {
                return(Failed(ErrorCode.UserData));
            }
            UserBiz userBiz = new UserBiz();
            var     ressult = await userBiz.GetAsync(userGuid);

            if (ressult == null)
            {
                return(Failed(ErrorCode.UserData, "userGuid错误"));
            }
            var response = ressult.ToDto <GetMemberInfoResponseDto>();
            //获取用户消费信息
            var consumer = await userBiz.GetConsumerAsync(userGuid);

            if (consumer != null)
            {
                response.LastBuyDate      = (DateTime?)consumer?.LastBuyDate;
                response.OrderAverage     = (decimal)consumer?.OrderAverage;
                response.OrderQty         = (int)consumer?.OrderQty;
                response.OrderTotalAmount = (decimal)consumer?.OrderTotalAmount;
            }
            //消费者
            var consumer2 = await new ConsumerBiz().GetAsync(userGuid);

            if (consumer2 != null)
            {
                response.Recommended = (await userBiz.GetAsync(consumer2.RecommendGuid))?.UserName;
            }
            var address = new AddressBiz().GetUserDefaultAddress(userGuid);

            response.Address = $"{address?.Province}{address?.City}{address?.Area}{address?.DetailAddress}";
            return(Success(response));
        }
Exemplo n.º 14
0
 private void updateAddress(ProductChild pc, AddressBiz addressBiz, AddressMain addressToSave)
 {
     pc.ShipFromAddressId = addressToSave.Id;
     addressBiz.Update(addressToSave);
 }
Exemplo n.º 15
0
 public ProductApproverBiz(IRepositry <ProductApprover> entityDal, BizParameters bizParameters, ProductApproverCategoryBiz ownerCategoryBiz, AddressBiz addressBiz, CashTrxBiz cashTrxBiz)
     : base(entityDal, bizParameters, addressBiz, cashTrxBiz)
 {
     _productApproverBiz = ownerCategoryBiz;
 }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
0
        //PersonBiz _personBiz;

        public CashierBiz(IRepositry <Cashier> entityDal, BizParameters bizParameters, CashierCategoryBiz cashierCategoryBiz, AddressBiz addressBiz, CashTrxBiz cashTrxBiz)
            : base(entityDal, bizParameters, addressBiz, cashTrxBiz)
        {
            //_personBiz = personBiz;
            _cashierCategoryBiz = cashierCategoryBiz;
        }
Exemplo n.º 18
0
 public SelectList SelectListBillAddressesFor(string userId)
 {
     return(AddressBiz.SelectListBillAddressCurrentUser());
 }
Exemplo n.º 19
0
 public CustomerBiz(IRepositry <Customer> entityDal, BizParameters bizParameters, CustomerCategoryBiz customerCategoryBiz, AddressBiz addressBiz, CashTrxBiz cashTrxBiz)
     : base(entityDal, bizParameters, addressBiz, cashTrxBiz)
 {
     _customerCategoryBiz = customerCategoryBiz;
     _cashTrxBiz          = cashTrxBiz;
 }
Exemplo n.º 20
0
 public BusinessLayerPlayer(IRepositry <TEntity> dal, BizParameters param, AddressBiz addressBiz, CashTrxBiz cashTrxBiz)
     : base(dal, param)
 {
     _addressBiz = addressBiz;
     _cashTrxBiz = cashTrxBiz;
 }
Exemplo n.º 21
0
        /// <summary>
        /// This returns the new address Id, or null.
        /// </summary>
        /// <param name="buySellDoc"></param>
        /// <param name="addressComplex"></param>
        /// <returns></returns>
        private bool isNewAddress(BuySellDoc buySellDoc, AddressComplex addressComplex, out string addressFoundId)
        {
            addressFoundId = "";
            if (addressComplex.IsNull())
            {
                return(false);
            }

            buySellDoc.IsNullThrowException();

            Customer customer = buySellDoc.Customer;

            customer.IsNullThrowException();

            Person person = customer.Person;

            person.IsNullThrowException();

            addressComplex.ErrorCheck();
            //if there is no address... there should be an error.
            if (!addressComplex.Error.IsNullOrWhiteSpace())
            {
                throw new Exception(addressComplex.Error);
            }

            //address is complete.
            //We need to make the unique name from this so that we can check it exists in the db
            AddressMain addressToSave = AddressBiz.Factory() as AddressMain;

            addressToSave.LoadFor(addressComplex);
            addressToSave.Name = addressToSave.MakeUniqueName();

            //locate this address in Person

            //get all the addresses for the ownerPerson
            List <AddressMain> allAddressForOwnerPerson = AddressBiz.FindAll().Where(x => x.PersonId == person.Id).ToList();

            if (allAddressForOwnerPerson.IsNull())
            {
                //no addresses found. Its empty...
                //so add the new address
                return(true);
            }
            else
            {
                //addresses have been found
                //we do not update old addresses, we just add new ones, if they change.
                AddressMain addressFound = allAddressForOwnerPerson.FirstOrDefault(x => x.Name.ToLower() == addressToSave.Name.ToLower());

                if (addressFound.IsNull())
                {
                    //the address was not found.
                    //AddressComplex contains a new address
                    //Add it to the person's addresses

                    return(true);
                }
                else
                {
                    addressFoundId = addressFound.Id;
                }
            }

            return(false);
        }
Exemplo n.º 22
0
        //PersonBiz _personBiz;

        public SalesmanBiz(IRepositry <Salesman> entityDal, BizParameters bizParameters, SalesmanCategoryBiz salesmanCategoryBiz, AddressBiz addressBiz, CashTrxBiz cashTrxBiz)
            : base(entityDal, bizParameters, addressBiz, cashTrxBiz)
        {
            //_personBiz = personBiz;
            _salesmanCategoryBiz = salesmanCategoryBiz;
        }
Exemplo n.º 23
0
 public void load_ShipAddress_SelectList_Into_BuySellDoc(BuySellDoc buySellDoc)
 {
     buySellDoc.Customer.IsNullThrowException();
     buySellDoc.SelectListAddressBillTo = AddressBiz.SelectListShipAddressForPerson(buySellDoc.Customer.PersonId);
 }
Exemplo n.º 24
0
 public DeliverymanBiz(IRepositry <Deliveryman> entityDal, BizParameters bizParameters, DeliverymanCategoryBiz deliverymanCategoryBiz, AddressBiz addressBiz, CashTrxBiz cashTrxBiz)
     : base(entityDal, bizParameters, addressBiz, cashTrxBiz)
 {
     //_userBiz = userBiz;
     _deliverymanCategoryBiz = deliverymanCategoryBiz;
 }
Exemplo n.º 25
0
 public OwnerBiz(IRepositry <Owner> entityDal, BizParameters bizParameters, OwnerCategoryBiz ownerCategoryBiz, AddressBiz addressBiz, CashTrxBiz cashTrxBiz)
     : base(entityDal, bizParameters, addressBiz, cashTrxBiz)
 {
     _ownerCategoryBiz = ownerCategoryBiz;
 }
Exemplo n.º 26
0
        //readonly UserBiz _userBiz;
        //PersonBiz _personBiz;

        public MailerBiz(IRepositry <Mailer> entityDal, BizParameters bizParameters, AddressBiz addressBiz, CashTrxBiz cashTrxBiz)
            : base(entityDal, bizParameters, addressBiz, cashTrxBiz)
        {
            //_personBiz = personBiz;
            //_userBiz = userBiz;
        }