public Type814ServiceStatus[] ListServiceStatuses(int serviceKey) { using (var connection = new SqlConnection(connectionString)) using (var command = connection.CreateCommand("esp_814ServiceStatusList")) { command.AddWithValue("@Service_Key", serviceKey); if (connection.State != ConnectionState.Open) { connection.Open(); } var collection = new List <Type814ServiceStatus>(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { var item = new Type814ServiceStatus { StatusKey = reader.GetInt32("Status_Key"), ServiceKey = serviceKey, }; reader.TryGetString("StatusCode", x => item.StatusCode = x); reader.TryGetString("StatusReason", x => item.StatusReason = x); reader.TryGetString("StatusType", x => item.StatusType = x); collection.Add(item); } return(collection.ToArray()); } } }
public int InsertServiceStatus(Type814ServiceStatus model) { using (var connection = new SqlConnection(connectionString)) using (var command = connection.CreateCommand("csp814ServiceStatusInsert")) { SqlParameter keyParameter; command.AddWithValue("@Service_Key", model.ServiceKey) .AddIfNotEmptyOrDbNull("@StatusCode", model.StatusCode) .AddIfNotEmptyOrDbNull("@StatusReason", model.StatusReason) .AddWithValue("@StatusType", model.StatusType) .AddOutParameter("@Status_Key", SqlDbType.Int, out keyParameter); if (connection.State != ConnectionState.Open) { connection.Open(); } command.ExecuteNonQuery(); if (keyParameter.Value == null) { throw new Exception(); } var statusKey = (int)keyParameter.Value; model.StatusKey = statusKey; return(statusKey); } }
public void When_Saving_Header_With_Any_Service_Statuses_Then_Insert_Service_Status_Is_Called() { // arrange const int serviceKey = 2; var status = new Type814ServiceStatus { StatusCode = "mock" }; var service = new Type814Service(); service.AddStatus(status); 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.InsertServiceStatus(Arg.Is(status))) .Return(1); // act concern.SaveHeader(header); // assert Assert.AreEqual(serviceKey, status.ServiceKey); dataAccess.VerifyAllExpectations(); }
public Type814ServiceStatus ParseServiceStatus(XElement element, IDictionary <string, XNamespace> namespaces) { XNamespace empty; if (!namespaces.TryGetValue(string.Empty, out empty)) { empty = XNamespace.None; } var model = new Type814ServiceStatus { StatusCode = element.GetChildText(empty + "StatusCode"), StatusReason = element.GetChildText(empty + "StatusReason"), StatusType = element.GetChildText(empty + "StatusType"), }; return(model); }
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); }