public async Task <StockMutation[]> GetMutationHistory(int selectedStoreId, long selectProductId, int timeSpanInDays, DateTime startingDate) { string query = "select * from stockmutation where storeId = @0 and productId = @1 and `datetime` > @3 and `datetime` < date_add(@3, interval @2 day);"; object[][] result = await QueryExecutor.SelectMultiple(dbConnectionString, query, MySqlDbType.Int32, selectedStoreId, MySqlDbType.Int32, selectProductId, MySqlDbType.Int32, timeSpanInDays, MySqlDbType.DateTime, startingDate); StockMutation[] mutations = new StockMutation[result.Length]; int counter = 0; foreach (object[] row in result) { int mutationId = (int)row[0]; int storeId = (int)row[1]; int productId = (int)row[2]; int amount = (int)row[3]; string reasonString = (string)row[4]; MutationReason reason = Enum.Parse <MutationReason>(reasonString); DateTime dateTime = (DateTime)row[5]; StockMutation mutation = new StockMutation(mutationId, storeId, productId, amount, reason, dateTime); mutations[counter] = mutation; counter++; } if (counter > 0) { return(mutations); } else { return(null); } }
public StockMutation(int?id, int storeId, int productId, int amount, MutationReason reason, DateTime dateTime) { this.id = id; this.productId = productId; this.amount = amount; this.reason = reason; this.dateTime = dateTime; }