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 ConvertCafePhotos(CafeAlbum album) { return(new ModelCafeAlbum() { Id = album.Id, CreateDate = album.CreateDate, PhotoName = album.PhotoName }); }