Exemplo n.º 1
0
        public Purchaser AddOrUpdatePurchaser(int clientId, bool active)
        {
            var client = Require <Data.ClientInfo>(x => x.ClientID, clientId);

            var purch = DataSession.Query <Ordering.Purchaser>().FirstOrDefault(x => x.Client.ClientID == clientId);

            if (purch == null)
            {
                purch = new Ordering.Purchaser()
                {
                    Client  = Require <Data.Client>(x => x.ClientID, clientId),
                    Active  = active,
                    Deleted = false
                };

                DataSession.Insert(purch);
            }
            else
            {
                purch.Active  = active;
                purch.Deleted = false;
            }

            return(CreatePurchaser(purch, client));
        }
Exemplo n.º 2
0
        private Purchaser CreatePurchaser(Ordering.Purchaser purchaser, Data.ClientInfo client)
        {
            if (purchaser == null || client == null)
            {
                return(null);
            }

            return(new Purchaser()
            {
                PurchaserID = purchaser.PurchaserID,
                ClientID = client.ClientID,
                UserName = client.UserName,
                LName = client.LName,
                FName = client.FName,
                Email = client.Email,
                Phone = client.Phone,
                Active = purchaser.Active,
                Deleted = purchaser.Deleted
            });
        }