Ejemplo n.º 1
0
        static CustomerAcctDto mapToCustomerAcct(CustomerAcctRow pCustomerAcctRow, PartnerDto pPartner)
        {
            if (pCustomerAcctRow == null)
            {
                return(null);
            }

            var _customerAcct = new CustomerAcctDto
            {
                CustomerAcctId           = pCustomerAcctRow.Customer_acct_id,
                ServiceId                = pCustomerAcctRow.Service_id,
                RoutingPlanId            = pCustomerAcctRow.Routing_plan_id,
                AllowRerouting           = pCustomerAcctRow.AllowRerouting,
                DefaultBonusMinutesType  = pCustomerAcctRow.DefaultBonusMinutesType,
                DefaultStartBonusMinutes = pCustomerAcctRow.Default_start_bonus_minutes,
                IsPrepaid                = pCustomerAcctRow.IsPrepaid,
                ConcurrentUse            = pCustomerAcctRow.ConcurrentUse,
                CurrentAmount            = pCustomerAcctRow.Current_amount,
                LimitAmount              = pCustomerAcctRow.Limit_amount,
                Name           = pCustomerAcctRow.Name,
                PrefixIn       = pCustomerAcctRow.Prefix_in,
                PrefixInTypeId = pCustomerAcctRow.Prefix_in_type_id,
                PrefixOut      = pCustomerAcctRow.Prefix_out,
                Status         = pCustomerAcctRow.AccountStatus,
                WarningAmount  = pCustomerAcctRow.Warning_amount,
                MaxCallLength  = pCustomerAcctRow.Max_call_length,
                Partner        = pPartner,
                ServiceDto     = null,
                RoutingPlan    = null
            };

            return(_customerAcct);
        }
Ejemplo n.º 2
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.º 3
0
        public static void UpdateAcct(CustomerAcctDto pCustomerAcct)
        {
            using (var _db = new Rbr_Db()) {
                using (var _tx = new Transaction(_db, pCustomerAcct)) {
                    CustomerAcctRow _original = CustomerAcctManager.Get(_db, pCustomerAcct.CustomerAcctId);

                    if (pCustomerAcct.ServiceDto.IsDedicated)
                    {
                        //-- Dedicated, make sure dp's name is created by cust's name
                        pCustomerAcct.ServiceDto.Name = AppConstants.CustomerServiceNamePrefix + pCustomerAcct.Name;

                        //-- Make sure RoutingPlan is the same for Dedicated Service
                        pCustomerAcct.ServiceDto.DefaultRoutingPlan = pCustomerAcct.RoutingPlan;
                        ServiceManager.UpdateService(_db, pCustomerAcct.ServiceDto);
                    }

                    ServiceManager.SaveAccessNumbers(_db, pCustomerAcct);
                    CustomerAcctManager.UpdateAcct(_db, pCustomerAcct);

                    if (pCustomerAcct.PrefixIn != _original.Prefix_in)
                    {
                        CustomerAcctManager.UpdateCustomerDialPeers(_db, pCustomerAcct.CustomerAcctId, pCustomerAcct.PrefixIn, _original.Prefix_in);
                    }

                    if (pCustomerAcct.ResellAccount != null)
                    {
                        CustomerAcctManager.UpdateResellAccount(_db, pCustomerAcct.ResellAccount);
                    }

                    #region TODO: for the next rev

                    //if (CurrentNode.Instance.BelongsToStandalonePlatform) {
                    //  //add LB Map for the actual acct only, not the resell one
                    //  LoadBalancingMapManager.Add(_db, CurrentNode.Instance.Id, pCustomerAcct.CustomerAcctId);
                    //}
                    //else {
                    //  //TODO: !!!!! review it
                    //  //							if ( ! _original.IsPrepaid && pCustomerAcct.CustomerAcctRow.IsPrepaid) {
                    //  //								//TODO: check the logic
                    //  //								//if changed to Prepaid - delete all LB Maps
                    //  //								//user will need to pick Node manually
                    //  //								_db.LoadBalancingMapCollection.DeleteByCustomer_acct_id(pCustomerAcct.CustomerAcctRow.Customer_acct_id);
                    //  //							}
                    //}

                    #endregion for the next rev

                    _tx.Commit();
                }
            }
        }
