Ejemplo n.º 1
0
 public Story MapStory(SqlDataReader reader)
 {
     var story = new Story
     {
         Id = (int)reader["StoryId"],
         Title = (string)reader["StoryTitle"],
         Content = (string)reader["StoryContent"],
         ColumnId = (int)reader["StoryColumnId"],
         ColorValue = (string)reader["StoryColorValue"]
     };
     return story;
 }
        public void Setup()
        {
            var container = IoC.GetInstance();
            _databaseRepository = container.GetInstance<IDatabaseRepository>();

            _story = new Story
            {
                Title = "Integration test story",
                Content = "Content of the story",
                ColumnId = 1,
                ColorValue = ""
            };
        }
        public ActionResult AddNewStory(string storyTitle, string storyContent, string defaultColor)
        {
            var newStory = new Story();

            newStory.Title = storyTitle;
            newStory.Content = storyContent;
            newStory.ColorValue = defaultColor;
            newStory.ColumnId = 1;

            _db.Stories.Add(newStory);
            _db.SaveChanges();

            var story = _db.Stories.Find(newStory.Id);

            return Json(story);
        }
        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;
            }
        }