コード例 #1
0
        /// <summary>
        /// Update the specified template
        /// </summary>
        public NotificationTemplate Update(NotificationTemplate template)
        {
            try
            {
                lock (this.m_lock)
                {
                    this.m_repository.RemoveAll(o => o.Id == template.Id && o.Language == template.Language);
                    this.m_repository.Add(template);
                }

                var fileName = Path.Combine(this.m_configuration.RepositoryRoot, template.Language ?? "default", template.Id + ".xml");
                if (!Directory.Exists(Path.GetDirectoryName(fileName)))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(fileName));
                }

                using (var fs = File.Create(fileName))
                    return(template.Save(fs));
            }
            catch (Exception e)
            {
                this.m_tracer.TraceError("Error updating the specified template - {0}", e);
                throw new Exception($"Error inserting {template.Id}", e);
            }
        }