コード例 #1
0
        public void Run([CosmosDBTrigger(
                             databaseName: "letmeworkCosmosDB",
                             collectionName: "meetings",
                             ConnectionStringSetting = "letmework4U_DOCUMENTDB",
                             LeaseCollectionName = "leasesMeetings",
                             CreateLeaseCollectionIfNotExists = true)] IReadOnlyList <Document> input, ILogger log)
        {
            try
            {
                if (input != null && input.Count > 0)
                {
                    var meeting = (Meeting)input;

                    foreach (var meetingFollowUp in meeting.FollowUpMeetings)
                    {
                        _meetingRepository.UpdateItemAsync(new Guid(meeting.ApplicantId), meetingFollowUp);
                    }

                    foreach (var recruiter in meeting.Recruiters)
                    {
                        _recruiterRepository.UpdateItemAsync(new Guid(recruiter.Id), recruiter);
                    }
                }
            }
            catch (Exception ex)
            {
                // TODO log exception
                throw ex;
            }
        }
コード例 #2
0
        public void Run([CosmosDBTrigger(
                             databaseName: "letmeworkCosmosDB",
                             collectionName: "jobApplications",
                             ConnectionStringSetting = "letmework4U_DOCUMENTDB",
                             LeaseCollectionName = "leasesJobApplications",
                             CreateLeaseCollectionIfNotExists = true)] IReadOnlyList <Document> input, ILogger log)
        {
            if (input != null && input.Count > 0)
            {
                try
                {
                    var jobApplication = JsonConvert.DeserializeObject <JobApplication>(input[0].ToString());

                    if (jobApplication.Company != null)
                    {
                        _companyRepository.UpdateItemAsync(new Guid(jobApplication.Company.Id), jobApplication.Company);
                    }

                    if (jobApplication.FirstMeeting != null)
                    {
                        _meetingRepository.UpdateItemAsync(new Guid(jobApplication.ApplicantId), jobApplication.FirstMeeting);
                    }

                    if (jobApplication.ApplicantTasks.Any())
                    {
                        foreach (var appTask in jobApplication.ApplicantTasks)
                        {
                            _applicantTaskRepository.UpdateItemAsync(new Guid(jobApplication.ApplicantId), appTask);
                        }
                    }

                    if (jobApplication.Recruiters.Any())
                    {
                        foreach (var recruiter in jobApplication.Recruiters)
                        {
                            _recruiterRepository.UpdateItemAsync(new Guid(recruiter.Id), recruiter);
                        }
                    }
                }
                catch (Exception ex)
                {
                    // TODO log exception
                    throw ex;
                }
            }
        }