示例#1
0
 private static void ValidateEntityNull(Entities.BatchEntity entity)
 {
     if (entity == null)
     {
         throw new ArgumentNullException("Parameter 'entity' cannot be null!", "entity");
     }
 }
示例#2
0
        public void UpdateBatch(Entities.BatchEntity entity)
        {
            // Parameter Validation
            ValidateEntityNull(entity);
            ValidateMandatoryParams(entity);

            // First of all try to find the existing batch
            var existingEntity = FindExistingBatch(entity.Id);

            // Now update the entity
            var updateOp = TableOperation.Merge(entity);

            _azureTable.Execute(updateOp);
        }
示例#3
0
        public Entities.BatchEntity CreateBatch(Entities.BatchEntity entity)
        {
            // Parameter Validations
            ValidateEntityNull(entity);
            ValidateMandatoryParams(entity);

            // Next add the batch to the table
            var insertOp = TableOperation.Insert(entity);

            _azureTable.Execute(insertOp);

            // Return the entity with the updated ID
            return(entity);
        }
示例#4
0
 private static void ValidateMandatoryParams(Entities.BatchEntity entity)
 {
     if (string.IsNullOrEmpty(entity.Id))
     {
         throw new ArgumentException("Parameter 'entity.Id' cannot be null or empty for an update!");
     }
     if (string.IsNullOrEmpty(entity.Name))
     {
         throw new ArgumentException("Parameter 'entity.Name' cannot be null or empty!");
     }
     if (entity.Priority < 0)
     {
         throw new ArgumentException("Parameter 'entity.Priority' must be >= 0!");
     }
 }