Example #1
0
        private static void WriteMetadata(string id, GalleryMetadata metadata) 
        {
            var folder = GetGalleryFolder(id);
            var metadataPath = Path.Combine(folder, MetadataFileName);

            using (FileStream fs = new FileStream(metadataPath, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                using (StreamWriter writer = new StreamWriter(fs, Encoding.UTF8))
                {
                    writer.Write(JsonConvert.SerializeObject(metadata));
                }
            }
            
        }
Example #2
0
        public HttpResponseMessage Metadata(string id, GalleryMetadata metadata)
        {
            if (metadata == null || (metadata.Title == null && metadata.Description == null))
            {
                Trace.TraceInformation("PUT GalleryMetadata did not save metadata. No metadata was received");
                return new HttpResponseMessage(HttpStatusCode.OK);
            }
            DateTime lastUpdateTime = DateTime.Now;
            metadata.Id = TrimName(id);
            metadata.LastUpdateTime = lastUpdateTime.ToString("Y");
            metadata.LastUpdateTimeFull = lastUpdateTime.ToString("O");
            WriteMetadata(id, metadata);

            Trace.TraceInformation("PUT GalleryMetadata title: {0}{1}description: {1}",
                metadata.Title, Environment.NewLine, metadata.Description);

            return new HttpResponseMessage(HttpStatusCode.OK);
        }