Ejemplo n.º 4
0
        public CustomerAcct(CustomerAcctRow pCustomerAcctRow)
        {
            customerAcctRow = pCustomerAcctRow;
            status          = (Status)customerAcctRow.Status;
            email           = string.Empty;

            //--
            using (var _db = new Rbr_Db()) {
                partnerRow = _db.PartnerCollection.GetByPrimaryKey(customerAcctRow.Partner_id);
            }
            if (partnerRow == null)
            {
                throw new Exception("Couldn't FIND PartnerRow for Customer: " + customerAcctRow.Customer_acct_id);
            }

            //--
            ServiceRow _serviceRow;

            using (var _db = new Rbr_Db()) {
                _serviceRow = _db.ServiceCollection.GetByPrimaryKey(customerAcctRow.Service_id);
            }
            if (_serviceRow == null)
            {
                throw new Exception("Couldn't FIND ServiceRow for Customer: " + customerAcctRow.Customer_acct_id);
            }
            serviceType     = _serviceRow.ServiceType;
            retailType      = _serviceRow.RetailType;
            isPrepaid       = customerAcctRow.IsPrepaid;
            isRatingEnabled = _serviceRow.IsRatingEnabled;
            callingPlanId   = _serviceRow.Calling_plan_id;

            //TODO: set max number of calls from db
            MaxNumberOfCalls = 1000;

            if (isPrepaid)                      //get email, so we can send balance warnings to Partners as well
            {
                using (var _db = new Rbr_Db()) {
                    var _partnerRow = _db.PartnerCollection.GetByPrimaryKey(customerAcctRow.Partner_id);
                    if (_partnerRow == null)
                    {
                        throw new Exception("Couldn't FIND PartnerRow for Customer: " + customerAcctRow.Customer_acct_id);
                    }
                    var _contactInfoRow = _db.ContactInfoCollection.GetByPrimaryKey(_partnerRow.Contact_info_id);
                    if (_contactInfoRow != null)
                    {
                        email = _contactInfoRow.Email;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        static CustomerAcctDto getAcct(Rbr_Db pDb, CustomerAcctRow pCustomerAcctRow)
        {
            if (pCustomerAcctRow == null)
            {
                return(null);
            }
            var _partner = PartnerManager.Get(pDb, pCustomerAcctRow.Partner_id);

            if (_partner == null)
            {
                return(null);
            }

            return(mapToCustomerAcct(pCustomerAcctRow, _partner));
        }
Ejemplo n.º 6
0
        public static void Credit(PersonDto pPerson, CustomerAcctPaymentDto pCustomerAcctPayment)
        {
            using (var _db = new Rbr_Db()) {
                using (var _tx = new Transaction(_db, pPerson, pCustomerAcctPayment)) {
                    pCustomerAcctPayment.DateTime = DateTime.Now;
                    //NOTE: make sure we got prev amnt
                    CustomerAcctRow _customerAcctRow = CustomerAcctManager.Get(_db, pCustomerAcctPayment.CustomerAcctId);
                    pCustomerAcctPayment.PreviousAmount = _customerAcctRow.Current_amount;
                    pCustomerAcctPayment.Person         = pPerson;
                    CustomerAcctManager.Credit(_db, pCustomerAcctPayment);
                    _tx.Commit();

                    PartnerDto     _partner     = PartnerManager.Get(_db, _customerAcctRow.Partner_id);
                    ContactInfoDto _contactInfo = ContactInfoManager.Get(_db, _partner.ContactInfo.ContactInfoId);
                    sendNotification(pPerson, pCustomerAcctPayment, _customerAcctRow, _partner, _contactInfo);
                }
            }
        }
Ejemplo n.º 7
0
        internal static CustomerAcctRow MapToCustomerAcctRow(CustomerAcctDto pCustomerAcct)
        {
            if (pCustomerAcct == null)
            {
                return(null);
            }

            var _customerAcctRow = new CustomerAcctRow
            {
                Customer_acct_id            = pCustomerAcct.CustomerAcctId,
                AllowRerouting              = pCustomerAcct.AllowRerouting,
                DefaultBonusMinutesType     = pCustomerAcct.DefaultBonusMinutesType,
                Default_start_bonus_minutes = pCustomerAcct.DefaultStartBonusMinutes,
                IsPrepaid         = pCustomerAcct.IsPrepaid,
                ConcurrentUse     = pCustomerAcct.ConcurrentUse,
                Current_amount    = pCustomerAcct.CurrentAmount,
                Limit_amount      = pCustomerAcct.LimitAmount,
                Name              = pCustomerAcct.Name,
                Prefix_in         = pCustomerAcct.PrefixIn,
                Prefix_in_type_id = pCustomerAcct.PrefixInTypeId,
                Prefix_out        = pCustomerAcct.PrefixOut,
                AccountStatus     = pCustomerAcct.Status,
                Warning_amount    = pCustomerAcct.WarningAmount,
                Max_call_length   = pCustomerAcct.MaxCallLength,
                Partner_id        = pCustomerAcct.PartnerId,
                Service_id        = pCustomerAcct.ServiceDto.ServiceId,
                Routing_plan_id   = pCustomerAcct.RoutingPlanId
            };

            //TODO: NEW DAL
            //if (pCustomerAcct.RetailCallingPlan != null) {
            //  _customerAcctRow.Retail_calling_plan_id = pCustomerAcct.RetailCallingPlanId;
            //}

            return(_customerAcctRow);
        }
Ejemplo n.º 8
0
 internal static void UpdateAcct(Rbr_Db pDb, CustomerAcctRow pCustomerAcctRow)
 {
     pDb.CustomerAcctCollection.Update(pCustomerAcctRow);
     //pDb.AddChangedObject(new CustomerAcctKey(TxType.Delete, pCustomerAcctRow.Customer_acct_id));
 }
Ejemplo n.º 9
0
 internal static void Add(Rbr_Db pDb, CustomerAcctRow pCustomerAcctRow)
 {
     pDb.CustomerAcctCollection.Insert(pCustomerAcctRow);
 }