Ejemplo n.º 1
0
        public void ChangeTemplateData(int templateId, WordTemplateDO template)
        {
            GvaWordTemplate templateData = this.unitOfWork.DbContext.Set<GvaWordTemplate>()
                .Where(t => t.GvaWordTemplateId == templateId)
                .Single();

            templateData.DataGeneratorCode = template.DataGenerator.Code;
            templateData.Description = template.Description;
            templateData.Name = template.Name;

            if (template.TemplateFile != null)
            {
                using (MemoryStream stream = new MemoryStream())
                using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DbContext"].ConnectionString))
                {
                    connection.Open();
                    using (var blobStream = new BlobReadStream(connection, "dbo", "Blobs", "Content", "Key", template.TemplateFile.Key))
                    {
                        blobStream.CopyTo(stream);
                        templateData.Template = stream.ToArray();
                    }
                }
            }

            this.unitOfWork.Save();
        }
Ejemplo n.º 2
0
        public void CreateNewTemplate(WordTemplateDO template)
        {
            GvaWordTemplate newTemplate = new GvaWordTemplate()
            {
                Name = template.Name,
                Description = template.Description,
                DataGeneratorCode = template.DataGenerator.Code
            };

            using (MemoryStream stream = new MemoryStream())
            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DbContext"].ConnectionString))
            {
                connection.Open();
                using (var blobStream = new BlobReadStream(connection, "dbo", "Blobs", "Content", "Key", template.TemplateFile.Key))
                {
                    blobStream.CopyTo(stream);
                    newTemplate.Template = stream.ToArray();
                }
            }

            this.unitOfWork.DbContext.Set<GvaWordTemplate>().Add(newTemplate);

            this.unitOfWork.Save();
        }
Ejemplo n.º 3
0
        public IHttpActionResult PostTemplate(int templateId, WordTemplateDO template)
        {
            using (var transaction = this.unitOfWork.BeginTransaction())
            {
                 this.wordTemplateRepository.ChangeTemplateData(templateId, template);

                transaction.Commit();

                return Ok();
            }
        }
Ejemplo n.º 4
0
        public IHttpActionResult PostNewTemplate(WordTemplateDO template)
        {
            using (var transaction = this.unitOfWork.BeginTransaction())
            {
                this.wordTemplateRepository.CreateNewTemplate(template);

                transaction.Commit();

                return Ok();
            }
        }