Exemplo n.º 1
0
        public Task UpdateAsync(JobInformation jobInformation)
        {
            if (jobInformation == null)
            {
                throw new ArgumentNullException(nameof(jobInformation));
            }

            if (jobInformations.TryGetValue(jobInformation.JobInformationId, out JobInformation currentJobInformation))
            {
                if (ReferenceEquals(jobInformation, currentJobInformation))
                {
                    return(Task.CompletedTask);
                }
            }
            else
            {
                throw new Exception("Entity to update do not exist");
            }

            if (jobInformations.TryUpdate(jobInformation.JobInformationId, jobInformation, null))
            {
                return(Task.CompletedTask);
            }
            else
            {
                throw new Exception("Entity to update do not exist");
            }
        }
Exemplo n.º 2
0
        public Task CreateAsync(JobInformation jobInformation)
        {
            if (jobInformation == null)
            {
                throw new ArgumentNullException(nameof(jobInformation));
            }

            jobInformation.JobInformationId = GetNextJobInformationId();

            if (jobInformations.TryAdd(jobInformation.JobInformationId, jobInformation))
            {
                return(Task.CompletedTask);
            }
            else
            {
                throw new Exception("Entity with same key already exist");
            }
        }