Пример #1
0
        public Type814ServiceReject[] ListServiceRejects(int serviceKey)
        {
            using (var connection = new SqlConnection(connectionString))
                using (var command = connection.CreateCommand("esp_814ServiceRejectList"))
                {
                    command.AddWithValue("@Service_Key", serviceKey);

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

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

                            reader.TryGetString("RejectCode", x => item.RejectCode     = x);
                            reader.TryGetString("RejectReason", x => item.RejectReason = x);

                            collection.Add(item);
                        }

                        return(collection.ToArray());
                    }
                }
        }
Пример #2
0
        public int InsertServiceReject(Type814ServiceReject model)
        {
            using (var connection = new SqlConnection(connectionString))
                using (var command = connection.CreateCommand("csp814ServiceRejectInsert"))
                {
                    SqlParameter keyParameter;

                    command.AddWithValue("@Service_Key", model.ServiceKey)
                    .AddIfNotEmptyOrDbNull("@RejectCode", model.RejectCode)
                    .AddIfNotEmptyOrDbNull("@RejectReason", model.RejectReason)
                    .AddOutParameter("@Reject_Key", SqlDbType.Int, out keyParameter);

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

                    command.ExecuteNonQuery();

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

                    var rejectKey = (int)keyParameter.Value;
                    model.RejectKey = rejectKey;

                    return(rejectKey);
                }
        }
Пример #3
0
        public void When_Saving_Header_With_Any_Service_Rejects_Then_Insert_Service_Reject_Is_Called()
        {
            // arrange
            const int serviceKey = 2;

            var reject = new Type814ServiceReject {
                RejectCode = "mock"
            };

            var service = new Type814Service();

            service.AddReject(reject);

            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.InsertServiceReject(Arg.Is(reject)))
            .Return(1);

            // act
            concern.SaveHeader(header);

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

            dataAccess.VerifyAllExpectations();
        }
Пример #4
0
        public Type814ServiceReject ParseServiceReject(XElement element, IDictionary <string, XNamespace> namespaces)
        {
            XNamespace empty;

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

            var model = new Type814ServiceReject
            {
                RejectCode   = element.GetChildText(empty + "RejectCode"),
                RejectReason = element.GetChildText(empty + "RejectReason"),
            };

            return(model);
        }
Пример #5
0
        public void ParseServiceReject(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();
            }

            var model = new Type814ServiceReject
            {
                RejectCode   = marketFields.AtIndex(2),
                RejectReason = marketFields.AtIndex(3),
            };

            service.AddReject(model);
        }