Ejemplo n.º 1
0
        private static void loadPhoneCardAndRetailAccount(Rbr_Db pDb, long pSerial, long pPin, InventoryCommandRequest pInventoryCommandRequest)
        {
            //PoneCard status = Loaded | (Activeted if Activate on load)
            //RetAcct  status = Active, date_active = pInventoryCommandRequest.DateCreated

            RetailAccountRow _retailAccountRow = createRetailAccount(pDb, pInventoryCommandRequest);

            var _phoneCardRow = new PhoneCardRow();

            //TODO: !!! setup new dates here...
            if (pInventoryCommandRequest.ActivateOnLoad)
            {
                _phoneCardRow.InventoryStatus = InventoryStatus.Activated;
                _phoneCardRow.CardStatus      = Status.Active;
                _phoneCardRow.Date_active     = pInventoryCommandRequest.DateActive;
            }
            else
            {
                _phoneCardRow.InventoryStatus   = InventoryStatus.Loaded;
                _phoneCardRow.CardStatus        = Status.Pending;
                _phoneCardRow.IsDate_activeNull = true;
            }
            _phoneCardRow.Pin            = pPin;
            _phoneCardRow.Retail_acct_id = _retailAccountRow.Retail_acct_id;
            _phoneCardRow.Serial_number  = pSerial;
            _phoneCardRow.Service_id     = pInventoryCommandRequest.ServiceId;

            _phoneCardRow.Date_loaded            = pInventoryCommandRequest.DateCreated;
            _phoneCardRow.Date_to_expire         = pInventoryCommandRequest.DateToExpire;
            _phoneCardRow.IsDate_deactivatedNull = true;
            _phoneCardRow.IsDate_archivedNull    = true;

            pDb.PhoneCardCollection.Insert(_phoneCardRow);
            TimokLogger.Instance.LogRbr(LogSeverity.Debug, "InventoryController.loadPhoneCardAndRetailAccount", string.Format("PhoneCardRow inserted, Serial={0}", _phoneCardRow.Serial_number));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a new record into the <c>RetailAccount</c> table.
        /// </summary>
        /// <param name="value">The <see cref="RetailAccountRow"/> object to be inserted.</param>
        public virtual void Insert(RetailAccountRow value)
        {
            string sqlStr = "INSERT INTO [dbo].[RetailAccount] (" +
                            "[retail_acct_id], " +
                            "[customer_acct_id], " +
                            "[date_to_expire], " +
                            "[status], " +
                            "[start_balance], " +
                            "[start_bonus_minutes]" +
                            ") VALUES (" +
                            _db.CreateSqlParameterName("Retail_acct_id") + ", " +
                            _db.CreateSqlParameterName("Customer_acct_id") + ", " +
                            _db.CreateSqlParameterName("Date_to_expire") + ", " +
                            _db.CreateSqlParameterName("Status") + ", " +
                            _db.CreateSqlParameterName("Start_balance") + ", " +
                            _db.CreateSqlParameterName("Start_bonus_minutes") + ")";
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Retail_acct_id", value.Retail_acct_id);
            AddParameter(cmd, "Customer_acct_id", value.Customer_acct_id);
            AddParameter(cmd, "Date_to_expire", value.Date_to_expire);
            AddParameter(cmd, "Status", value.Status);
            AddParameter(cmd, "Start_balance", value.Start_balance);
            AddParameter(cmd, "Start_bonus_minutes", value.Start_bonus_minutes);
            cmd.ExecuteNonQuery();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Reads data from the provided data reader and returns
        /// an array of mapped objects.
        /// </summary>
        /// <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param>
        /// <param name="startIndex">The index of the first record to map.</param>
        /// <param name="length">The number of records to map.</param>
        /// <param name="totalRecordCount">A reference parameter that returns the total number
        /// of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param>
        /// <returns>An array of <see cref="RetailAccountRow"/> objects.</returns>
        protected virtual RetailAccountRow[] MapRecords(IDataReader reader,
                                                        int startIndex, int length, ref int totalRecordCount)
        {
            if (0 > startIndex)
            {
                throw new ArgumentOutOfRangeException("startIndex", startIndex, "StartIndex cannot be less than zero.");
            }
            if (0 > length)
            {
                throw new ArgumentOutOfRangeException("length", length, "Length cannot be less than zero.");
            }

            int retail_acct_idColumnIndex        = reader.GetOrdinal("retail_acct_id");
            int customer_acct_idColumnIndex      = reader.GetOrdinal("customer_acct_id");
            int date_createdColumnIndex          = reader.GetOrdinal("date_created");
            int date_activeColumnIndex           = reader.GetOrdinal("date_active");
            int date_to_expireColumnIndex        = reader.GetOrdinal("date_to_expire");
            int date_expiredColumnIndex          = reader.GetOrdinal("date_expired");
            int statusColumnIndex                = reader.GetOrdinal("status");
            int start_balanceColumnIndex         = reader.GetOrdinal("start_balance");
            int current_balanceColumnIndex       = reader.GetOrdinal("current_balance");
            int start_bonus_minutesColumnIndex   = reader.GetOrdinal("start_bonus_minutes");
            int current_bonus_minutesColumnIndex = reader.GetOrdinal("current_bonus_minutes");

            System.Collections.ArrayList recordList = new System.Collections.ArrayList();
            int ri = -startIndex;

            while (reader.Read())
            {
                ri++;
                if (ri > 0 && ri <= length)
                {
                    RetailAccountRow record = new RetailAccountRow();
                    recordList.Add(record);

                    record.Retail_acct_id        = Convert.ToInt32(reader.GetValue(retail_acct_idColumnIndex));
                    record.Customer_acct_id      = Convert.ToInt16(reader.GetValue(customer_acct_idColumnIndex));
                    record.Date_created          = Convert.ToDateTime(reader.GetValue(date_createdColumnIndex));
                    record.Date_active           = Convert.ToDateTime(reader.GetValue(date_activeColumnIndex));
                    record.Date_to_expire        = Convert.ToDateTime(reader.GetValue(date_to_expireColumnIndex));
                    record.Date_expired          = Convert.ToDateTime(reader.GetValue(date_expiredColumnIndex));
                    record.Status                = Convert.ToByte(reader.GetValue(statusColumnIndex));
                    record.Start_balance         = Convert.ToDecimal(reader.GetValue(start_balanceColumnIndex));
                    record.Current_balance       = Convert.ToDecimal(reader.GetValue(current_balanceColumnIndex));
                    record.Start_bonus_minutes   = Convert.ToInt16(reader.GetValue(start_bonus_minutesColumnIndex));
                    record.Current_bonus_minutes = Convert.ToInt16(reader.GetValue(current_bonus_minutesColumnIndex));

                    if (ri == length && 0 != totalRecordCount)
                    {
                        break;
                    }
                }
            }

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((RetailAccountRow[])(recordList.ToArray(typeof(RetailAccountRow))));
        }
Ejemplo n.º 4
0
        //-------------------------------------------------- Privates -------------------------------------------------------------

        RetailAccountDto get(Rbr_Db pDb, RetailAccountRow pRetailAccountRow)
        {
            if (pRetailAccountRow != null)
            {
                CustomerAcctRow _customerAcctRow = CustomerAcctManager.Get(pDb, pRetailAccountRow.Customer_acct_id);
                return(get(pDb, _customerAcctRow.Service_id, pRetailAccountRow));
            }
            return(null);
        }
Ejemplo n.º 5
0
        internal RetailAccountDto GetByPIN(Rbr_Db pDb, short pServiceId, long pPIN)
        {
            PhoneCardRow _phoneCardRow = pDb.PhoneCardCollection.GetByPrimaryKey(pServiceId, pPIN);

            if (_phoneCardRow != null)
            {
                RetailAccountRow _retailAccountRow = pDb.RetailAccountCollection.GetByPrimaryKey(_phoneCardRow.Retail_acct_id);
                return(get(pDb, pServiceId, _retailAccountRow));
            }
            return(null);
        }
Ejemplo n.º 6
0
        internal RetailAccountDto GetByANI(Rbr_Db pDb, short pServiceId, long pANI)
        {
            ResidentialPSTNRow _residentialPSTNRow = pDb.ResidentialPSTNCollection.GetByPrimaryKey(pServiceId, pANI);

            if (_residentialPSTNRow != null)
            {
                RetailAccountRow _retailAccountRow = pDb.RetailAccountCollection.GetByPrimaryKey(_residentialPSTNRow.Retail_acct_id);
                return(get(pDb, pServiceId, _retailAccountRow));
            }
            return(null);
        }
Ejemplo n.º 7
0
        internal RetailAccountDto GetByVoIPUserId(Rbr_Db pDb, short pServiceId, string pUserId)
        {
            ResidentialVoIPRow _residentialVoIPRow = pDb.ResidentialVoIPCollection.GetByPrimaryKey(pUserId);

            if (_residentialVoIPRow != null)
            {
                RetailAccountRow _retailAccountRow = pDb.RetailAccountCollection.GetByPrimaryKey(_residentialVoIPRow.Retail_acct_id);
                return(get(pDb, pServiceId, _retailAccountRow));
            }
            return(null);
        }
        public static void Update(string pSalt, RetailAccountDto pRetailAccount)
        {
            if (pRetailAccount.AccessEnabled && (pRetailAccount.Person.Salt == null || pRetailAccount.Person.Salt.Trim().Length == 0))
            {
                pRetailAccount.Person.Salt = pSalt;
            }

            using (var _db = new Rbr_Db()) {
                using (var _tx = new Transaction(_db, pSalt, pRetailAccount)) {
                    RetailAccountRow _originalRetailAccountRow = RetailAccountManager.Instance.Get(_db, pRetailAccount.RetailAcctId);
                    RetailAccountRow _retailAccountRow         = RetailAccountManager.MapToRetailAccountRow(pRetailAccount);

                    if (_originalRetailAccountRow.AccountStatus != Status.Active && _retailAccountRow.AccountStatus == Status.Active && _retailAccountRow.Date_active == Configuration.Instance.Db.SqlSmallDateTimeMaxValue)
                    {
                        _retailAccountRow.Date_active = DateTime.Today;
                    }

                    if (pRetailAccount.AccessEnabled)
                    {
                        pRetailAccount.Person.RetailAcctId = pRetailAccount.RetailAcctId;
                        PersonManager.Save(_db, pSalt, pRetailAccount.Person);
                    }
                    else
                    {
                        PersonManager.DeleteByRetailAcctId(_db, pRetailAccount.RetailAcctId);
                    }

                    RetailAccountManager.Instance.Update(_db, _retailAccountRow);

                    if (pRetailAccount.PhoneCards != null && pRetailAccount.PhoneCards.Length > 0)
                    {
                        //Update PhoneCard
                        //TODO: now works only with 1 (one) PhoneCard per RetailAcct
                        PhoneCardRow _phoneCardRow = RetailAccountManager.MapToPhoneCardRow(pRetailAccount.PhoneCards[0]);
                        _phoneCardRow.CardStatus = pRetailAccount.Status;
                        RetailAccountManager.UpdatePhoneCard(_db, _phoneCardRow);
                    }

                    if (pRetailAccount.ResidentialPSTNs != null && pRetailAccount.ResidentialPSTNs.Length > 0)
                    {
                        //Update ResidentialPSTN
                        //TODO: now works only with 1 (one) PSTN # per RetailAcct
                        ResidentialPSTNRow _residentialPSTNRow = RetailAccountManager.MapToResidentialPSTNRow(pRetailAccount.ResidentialPSTNs[0]);
                        _residentialPSTNRow.AccountStatus = pRetailAccount.Status;
                        RetailAccountManager.UpdateResidentialPSTNSubAcct(_db, _residentialPSTNRow);
                    }

                    _tx.Commit();
                }
            }
        }
Ejemplo n.º 9
0
        internal static RetailAccountRow[] MapToRetailAccountRows(RetailAccountDto[] pRetailAccounts)
        {
            var _list = new ArrayList();

            if (pRetailAccounts != null)
            {
                foreach (RetailAccountDto _retailAccount in pRetailAccounts)
                {
                    RetailAccountRow _retailAccountRow = MapToRetailAccountRow(_retailAccount);
                    _list.Add(_retailAccountRow);
                }
            }
            return((RetailAccountRow[])_list.ToArray(typeof(RetailAccountRow)));
        }
Ejemplo n.º 10
0
        RetailAccountDto get(Rbr_Db pDb, short pServiceId, RetailAccountRow pRetailAccountRow)
        {
            if (pRetailAccountRow != null)
            {
                ServiceRow       _serviceRow    = ServiceManager.Get(pDb, pServiceId);
                RetailAccountDto _retailAccount = mapToRetailAccount(pRetailAccountRow);
                _retailAccount.ServiceId  = pServiceId;
                _retailAccount.RetailType = _serviceRow.RetailType;

                _retailAccount.Person = PersonManager.GetByRetailAcctId(pDb, pRetailAccountRow.Retail_acct_id);

                PhoneCardDto[] _phoneCards = mapToPhoneCards(pDb.PhoneCardCollection.GetByRetail_acct_id(_retailAccount.RetailAcctId));
                if (_phoneCards != null && _phoneCards.Length > 0)
                {
                    _retailAccount.PhoneCards = _phoneCards;
                    foreach (PhoneCardDto _phoneCard in _phoneCards)
                    {
                        if (_retailAccount.ServiceId != _phoneCard.ServiceId)
                        {
                            throw new Exception("Retail Account has a card from a different Service. [RetailAcctId=" + _retailAccount.RetailAcctId + "] [RetailAccount.ServiceId=" + _retailAccount.ServiceId + "] [PhoneCard.ServiceId=" + _phoneCard.ServiceId + "]");
                        }
                    }
                }

                ResidentialPSTNDto[] _residentialPSTNs = mapToResidentialPSTNs(pDb.ResidentialPSTNCollection.GetByRetail_acct_id(_retailAccount.RetailAcctId));
                if (_residentialPSTNs != null && _residentialPSTNs.Length > 0)
                {
                    _retailAccount.ResidentialPSTNs = _residentialPSTNs;
                    foreach (ResidentialPSTNDto _residentialPSTN in _residentialPSTNs)
                    {
                        if (_retailAccount.ServiceId != _residentialPSTN.ServiceId)
                        {
                            throw new Exception("Retail Account has a ResidentialPSTN from a different Service. [RetailAcctId=" + _retailAccount.RetailAcctId + "] [RetailAccount.ServiceId=" + _retailAccount.ServiceId + "] [ResidentialPSTN.ServiceId=" + _residentialPSTN.ServiceId + "]");
                        }
                    }
                }

                //ResidentialVoIP[] _residentialVoIPs = mapToResidentialVoIPs(pDb.ResidentialVoIPCollection.GetByRetail_acct_id(_retailAccount.RetailAcctId));
                //if (_residentialVoIPs != null && _residentialVoIPs.Length > 0) {
                //  _retailAccount.ResidentialVoIPs = _residentialVoIPs;
                //  foreach (ResidentialVoIP _residentialVoIP in _residentialVoIPs) {
                //    if (_retailAccount.ServiceId != _residentialVoIP.ServiceId) {
                //      throw new Exception("Retail Account has a ResidentialVoIP from a different Service. [RetailAcctId=" + _retailAccount.RetailAcctId + "] [RetailAccount.ServiceId=" + _retailAccount.ServiceId + "] [ResidentialVoIP.ServiceId=" + _residentialVoIP.ServiceId + "]");
                //    }
                //  }
                //}
                return(_retailAccount);
            }
            return(null);
        }
        public static void Credit(PersonDto pPerson, RetailAccountPaymentDto pRetailAccountPayment)
        {
            using (var _db = new Rbr_Db()) {
                using (var _tx = new Transaction(_db, pRetailAccountPayment)) {
                    //NOTE: make sure we got prev amnt
                    RetailAccountRow _retailAccountRow = _db.RetailAccountCollection.GetByPrimaryKey(pRetailAccountPayment.RetailAcctId);
                    pRetailAccountPayment.DateTime             = DateTime.Now;
                    pRetailAccountPayment.PreviousAmount       = _retailAccountRow.Current_balance;
                    pRetailAccountPayment.PreviousBonusMinutes = _retailAccountRow.Current_bonus_minutes;
                    pRetailAccountPayment.Person = pPerson;

                    RetailAccountManager.Instance.Credit(_db, pRetailAccountPayment);
                    RetailAccountManager.Add(_db, pRetailAccountPayment);
                    _tx.Commit();
                }
            }
        }
Ejemplo n.º 12
0
        RetailAccountDto mapToRetailAccount(RetailAccountRow pRetailAccountRow)
        {
            var _retailAccount = new RetailAccountDto();

            _retailAccount.CurrentBalance      = pRetailAccountRow.Current_balance;
            _retailAccount.CurrentBonusMinutes = pRetailAccountRow.Current_bonus_minutes;
            _retailAccount.CustomerAcctId      = pRetailAccountRow.Customer_acct_id;
            _retailAccount.DateActive          = pRetailAccountRow.Date_active;
            _retailAccount.DateCreated         = pRetailAccountRow.Date_created;
            _retailAccount.DateExpired         = pRetailAccountRow.Date_expired;
            _retailAccount.DateToExpire        = pRetailAccountRow.Date_to_expire;
            _retailAccount.RetailAcctId        = pRetailAccountRow.Retail_acct_id;
            _retailAccount.StartBalance        = pRetailAccountRow.Start_balance;
            _retailAccount.StartBonusMinutes   = pRetailAccountRow.Start_bonus_minutes;
            _retailAccount.Status = pRetailAccountRow.AccountStatus;

            return(_retailAccount);
        }
Ejemplo n.º 13
0
        private static RetailAccountRow createRetailAccount(Rbr_Db pDb, InventoryCommandRequest pInventoryCommandRequest)
        {
            var _retailAccountRow = new RetailAccountRow();

            _retailAccountRow.Customer_acct_id      = pInventoryCommandRequest.CustomerAcctId;
            _retailAccountRow.Start_balance         = pInventoryCommandRequest.Denomination;
            _retailAccountRow.Start_bonus_minutes   = 0;
            _retailAccountRow.Current_balance       = pInventoryCommandRequest.Denomination;
            _retailAccountRow.Current_bonus_minutes = 0;
            _retailAccountRow.AccountStatus         = Status.Active;
            _retailAccountRow.Date_active           = pInventoryCommandRequest.DateCreated;
            _retailAccountRow.Date_created          = pInventoryCommandRequest.DateCreated;
            _retailAccountRow.Date_to_expire        = pInventoryCommandRequest.DateToExpire;
            _retailAccountRow.Date_expired          = Configuration.Instance.Db.SqlSmallDateTimeMaxValue;

            pDb.RetailAccountCollection.Insert(_retailAccountRow);
            TimokLogger.Instance.LogRbr(LogSeverity.Debug, "InventoryController.loadPhoneCardAndRetailAccount", string.Format("RetailAccountRow inserted, Id={0}", _retailAccountRow.Retail_acct_id));
            return(_retailAccountRow);
        }
        static void importPhoneCardAndRetailAccount(Rbr_Db pDb, PhoneCardDto pPhoneCard, InventoryStatus pInitialInventoryStatus, PhoneCardBatch pPhoneCardBatch)
        {
            var _retailAccountRow = new RetailAccountRow();

            _retailAccountRow.AccountStatus         = Status.Active;     //NOTE
            _retailAccountRow.Start_balance         = pPhoneCardBatch.StartBalance;
            _retailAccountRow.Start_bonus_minutes   = pPhoneCardBatch.StartBonusMinutes;
            _retailAccountRow.Current_balance       = pPhoneCardBatch.StartBalance;
            _retailAccountRow.Current_bonus_minutes = pPhoneCardBatch.StartBonusMinutes;
            _retailAccountRow.Customer_acct_id      = pPhoneCardBatch.CustomerAcctId;
            _retailAccountRow.Date_created          = pPhoneCardBatch.DateCreated;   //NOTE
            _retailAccountRow.Date_active           = pPhoneCardBatch.DateCreated;   //NOTE
            _retailAccountRow.Date_to_expire        = pPhoneCardBatch.DateToExpire;
            _retailAccountRow.Date_expired          = Configuration.Instance.Db.SqlSmallDateTimeMaxValue;

            RetailAccountManager.Instance.Add(pDb, _retailAccountRow);
            pPhoneCard.RetailAcctId = _retailAccountRow.Retail_acct_id;

            var _phoneCardRow = new PhoneCardRow();

            _phoneCardRow.InventoryStatus = pInitialInventoryStatus;
            if (pInitialInventoryStatus == InventoryStatus.Activated)
            {
                _phoneCardRow.CardStatus = Status.Active;
            }
            else
            {
                _phoneCardRow.CardStatus = Status.Pending;
            }
            _phoneCardRow.Pin            = pPhoneCard.Pin;
            _phoneCardRow.Serial_number  = pPhoneCard.SerialNumber;
            _phoneCardRow.Service_id     = pPhoneCard.ServiceId;
            _phoneCardRow.Retail_acct_id = pPhoneCard.RetailAcctId;

            _phoneCardRow.Date_loaded            = pPhoneCardBatch.DateCreated;
            _phoneCardRow.Date_active            = pPhoneCardBatch.DateCreated;
            _phoneCardRow.Date_to_expire         = pPhoneCardBatch.DateToExpire;
            _phoneCardRow.IsDate_deactivatedNull = true;
            _phoneCardRow.IsDate_archivedNull    = true;

            RetailAccountManager.AddPhoneCard(pDb, _phoneCardRow);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Updates a record in the <c>RetailAccount</c> table.
        /// </summary>
        /// <param name="value">The <see cref="RetailAccountRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(RetailAccountRow value)
        {
            string sqlStr = "UPDATE [dbo].[RetailAccount] SET " +
                            "[customer_acct_id]=" + _db.CreateSqlParameterName("Customer_acct_id") + ", " +
                            "[date_to_expire]=" + _db.CreateSqlParameterName("Date_to_expire") + ", " +
                            "[status]=" + _db.CreateSqlParameterName("Status") + ", " +
                            "[start_balance]=" + _db.CreateSqlParameterName("Start_balance") + ", " +
                            "[start_bonus_minutes]=" + _db.CreateSqlParameterName("Start_bonus_minutes") +
                            " WHERE " +
                            "[retail_acct_id]=" + _db.CreateSqlParameterName("Retail_acct_id");
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Customer_acct_id", value.Customer_acct_id);
            AddParameter(cmd, "Date_to_expire", value.Date_to_expire);
            AddParameter(cmd, "Status", value.Status);
            AddParameter(cmd, "Start_balance", value.Start_balance);
            AddParameter(cmd, "Start_bonus_minutes", value.Start_bonus_minutes);
            AddParameter(cmd, "Retail_acct_id", value.Retail_acct_id);
            return(0 != cmd.ExecuteNonQuery());
        }
Ejemplo n.º 16
0
        internal static RetailAccountRow MapToRetailAccountRow(RetailAccountDto pRetailAccount)
        {
            var _retailAccountRow = new RetailAccountRow
            {
                AccountStatus         = pRetailAccount.Status,
                Current_balance       = pRetailAccount.CurrentBalance,
                Current_bonus_minutes = pRetailAccount.CurrentBonusMinutes,
                Date_active           = pRetailAccount.DateActive,
                Date_created          = pRetailAccount.DateCreated,
                Date_expired          = pRetailAccount.DateExpired,
                Date_to_expire        = pRetailAccount.DateToExpire,
                Retail_acct_id        = pRetailAccount.RetailAcctId,
                Start_balance         = pRetailAccount.StartBalance,
                Start_bonus_minutes   = pRetailAccount.StartBonusMinutes
            };

            if (pRetailAccount.CustomerAcctId > 0)
            {
                _retailAccountRow.Customer_acct_id = pRetailAccount.CustomerAcctId;
            }

            return(_retailAccountRow);
        }
        public static void Add(string pSalt, RetailAccountDto pRetailAccount)
        {
            using (var _db = new Rbr_Db()) {
                using (var _tx = new Transaction(_db, pSalt, pRetailAccount)) {
                    RetailAccountRow _retailAccountRow = RetailAccountManager.MapToRetailAccountRow(pRetailAccount);

                    //TODO: ! CONFIRM IT before implementing
                    //					CustomerAcctRow _customerAcctRow = _db.CustomerAcctCollection.GetByPrimaryKey(pRetailAccount.CustomerAcctId);
                    //					if (_customerAcctRow.BonusMinutesType == BonusMinutesType.None) {
                    //						_retailAccountRow.Current_bonus_minutes = -1;
                    //					}

                    _retailAccountRow.Date_created          = DateTime.Now;
                    _retailAccountRow.Date_expired          = Configuration.Instance.Db.SqlSmallDateTimeMaxValue;
                    _retailAccountRow.Current_balance       = _retailAccountRow.Start_balance;
                    _retailAccountRow.Current_bonus_minutes = _retailAccountRow.Start_bonus_minutes;

                    if (_retailAccountRow.AccountStatus == Status.Active)
                    {
                        _retailAccountRow.Date_active = _retailAccountRow.Date_created;
                    }
                    else
                    {
                        _retailAccountRow.Date_active = Configuration.Instance.Db.SqlSmallDateTimeMaxValue;
                    }

                    RetailAccountManager.Instance.Add(_db, _retailAccountRow);
                    pRetailAccount.RetailAcctId = _retailAccountRow.Retail_acct_id;

                    //prepare PhoneCard (s)
                    if (pRetailAccount.PhoneCards != null && pRetailAccount.PhoneCards.Length > 0)
                    {
                        //NOTE: !!! in this virsion only ONE PhoneCard p/RetailAccount allowed!!!
                        if (pRetailAccount.PhoneCards.Length > 1)
                        {
                            throw new Exception("In this virsion only ONE PhoneCard p/RetailAccount allowed!!!");
                        }
                        foreach (PhoneCardDto _phoneCard in pRetailAccount.PhoneCards)
                        {
                            long _pin = 0;
                            if (_phoneCard.SerialNumber == 0)
                            {
                                ServiceRow _serviceRow = ServiceManager.Get(_db, pRetailAccount.ServiceId);
                                long       _serialNumber;
                                generateTestSerialNumberPIN(_db, _serviceRow, out _serialNumber, out _pin);
                                _phoneCard.SerialNumber = _serialNumber;
                            }
                            if (_phoneCard.Pin == 0)
                            {
                                _phoneCard.Pin = _pin;
                            }
                            switch (pRetailAccount.Status)
                            {
                            case Status.Active:
                                _phoneCard.InventoryStatus = InventoryStatus.Activated;
                                break;

                            case Status.Pending:
                            case Status.Blocked:
                            case Status.Archived:
                            case Status.InUse:
                            default:
                                throw new ArgumentException(string.Format("Unexpected Status [{0}]", pRetailAccount.Status));
                            }
                            _phoneCard.ServiceId    = pRetailAccount.ServiceId;
                            _phoneCard.RetailAcctId = pRetailAccount.RetailAcctId;

                            _phoneCard.Status = pRetailAccount.Status;
                            //TODO: ??? set it based on RetAcct status ???
                            _phoneCard.InventoryStatus = InventoryStatus.Activated;

                            _phoneCard.DateLoaded      = _retailAccountRow.Date_created;
                            _phoneCard.DateActive      = _retailAccountRow.Date_created;
                            _phoneCard.DateToExpire    = _retailAccountRow.Date_to_expire;
                            _phoneCard.DateDeactivated = Configuration.Instance.Db.SqlSmallDateTimeMaxValue;
                            _phoneCard.DateArchived    = Configuration.Instance.Db.SqlSmallDateTimeMaxValue;
                        }
                    }

                    //prepare ResidentialPSTN (s)
                    if (pRetailAccount.ResidentialPSTNs != null && pRetailAccount.ResidentialPSTNs.Length > 0)
                    {
                        //NOTE: !!! in this virsion only ONE ResidentialPSTN p/RetailAccount allowed!!!
                        if (pRetailAccount.ResidentialPSTNs.Length > 1)
                        {
                            throw new Exception("In this virsion only ONE ResidentialPSTN p/RetailAccount allowed!!!");
                        }
                        foreach (var _residentialPSTN in pRetailAccount.ResidentialPSTNs)
                        {
                            _residentialPSTN.Status       = pRetailAccount.Status;
                            _residentialPSTN.ServiceId    = pRetailAccount.ServiceId;
                            _residentialPSTN.RetailAcctId = pRetailAccount.RetailAcctId;
                        }
                    }

                    ////prepare ResidentialVoIP (s)
                    //if (pRetailAccount.ResidentialVoIPs != null && pRetailAccount.ResidentialVoIPs.Length > 0) {
                    //  //NOTE: !!! in this virsion only ONE ResidentialVoIP p/RetailAccount allowed!!!
                    //  if (pRetailAccount.ResidentialVoIPs.Length > 1) {
                    //    throw new Exception("In this virsion only ONE ResidentialVoIP p/RetailAccount allowed!!!");
                    //  }
                    //  foreach (ResidentialVoIP _residentialVoIP in pRetailAccount.ResidentialVoIPs) {
                    //    _residentialVoIP.Status = pRetailAccount.Status;
                    //    _residentialVoIP.ServiceId = pRetailAccount.ServiceId;
                    //    _residentialVoIP.RetailAcctId = pRetailAccount.RetailAcctId;
                    //  }
                    //}

                    if (pRetailAccount.AccessEnabled)
                    {
                        pRetailAccount.Person.RetailAcctId = pRetailAccount.RetailAcctId;
                        PersonManager.Save(_db, pSalt, pRetailAccount.Person);
                    }

                    if (pRetailAccount.PhoneCards != null && pRetailAccount.PhoneCards.Length > 0)
                    {
                        //Insert PhoneCard
                        //TODO: now works only with 1 (one) card per RetailAcct
                        PhoneCardRow _phoneCardRow = RetailAccountManager.MapToPhoneCardRow(pRetailAccount.PhoneCards[0]);
                        RetailAccountManager.AddPhoneCard(_db, _phoneCardRow);
                    }

                    if (pRetailAccount.ResidentialPSTNs != null && pRetailAccount.ResidentialPSTNs.Length > 0)
                    {
                        //Insert ResidentialPSTN
                        //TODO: now works only with 1 (one) PSTN # per RetailAcct
                        ResidentialPSTNRow _residentialPSTNRow = RetailAccountManager.MapToResidentialPSTNRow(pRetailAccount.ResidentialPSTNs[0]);
                        RetailAccountManager.AddResidentialPSTNSubAcct(_db, _residentialPSTNRow);
                    }

                    _tx.Commit();
                }
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="RetailAccountRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="RetailAccountRow"/> object.</returns>
        protected virtual RetailAccountRow MapRow(DataRow row)
        {
            RetailAccountRow mappedObject = new RetailAccountRow();
            DataTable        dataTable    = row.Table;
            DataColumn       dataColumn;

            // Column "Retail_acct_id"
            dataColumn = dataTable.Columns["Retail_acct_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Retail_acct_id = (int)row[dataColumn];
            }
            // Column "Customer_acct_id"
            dataColumn = dataTable.Columns["Customer_acct_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Customer_acct_id = (short)row[dataColumn];
            }
            // Column "Date_created"
            dataColumn = dataTable.Columns["Date_created"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Date_created = (System.DateTime)row[dataColumn];
            }
            // Column "Date_active"
            dataColumn = dataTable.Columns["Date_active"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Date_active = (System.DateTime)row[dataColumn];
            }
            // Column "Date_to_expire"
            dataColumn = dataTable.Columns["Date_to_expire"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Date_to_expire = (System.DateTime)row[dataColumn];
            }
            // Column "Date_expired"
            dataColumn = dataTable.Columns["Date_expired"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Date_expired = (System.DateTime)row[dataColumn];
            }
            // Column "Status"
            dataColumn = dataTable.Columns["Status"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Status = (byte)row[dataColumn];
            }
            // Column "Start_balance"
            dataColumn = dataTable.Columns["Start_balance"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Start_balance = (decimal)row[dataColumn];
            }
            // Column "Current_balance"
            dataColumn = dataTable.Columns["Current_balance"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Current_balance = (decimal)row[dataColumn];
            }
            // Column "Start_bonus_minutes"
            dataColumn = dataTable.Columns["Start_bonus_minutes"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Start_bonus_minutes = (short)row[dataColumn];
            }
            // Column "Current_bonus_minutes"
            dataColumn = dataTable.Columns["Current_bonus_minutes"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Current_bonus_minutes = (short)row[dataColumn];
            }
            return(mappedObject);
        }
Ejemplo n.º 19
0
 internal void Update(Rbr_Db pDb, RetailAccountRow pRetailAccountRow)
 {
     pDb.RetailAccountCollection.Update(pRetailAccountRow);
 }
Ejemplo n.º 20
0
 internal void Add(Rbr_Db pDb, RetailAccountRow pRetailAccountRow)
 {
     pDb.RetailAccountCollection.Insert(pRetailAccountRow);
 }
Ejemplo n.º 21
0
        }                                                                                    //TODO: add Serail to all Retail SubAccts?

        public Residential(RetailAccountRow pRetailAcctRow, ResidentialPSTNRow pResidentialRow) : base(pRetailAcctRow)
        {
            residentialPSTNRow = pResidentialRow;
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Deletes the specified object from the <c>RetailAccount</c> table.
 /// </summary>
 /// <param name="value">The <see cref="RetailAccountRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(RetailAccountRow value)
 {
     return(DeleteByPrimaryKey(value.Retail_acct_id));
 }
Ejemplo n.º 23
0
        internal RetailAccountDto GetAcct(Rbr_Db pDb, int pRetailAcctId)
        {
            RetailAccountRow _retailAccountRow = pDb.RetailAccountCollection.GetByPrimaryKey(pRetailAcctId);

            return(get(pDb, _retailAccountRow));
        }
Ejemplo n.º 24
0
 protected RetailAccount(RetailAccountRow pRetailAcctRow)
 {
     retailAcctRow = pRetailAcctRow;
 }
Ejemplo n.º 25
0
 public PhoneCard(RetailAccountRow pRetailAcctRow, PhoneCardRow pPhoneCardRow) : base(pRetailAcctRow)
 {
     phoneCardRow = pPhoneCardRow;
 }