public int CreateCafeAlbum(AlbumLang model) { using (var db = new DataContext()) { var album = new CafeAlbum() { CreateDate = (model.CreateDate == null) ? DateTime.Now : model.CreateDate }; db.CafeAlbums.Add(album); var albumRu = new CafeAlbumLanguage() { CafeAlbumId = album.Id, LanguageId = EnumLanguage.ru, Name = model.Ru_Title }; db.CafeAlbumLanguages.Add(albumRu); var albumRo = new CafeAlbumLanguage() { CafeAlbumId = album.Id, LanguageId = EnumLanguage.ro, Name = model.Ro_Title }; db.CafeAlbumLanguages.Add(albumRo); db.SaveChanges(); return(album.Id); } }
public static ModelCafeAlbum ConvertToModelCafeAlbum(CafeAlbumLanguage album) { return(new ModelCafeAlbum() { Id = album.CafeAlbumId, Name = album.Name, //Descrition = album.Descrition, CreateDate = album.CafeAlbum.CreateDate //PhotoName = album.Album.PhotoName }); }