public Type650ServiceChange[] ListServiceChanges(int serviceKey) { using (var connection = new SqlConnection(connectionString)) using (var command = connection.CreateCommand("esp_650ServiceChangeList")) { command.AddWithValue("@Service_Key", serviceKey); if (connection.State != ConnectionState.Open) { connection.Open(); } var collection = new List <Type650ServiceChange>(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { var item = new Type650ServiceChange { ServiceKey = serviceKey, ServiceChangeKey = reader.GetInt32("ServiceChange_Key"), }; reader.TryGetString("ChangeReason", x => item.ChangeReason = x); collection.Add(item); } return(collection.ToArray()); } } }
public int InsertServiceChange(Type650ServiceChange model) { using (var connection = new SqlConnection(connectionString)) using (var command = connection.CreateCommand("csp650ServiceChangeInsert")) { SqlParameter keyParameter; command.AddWithValue("@Service_Key", model.ServiceKey) .AddIfNotEmptyOrDbNull("@ChangeReason", model.ChangeReason) .AddOutParameter("@ServiceChange_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.ServiceChangeKey = changeKey; return(changeKey); } }
public Type650ServiceChange ParseServiceChange(XElement element, IDictionary <string, XNamespace> namespaces) { XNamespace empty; if (!namespaces.TryGetValue(string.Empty, out empty)) { empty = XNamespace.None; } var model = new Type650ServiceChange { ChangeReason = element.GetChildText(empty + "ChangeReason"), }; return(model); }
public void ParseServiceChange(Prism650Context context, string[] marketFields) { var current = context.Current; if (current == null || current.ModelType != Type650Types.Service) { throw new InvalidOperationException(); } var service = current as Type650Service; if (service == null) { throw new InvalidOperationException(); } var model = new Type650ServiceChange { ChangeReason = marketFields.AtIndex(2), }; service.AddChange(model); }