コード例 #1
0
        /// <summary>
        /// Validates and saves a largeObject
        /// </summary>
        /// <param name="largeObjectModel"></param>
        public void Save(Model.LargeObject.LargeObjectModel largeObjectModel)
        {
            Common.Validation.ValidationService validationService = new Common.Validation.ValidationService();
            validationService.ValidateObject(largeObjectModel);

            largeObjectRepository.InsertOrReplace(largeObjectModel);
        }
コード例 #2
0
        /// <summary>
        /// Validates and saves a customer
        /// </summary>
        /// <param name="customerModel"></param>
        public void Save(Model.Customer.CustomerModel customerModel)
        {
            Common.Validation.ValidationService validationService = new Common.Validation.ValidationService();
            validationService.ValidateObject(customerModel);

            customerRepository.InsertOrReplace(customerModel);
        }
コード例 #3
0
        /// <summary>
        /// Saves the file as binary
        /// </summary>
        /// <param name="fileModel"></param>
        public void PutFileAsBytes(Sample.Azure.Model.File.FileModel fileModel)
        {
            Sample.Azure.Common.Validation.ValidationService validationService = new Common.Validation.ValidationService();
            validationService.ValidateObject <Sample.Azure.Model.File.FileModel>(fileModel);
            if (fileModel.Bytes == null)
            {
                throw new ArgumentException("Bytes may not be null;");
            }

            AzureBlobHelper azureBlobHelper = new AzureBlobHelper();

            string fullPath = string.Empty;

            if (string.IsNullOrWhiteSpace(fileModel.Path))
            {
                fullPath = fileModel.Name;
            }
            else
            {
                fullPath = System.IO.Path.Combine(fileModel.Path, fileModel.Name);
            }
            if (fileModel.Bytes != null)
            {
                System.IO.MemoryStream ms = new MemoryStream(fileModel.Bytes);
                azureBlobHelper.SaveBlob(fileModel.Container.ToLower(), fullPath, ms);
            }
            else
            {
                System.IO.MemoryStream ms = null;
                azureBlobHelper.SaveBlob(fileModel.Container.ToLower(), fullPath, ms);
            }
        }