Пример #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!");
     }
 }