public ActionResult Add() { var fileStoreSvc = new FileStoreService(); string filePath = fileStoreSvc.SaveNew(Request.Files[0].InputStream); string fileName = Path.GetFileName(filePath); var photo = new Photo() { CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, Description = "My new photo", Filename = fileName, }; var albumsvc = new AlbumService(); var album = albumsvc.GetById(2); album.Photos.Add(photo); albumsvc.Save(); return View(); }
public void Test_Save() { var test = Assembly.GetExecutingAssembly().GetManifestResourceStream("MyPhotos.Tests.IntegrationObjs.Desert.jpg"); var fileService = new FileStoreService(); var fi = fileService.SaveNew(test); Assert.IsTrue(new FileInfo(fi).Exists); }