public ActionResult CreateAlbum(AlbumViewModel model) { if (ModelState.IsValid) { ImageShareDbContext ImagesContext = HttpContext.GetOwinContext().Get<ImageShareDbContext>(); Album album = new Album(); album.Name = model.Name; album.ApplicationUserID = HttpContext.User.Identity.GetUserId(); album.Type = AlbumType.Album; ImagesContext.Albums.Add(album); ImagesContext.SaveChanges(); return RedirectToAction("AddImages", "Images"); } return View(model); }
private void initializeDefaultAlbum() { string currentUserId = HttpContext.User.Identity.GetUserId(); Album createDefaultAlbum = new Album(); createDefaultAlbum.ApplicationUserID = currentUserId; createDefaultAlbum.Name = "No Album"; createDefaultAlbum.Type = AlbumType.NoAlbum; ImagesContext.Albums.Add(createDefaultAlbum); ImagesContext.SaveChanges(); }