コード例 #1
0
        public int Insert(Models.Collection collection)
        {
            tblCollection newCollection = new tblCollection {
                MessageTypeId = collection.MessageTypeId
            };

            db.Collections.Add(newCollection);

            db.SaveChanges();
            return(newCollection.Id);
        }
コード例 #2
0
ファイル: Artwork.cs プロジェクト: taylorcarlsen/Octo.Net
        public int Insert(Models.Artwork artwork, Models.File file)
        {
            tblCollection newCollection = new tblCollection {
                MessageTypeId = 3
            };

            db.Collections.Add(newCollection);
            db.SaveChanges();

            tblArtwork tblArtwork = new tblArtwork {
                GalleryId           = artwork.GalleryId,
                Title               = artwork.Title,
                Price               = artwork.Price,
                IsCommission        = artwork.IsCommission,
                TagId               = artwork.TagId,
                CollectionMessageId = newCollection.Id,
                DateCreated         = DateTime.Now
            };

            db.Artworks.Add(tblArtwork);
            db.SaveChanges();

            tblFiles tblFiles = new tblFiles
            {
                FileName    = file.FileName,
                ContentType = file.ContentType,
                Content     = file.Content,
                FileType    = tblFileType.Photo,
                ArtworkId   = artwork.Id,
                UserId      = file.UserId,
                Artwork     = tblArtwork
            };

            db.Files.Add(tblFiles);
            db.SaveChanges();

            return(tblArtwork.Id);
        }