public NewsViewModel.Details AddPicture(Guid newsGuid, String pictureUrl) { YoumotoDbContext context = this.context ?? new YoumotoDbContext(); var result = NewsPersister.LoadSingle(context, newsGuid); var newPicture = NewsPersister.CreatePicture(result, pictureUrl); context.NewsPictures.Add(newPicture); context.SaveChanges(); return(new Models.NewsViewModel.Details(result)); }
public void CreateNewsPicture() { using (var context = new YoumotoDbContext(Effort.DbConnectionFactory.CreateTransient())) { String url = "https://www.youmoto.com/test.jpg"; News news = NewsPersister.Create("MyTitle"); NewsPicture newsPicture = NewsPersister.CreatePicture(news, url); context.News.Add(news); context.SaveChanges(); Assert.AreEqual(1, context.News.Count()); Assert.AreEqual(1, context.NewsPictures.Count()); Assert.AreEqual(1, context.News.First().NewsPictures.Count()); Assert.AreEqual(url, context.News.First().NewsPictures.First().ImageLink); } }