Ejemplo n.º 1
0
        // TO DO:  The number of parameters here is obviously ridiculous... but is consistent with DDD
        //   principles
        public static Customer Create(int customerId, DateTime startDate, DateTime endDate, int statusCodeId, int nominationLevelId,
                                      AccountNumber accountNumber, int customerTypeId, int deliveryTypeId, DUNSNumber dunsNumber, LongName longName,
                                      ShortName shortName, DatabaseId ldcId, int lossTierId, DatabaseId deliveryLocation, int shipperId,
                                      DeliveryPressure deliveryPressure, MDQ mdq, MaxHourlyInterruptible maxHourlyInterruptible,
                                      MaxDailyInterruptible maxDailyInterruptible, HourlyInterruptible hourlyInterruptible,
                                      DailyInterruptible dailyInterruptible, TotalHourlySpecifiedFirm totalHourlySpecifiedFirm,
                                      TotalDailySpecifiedFirm totalDailySpecifiedFirm, InterstateSpecifiedFirm interstateSpecifiedFirm,
                                      IntrastateSpecifiedFirm intrastateSpecifiedFirm, CurrentDemand currentDemand, PreviousDemand previousDemand,
                                      int groupTypeId, int balancingLevelId, NAICSCode naicsCode, SICCode sicCode,
                                      SICCodePercentage sicCodePercentage, DateTime shippersLetterFromDate, DateTime shippersLetterToDate,
                                      bool ss1, bool isFederal, DateTime turnOffDate, DateTime turnOnDate)
        {
            DebugLog.Log("Entering Customer::Create");

            return(new Customer
            {
                Id = customerId,
                AccountNumber = accountNumber,
                AlternateCustomerId = null,
                BalancingLevelId = balancingLevelId,
                BasicPoolId = null,
                ContractTypeId = null,
                CurrentDemand = null,
                CustomerTypeId = customerTypeId,
                DailyInterruptible = dailyInterruptible,
                DeliveryLocation = deliveryLocation,
                DeliveryPressure = deliveryPressure,
                DeliveryTypeId = deliveryTypeId,
                DUNSNumber = dunsNumber,
                EndDate = endDate,
                GroupTypeId = groupTypeId,
                HourlyInterruptible = hourlyInterruptible,
                InterstateSpecifiedFirm = interstateSpecifiedFirm,
                IntrastateSpecifiedFirm = intrastateSpecifiedFirm,
                IsFederal = isFederal,
                LDCId = ldcId,
                LongName = longName,
                LossTierId = lossTierId,
                MaxDailyInterruptible = maxDailyInterruptible,
                MaxHourlyInterruptible = maxHourlyInterruptible,
                MDQ = mdq,
                NAICSCode = naicsCode,
                NominationLevelId = nominationLevelId,
                PreviousDemand = previousDemand,
                StartDate = startDate,
                StatusCodeId = statusCodeId,
                ShortName = shortName,
                ShipperId = shipperId,
                ShippersLetterFromDate = shippersLetterFromDate,
                ShippersLetterToDate = shippersLetterToDate,
                SICCode = sicCode,
                SICCodePercentage = sicCodePercentage,
                SS1 = ss1,
                TotalDailySpecifiedFirm = totalDailySpecifiedFirm,
                TotalHourlySpecifiedFirm = totalHourlySpecifiedFirm,
                TurnOffDate = turnOffDate,
                TurnOnDate = turnOnDate
            });
        }
        private CustomerRM CreateCustomerForAssociate(Commands.V1.Customer.CreateForAssociate cmd)
        {
            Customer customer = Customer.Create(_customers++, cmd.StartDate, cmd.EndDate, cmd.StatusCodeId,
                                                cmd.NominationLevelId, AccountNumber.Create(cmd.AccountNumber), cmd.CustomerTypeId, cmd.DeliveryTypeId,
                                                DUNSNumber.Create(cmd.DUNSNumber), LongName.Create(cmd.LongName), ShortName.Create(cmd.ShortName),
                                                cmd.LDCId, cmd.LossTierTypeId, cmd.DeliveryLocationId, cmd.ShipperId, cmd.DeliveryPressure,
                                                cmd.MDQ, cmd.MaxHourlyInterruptible, cmd.MaxDailyInterruptible, cmd.HourlyInterruptible,
                                                cmd.DailyInterruptible, cmd.TotalHourlySpecifiedFirm, cmd.TotalDailySpecifiedFirm,
                                                cmd.InterstateSpecifiedFirm, cmd.IntrastateSpecifiedFirm, cmd.CurrentDemand, cmd.PreviousDemand,
                                                cmd.GroupTypeId, cmd.BalancingLevelId, new NAICSCode(cmd.NAICSCode), SICCode.Create(cmd.SICCode), cmd.SICCodePercentage,
                                                cmd.ShippersLetterFromDate, cmd.ShippersLetterToDate, cmd.SS1, cmd.IsFederal, cmd.TurnOffDate,
                                                cmd.TurnOnDate);

            if (_repository.CustomerExistsForAssociate(customer, cmd.AssociateId))
            {
                throw new InvalidOperationException($"Customer already exists for Associate {cmd.AssociateId}");
            }

            _repository.AddCustomerForAssociate(customer, cmd.AssociateId);

            return(Conversions.GetCustomerRM(customer));
        }