Ejemplo n.º 1
0
        public Type814ServiceAccountChange[] ListServiceAccountChanges(int serviceKey)
        {
            using (var connection = new SqlConnection(connectionString))
                using (var command = connection.CreateCommand("esp_814ServiceAccountChangeList"))
                {
                    command.AddWithValue("@Service_Key", serviceKey);

                    if (connection.State != ConnectionState.Open)
                    {
                        connection.Open();
                    }

                    var collection = new List <Type814ServiceAccountChange>();
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var item = new Type814ServiceAccountChange
                            {
                                ChangeKey  = reader.GetInt32("Change_Key"),
                                ServiceKey = serviceKey,
                            };

                            reader.TryGetString("ChangeReason", x => item.ChangeReason           = x);
                            reader.TryGetString("ChangeDescription", x => item.ChangeDescription = x);

                            collection.Add(item);
                        }

                        return(collection.ToArray());
                    }
                }
        }
Ejemplo n.º 2
0
        public int InsertServiceAccountChange(Type814ServiceAccountChange model)
        {
            using (var connection = new SqlConnection(connectionString))
                using (var command = connection.CreateCommand("csp814ServiceAccountChangeInsert"))
                {
                    SqlParameter keyParameter;

                    command.AddWithValue("@Service_Key", model.ServiceKey)
                    .AddWithValue("@ChangeReason", model.ChangeReason)
                    .AddWithValue("@ChangeDescription", model.ChangeDescription)
                    .AddOutParameter("@Change_Key", SqlDbType.Int, out keyParameter);

                    if (connection.State != ConnectionState.Open)
                    {
                        connection.Open();
                    }

                    command.ExecuteNonQuery();

                    if (keyParameter.Value == null)
                    {
                        throw new Exception();
                    }

                    var changeKey = (int)keyParameter.Value;
                    model.ChangeKey = changeKey;

                    return(changeKey);
                }
        }
Ejemplo n.º 3
0
        public void When_Saving_Header_With_Any_Service_Account_Changes_Then_Insert_Service_Account_Change_Is_Called()
        {
            // arrange
            const int serviceKey = 2;

            var change = new Type814ServiceAccountChange {
                ChangeReason = "mock"
            };

            var service = new Type814Service();

            service.AddChange(change);

            var header = new Type814Header();

            header.AddService(service);

            dataAccess.Stub(x => x.InsertHeader(Arg.Is(header)))
            .Return(1);

            dataAccess.Stub(x => x.InsertService(Arg.Is(service)))
            .Return(serviceKey);

            dataAccess.Expect(x => x.InsertServiceAccountChange(Arg.Is(change)))
            .Return(1);

            // act
            concern.SaveHeader(header);

            // assert
            Assert.AreEqual(serviceKey, change.ServiceKey);

            dataAccess.VerifyAllExpectations();
        }
Ejemplo n.º 4
0
        public Type814ServiceAccountChange ParseServiceAccountChange(XElement element, IDictionary <string, XNamespace> namespaces)
        {
            XNamespace empty;

            if (!namespaces.TryGetValue(string.Empty, out empty))
            {
                empty = XNamespace.None;
            }

            var model = new Type814ServiceAccountChange
            {
                ChangeReason      = element.GetChildText(empty + "ChangeReason"),
                ChangeDescription = element.GetChildText(empty + "ChangeDescription"),
            };

            return(model);
        }
Ejemplo n.º 5
0
        public void ParseServiceStatus(Prism814Context context, string[] marketFields)
        {
            var current = context.Current;

            if (current == null || current.ModelType != Type814Types.Service)
            {
                throw new InvalidOperationException();
            }

            var service = current as Type814Service;

            if (service == null)
            {
                throw new InvalidOperationException();
            }

            if (context.Market == MarketOptions.Texas)
            {
                var statusModel = new Type814ServiceStatus
                {
                    StatusCode   = marketFields.AtIndex(2),
                    StatusReason = marketFields.AtIndex(3),
                };

                service.AddStatus(statusModel);
                return;
            }

            var changeModel = new Type814ServiceAccountChange
            {
                ChangeReason      = marketFields.AtIndex(2),
                ChangeDescription = marketFields.AtIndex(3),
            };

            service.AddChange(changeModel);
        }