コード例 #1
0
        public void InsertJobReadyForPayment()
        {
            Parent parent = _parentRepo.GetAll().FirstOrDefault(m => m.Id == 1);
            List<MySitterHub.Model.Core.Sitter> sitters = new SitterRepository().GetAll();

            MySitterHub.Model.Core.Sitter sitter = sitters[0];

            // Create Job.
            var job = new Job
            {
                ParentId = parent.Id,
                Duration = 3,
                Start = new DateTime(2015, 1, 1),
                State = JobState.Accepted
            };

            var invite = new JobInvite {SitterId = sitter.Id, RatePerHour = 10, InvitedDate = job.Start.AddDays(-3), LatestResponseDate = job.Start.AddDays(-2)};
            job.JobInvites = new List<JobInvite>();
            job.JobInvites.Add(invite);
            job.AcceptedSitterId = sitter.Id;

            invite.State = InvitationState.Accepted;
            invite.LatestResponseMessage = "yes";

           // var finalize = new FinalizeJobPaymentSM();
           //// finalize.JobId = job.Id;
           // finalize.UserId = job.ParentId;
           // finalize.Duration = job.Duration;
           // finalize.Bonus = 5;
           // job.SetFinalPayment(finalize);

            _jobDal.Insert(job);
        }
コード例 #2
0
        private void AddInvites(Job job, IEnumerable<int> sitterIds, int? acceptedSitterId = null)
        {
            job.JobInvites = new List<JobInvite>();
            foreach (int id in sitterIds)
            {
                var invite = new JobInvite {SitterId = id, RatePerHour = 5 + id, InvitedDate = job.Start.AddDays(-3), LatestResponseDate = job.Start.AddDays(-2)};
                job.JobInvites.Add(invite);
                if (id == acceptedSitterId)
                {
                    invite.State = InvitationState.Accepted;
                    invite.LatestResponseMessage = "yes";
                }
                else
                {
                    invite.State = InvitationState.Declined; //Futuredev: make some responses blank
                    invite.LatestResponseMessage = "no";
                }
            }
            if (acceptedSitterId != null && job.JobInvites.All(m => m.SitterId != acceptedSitterId.Value))
                throw new Exception();

            job.AcceptedSitterId = acceptedSitterId;
        }