public static AlbumClass EntityToModel(AlbumModel albumModel) { AlbumClass entity = new AlbumClass(); entity.AlbumId = albumModel.AlbumId; entity.AlbumName = albumModel.AlbumName; entity.Comment = MapCommentsEntityModel(albumModel.AComment); return(entity); }
public static AlbumModel MapAlbumModel(AlbumClass album) { return(new AlbumModel { AlbumId = album.AlbumId, AlbumName = album.AlbumName, AComment = album.Comment.Select(x => CommentsModelMapping.ModelToEntity(x)).ToList() }); }
public static AlbumModel ModelToEntity(AlbumClass entityModel) { var model = new AlbumModel(); model.AlbumId = entityModel.AlbumId; model.AlbumName = entityModel.AlbumName; model.AComment = MapCommentsModel(entityModel.Comment); return(model); }
// GET: Photo public ActionResult AlbumList() { using (var context = new GalleryContext()) { var NewAlbum = new AlbumClass(); NewAlbum.AlbumID = Guid.NewGuid(); NewAlbum.AlbumName = "wowowowow"; context.album.Add(NewAlbum); context.SaveChanges(); } return(View(db.album.ToList())); }
public void AddNewAlbum(AlbumClass newalbum) { using (var context = new MvcDataContext()) { AlbumClass album = new AlbumClass(); album.AlbumId = newalbum.AlbumId; album.AlbumName = newalbum.AlbumName; album.Comment = newalbum.Comment; //album.Photo = newalbum.Photo; context.album.Add(album); context.album.AddOrUpdate(album); context.SaveChanges(); } }