Exemple #1
0
 private static void ValidateEntityNull(Entities.JobEntity entity, string paramName)
 {
     if (entity == null)
     {
         throw new ArgumentNullException("You need to pass in a JobEntity into the repository, parameter 'entity' cannot be null!", paramName);
     }
 }
Exemple #2
0
 private static void ValidateMandatoryParams(Entities.JobEntity entity)
 {
     if (string.IsNullOrEmpty(entity.JobId))
     {
         throw new ArgumentException("JobId must be passed into the repository for all operations!", "entity.JobId");
     }
     if (string.IsNullOrEmpty(entity.Name))
     {
         throw new ArgumentException("Job must have a property 'Name' assigned with a value!", "entity.Name");
     }
     if (entity.Parameters == null)
     {
         throw new ArgumentNullException("Parameters cannot be null, please send string.empty if you don't want to pass parameters!", "entity.Parameters");
     }
     if (entity.ScheduledBy == null)
     {
         throw new ArgumentNullException("ScheduledBy cannot be null, please send string.empty if you don't want to specify a user name!", "entity.ScheduledBy");
     }
     if (string.IsNullOrEmpty(entity.Type))
     {
         throw new ArgumentException("Job-type must be specified in 'Type' property!", "entity.Type");
     }
     if (string.IsNullOrEmpty(entity.BatchId))
     {
         throw new ArgumentException("BatchId is missing in Job and is mandatory!", "entity.BatchId");
     }
     if (string.IsNullOrEmpty(entity.BatchName))
     {
         throw new ArgumentException("BatchName is missing in Job and is mandatory!", "entity.BatchName");
     }
 }
Exemple #3
0
 public CompletedJobsViewModel(Entities.JobEntity jobEntity)
 {
     this.Id            = jobEntity.JobId;
     this.CompletedDate = jobEntity.FinishDate.GetValueOrDefault().ToString("g");
     this.JobReference  = jobEntity.JobReference;
     this.JobDisplay    = String.Format("{0} ({1})", this.CompletedDate, this.JobReference);
 }
Exemple #4
0
        public Entities.JobEntity CreateJob(Entities.JobEntity newJob)
        {
            // First of all validate parameters
            ValidateEntityNull(newJob, "newJob");
            ValidateMandatoryParams(newJob);

            // Then create the method for insertions
            var insertOp = TableOperation.Insert(newJob);

            _azureTable.Execute(insertOp);

            // Return the entity
            return(newJob);
        }
Exemple #5
0
        public void UpdateJob(Entities.JobEntity job)
        {
            // Parameter Validations
            ValidateEntityNull(job, "job");
            ValidateMandatoryParams(job);

            // Next find the existing entity
            FindExistingJob(job.JobId, job.BatchId);

            // Now Update the job
            var updateOp = TableOperation.Merge(job);

            _azureTable.Execute(updateOp);
        }