コード例 #1
0
        public async Task <bool> UpdateProfileCollection(UpdateCollection collection)
        {
            Collection updatedCollection = new Collection {
                CollectionId = collection.CollectionId, Title = collection.Title, Description = collection.Description, ProfileId = collection.ProfileId
            };

            _context.Entry(updatedCollection).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                // Save worked
                return(true);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CollectionExists(updatedCollection.CollectionId))
                {
                    return(false);
                }
                else
                {
                    throw;
                }
            }
        }
コード例 #2
0
        public async Task <bool> UpdateArt(CreateArtData art)
        {
            Art newArt = new Art
            {
                ArtId       = art.ArtId,
                ProfileId   = art.ProfileId,
                Title       = art.Title,
                Content     = art.Content,
                Description = art.Description
            };

            _context.Entry(newArt).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ArtExists(art.ArtId))
                {
                    return(false);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
        }