public Type810Message[] ListMessages(int headerKey) { using (var connection = new SqlConnection(connectionString)) using (var command = connection.CreateCommand("esp_810MessageList")) { command.AddWithValue("@HeaderKey", headerKey); if (connection.State != ConnectionState.Open) { connection.Open(); } var collection = new List <Type810Message>(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { var item = new Type810Message { HeaderKey = headerKey, MessageKey = reader.GetInt32("Message_Key"), }; reader.TryGetString("ItemDescType", x => item.ItemDescType = x); reader.TryGetString("ProductCode", x => item.ProductCode = x); reader.TryGetString("Description", x => item.Description = x); reader.TryGetString("PositionCode", x => item.PositionCode = x); collection.Add(item); } return(collection.ToArray()); } } }
public int InsertMessage(Type810Message model) { using (var connection = new SqlConnection(connectionString)) using (var command = connection.CreateCommand("csp810MessageInsert")) { SqlParameter keyParameter; command.AddWithValue("@810_Key", model.HeaderKey) .AddWithValue("@ItemDescType", model.ItemDescType) .AddWithValue("@ProductCode", model.ProductCode) .AddWithValue("@Description", model.Description) .AddWithValue("@PositionCode", model.PositionCode) .AddOutParameter("@Message_Key", SqlDbType.Int, out keyParameter); if (connection.State != ConnectionState.Open) { connection.Open(); } command.ExecuteNonQuery(); if (keyParameter.Value == null) { throw new Exception(); } var messageKey = (int)keyParameter.Value; model.MessageKey = messageKey; return(messageKey); } }
public Type810Message ParseMessage(XElement element, IDictionary <string, XNamespace> namespaces) { XNamespace empty; if (!namespaces.TryGetValue(string.Empty, out empty)) { empty = XNamespace.None; } var model = new Type810Message { ItemDescType = element.GetChildText(empty + "ItemDescType"), ProductCode = element.GetChildText(empty + "ProductCode"), Description = element.GetChildText(empty + "Description"), PositionCode = element.GetChildText(empty + "PositionCode"), }; return(model); }
public int InsertMessage(Type810Message model) { return(-1); }