public List<Column> GetAllColumnsAndStories() { using (var query = new DataQuery(_provider).WithStoredProcedure("up_GetAllColumnsAndStorries")) { var reader = query.ExecuteQuery(); List<Column> columns = new List<Column>(); while (reader.Read()) { Story story = null; int colIndex = reader.GetOrdinal("StoryId"); if (!reader.IsDBNull(colIndex)) { story = _mapper.MapStory(reader); } var columnName = (string)reader["ColumnName"]; if (columns.Exists(x => x.ColumnName == columnName)) { var column = columns.Find(x => x.ColumnName == columnName); column.Stories.Add(story); } else { var column = _mapper.MapColumn(reader); columns.Add(column); column.Stories.Add(story); } } return columns; } }
public bool DeleteStory(int storyId) { using (var query = new DataQuery(_provider) .WithStoredProcedure("up_DeleteStory") .WithParam("@StoryId", storyId.ToString())) { var deleteStatement = query.ExecuteQuery(); if (deleteStatement.HasRows) { return false; } return true; } }
public Story InsertNewStory(Story story) { using (var query = new DataQuery(_provider) .WithStoredProcedure("up_InsertNewStory") .WithParam("@StoryTitle", story.Title) .WithParam("@StoryContent", story.Content) .WithParam("@StoryColumnId", story.ColumnId.ToString()) .WithParam("@StoryColorValue", story.ColorValue)) { var insert = query.ExecuteQuery(); Story newStory = new Story(); while (insert.Read()) { newStory = _mapper.MapStory(insert); } return newStory; } }