コード例 #1
0
 private void PopulateReport(ConfirmationReportViewModel report)
 {
     ReportNumber           = report.ReportNumber;
     ReportDate             = report.ReportDate;
     OwnerName              = report.OwnerName;
     OtherInterventionOps   = report.OtherInterventionOps;
     CustomerName           = report.CustomerName;
     CustomerRepresentative = report.CustomerRepresentative;
     InterventionMode       = (InterventionMode)Enum.Parse(typeof(InterventionMode), report.InterventionMode.ToString());
     OtherInterventionMode  = report.OtherInterventionMode;
     Notes = report.Notes;
     _Details.Clear();
     if (report.Details != null)
     {
         report.Details.ToList().ForEach(x =>
         {
             _Details.Add(new ConfirmationReportDetail
             {
                 Id          = x.Id,
                 ReportId    = x.ReportId,
                 Date        = x.Date,
                 FromTime    = x.FromTime,
                 ToTime      = x.ToTime,
                 Description = x.Description
             });
         });
     }
 }
        public void Save__overlapped_details__Throw_OverlappedDetailException()
        {
            // Arrange
            var reportView = new ConfirmationReportViewModel
            {
                Details = new List <ConfirmationReportDetailViewModel>
                {
                    new ConfirmationReportDetailViewModel
                    {
                        Date     = new DateTime(2016, 2, 1),
                        FromTime = new DateTime(2016, 2, 1, 8, 0, 0),
                        ToTime   = new DateTime(2016, 2, 1, 18, 0, 0)
                    },
                    new ConfirmationReportDetailViewModel
                    {
                        Date     = new DateTime(2016, 2, 1),
                        FromTime = new DateTime(2016, 2, 1, 8, 0, 0),
                        ToTime   = new DateTime(2016, 2, 1, 18, 0, 0)
                    }
                }
            };

            var report = new ConfirmationReport();

            //Act
            report.Save(reportView);
        }
コード例 #3
0
        public async Task Save__with_Report_null__Throw_ArgumentNullException()
        {
            // Arrange
            ConfirmationReportViewModel model = null;

            command.Save(model).Returns(model);

            // Act
            var worker = new ConfirmationReportWorker(command, query);
            await worker.Save(model);
        }
        public async Task <ConfirmationReportViewModel> SaveDraft(ConfirmationReportViewModel report)
        {
            Contract.Requires <ArgumentNullException>(report != null, "report");

            var domainReport = report.Id.Equals(0) ? new ConfirmationReport() : await repo.GetById(report.Id);

            domainReport.SaveDraft(report);
            await repo.Save(domainReport);

            return(mapper.Map <ConfirmationReportViewModel>(domainReport));
        }
        public void SaveDraft__Report__should_be_marked_as_DRAFT()
        {
            // Arrange
            var reportView = new ConfirmationReportViewModel {
            };
            var report     = new ConfirmationReport();

            // Act
            report.SaveDraft(reportView);

            // Assert
            Assert.That(report.Status, Is.EqualTo(Domain.Model.ReportStatus.Draft));
        }
        public async Task SaveDraft__ConfirmationReportViewModel_null__Throw_ArgumentNullException()
        {
            // Arrange
            ConfirmationReportViewModel model = null;

            mapper.Map <ConfirmationReport>(null).Returns(null as ConfirmationReport);
            mapper.Map <ConfirmationReportViewModel>(null).Returns(null as ConfirmationReportViewModel);

            var service = new ConfirmationReportCommandService(repo, mapper);

            // Act
            var actual = await service.SaveDraft(model);
        }
        public void Save__Report__should_be_marked_as_COMPLETED()
        {
            // Arrange
            var reportView = new ConfirmationReportViewModel {
            };
            var report     = new ConfirmationReport();

            // Act
            report.Save(reportView);

            // Assert
            Assert.That(report.Status, Is.EqualTo(Domain.Model.ReportStatus.Completed));
        }
        public async Task SaveDraft__ConfirmationReportViewModel_with_Id_Zero__Should_not_get_ConfirmationReport_from_Repo()
        {
            // Arrange
            ConfirmationReportViewModel model = new ConfirmationReportViewModel {
            };
            ConfirmationReport domainModel    = new ConfirmationReport {
            };
            var service = new ConfirmationReportCommandService(repo, mapper);

            // Act
            await service.SaveDraft(model);

            // Assert
            await repo.DidNotReceive().GetById(Arg.Any <int>());
        }
コード例 #9
0
        public async Task Save__with_Report_not_null__call_worker()
        {
            // Arrange
            ConfirmationReportViewModel model = new ConfirmationReportViewModel {
            };

            command.Save(model).Returns(model);

            // Act
            var worker = new ConfirmationReportWorker(command, query);
            var actual = await worker.Save(model);

            // Assert
            Assert.That(actual, Is.SameAs(model));
        }
コード例 #10
0
        public async Task FindById__with_reportNumber_greater_than_0__call_service()
        {
            // Arrange
            int reportNumber = 3;
            var expected     = new ConfirmationReportViewModel {
            };

            query.FindById(reportNumber).Returns(expected);

            //Act
            var worker = new ConfirmationReportWorker(command, query);
            var actual = await worker.FindById(reportNumber);

            // Assert
            Assert.That(actual, Is.SameAs(expected));
        }
        public async Task SaveDraft__ConfirmationReportViewModel_not_Empty__Should_call_SaveDraft_on_Domain()
        {
            // Arrange
            ConfirmationReportViewModel model = new ConfirmationReportViewModel {
                Id = 1
            };
            ConfirmationReport domainModel = Substitute.For <ConfirmationReport>();

            repo.GetById(model.Id).Returns(domainModel);
            var service = new ConfirmationReportCommandService(repo, mapper);

            // Act
            await service.SaveDraft(model);

            // Assert
            domainModel.Received().SaveDraft(model);
        }
        public async Task SaveDraft__ConfirmationReportViewModel_with_Id_not_Zero__Should_get_ConfirmationReport_from_Repo()
        {
            // Arrange
            ConfirmationReportViewModel model = new ConfirmationReportViewModel {
                Id = 1
            };
            ConfirmationReport domainModel = new ConfirmationReport {
            };

            repo.GetById(model.Id).Returns(domainModel);
            var service = new ConfirmationReportCommandService(repo, mapper);

            // Act
            await service.SaveDraft(model);

            // Assert
            await repo.Received().GetById(model.Id);
        }
        public async Task <IHttpActionResult> FindById(int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ConfirmationReportViewModel report = await worker.FindById(id);

            if (report != null)
            {
                return(Ok(report));
            }
            else
            {
                return(NotFound());
            }
        }
        public async Task <IHttpActionResult> Save(ConfirmationReportViewModel report)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            bool isNew = report.Id == 0;

            var returnedReport = await worker.Save(report);

            if (isNew)
            {
                return(Created(new Uri(Url.Link("FindById", new { id = report.Id })), report));
            }
            else
            {
                return(Ok(report));
            }
        }
コード例 #15
0
        public async Task SaveDraft__If_Model_is_invalid__Return_BadRequest()
        {
            // Arrange
            var model = new ConfirmationReportViewModel {
                Id = 5
            };

            IConfirmationReportWorker worker = Substitute.For <IConfirmationReportWorker>();

            worker.SaveDraft(model).Returns(new ConfirmationReportViewModel {
                Id = 5
            });

            var controller = new ConfirmationReportController(worker);

            controller.ModelState.AddModelError("fakeError", "fakeError");

            // Act
            var actual = await controller.SaveDraft(model);

            // Assert
            Assert.IsAssignableFrom <InvalidModelStateResult>(actual);
        }
コード例 #16
0
        public async Task SaveDraft__Report_With_Id_Not_0__Return_Ok_Status()
        {
            // Arrange
            var model = new ConfirmationReportViewModel {
                Id = 5
            };

            IConfirmationReportWorker worker = Substitute.For <IConfirmationReportWorker>();

            worker.SaveDraft(model).Returns(new ConfirmationReportViewModel {
                Id = 5
            });

            var controller = new ConfirmationReportController(worker);

            SubstituteUrlHelper(controller, "http://localhost/api/Reports/id/5");

            // Act
            var actual = await controller.SaveDraft(model);

            // Assert
            Assert.IsAssignableFrom <OkNegotiatedContentResult <ConfirmationReportViewModel> >(actual);
        }
コード例 #17
0
 public void Save(ConfirmationReportViewModel report)
 {
     this.Status = ReportStatus.Completed;
     PopulateReport(report);
     CheckInvariants();
 }
 public async Task <ConfirmationReportViewModel> Save(ConfirmationReportViewModel report)
 {
     Contract.Requires <ArgumentNullException>(report != null, "report");
     return(await command.Save(report));
 }
コード例 #19
0
 public void SaveDraft(ConfirmationReportViewModel report)
 {
     Status = ReportStatus.Draft;
     PopulateReport(report);
     CheckInvariants();
 }
コード例 #20
0
        public IEnumerable <ConfirmationReportViewModel> Create(IEnumerable <CallQueueCustomer> callQueueCustomers, IEnumerable <Customer> customers, IEnumerable <EventBasicInfoViewModel> events, IEnumerable <Call> calls,
                                                                IEnumerable <EventCustomer> eventCustomers, IEnumerable <Appointment> appointments, IEnumerable <CorporateAccount> healthPlans, IEnumerable <OrderedPair <long, string> > restrictionIdNamePairs,
                                                                IEnumerable <OrderedPair <long, string> > confirmedByIdNamePairs, IEnumerable <OrderedPair <long, string> > calledByAgentNameIdPairs, IEnumerable <CallQueueCustomerCall> callQueueCustomerCalls)
        {
            var collection = new List <ConfirmationReportViewModel>();

            foreach (var cqc in callQueueCustomers)
            {
                var customer = customers.First(x => x.CustomerId == cqc.CustomerId);

                var eventData = events.FirstOrDefault(x => x.Id == cqc.EventId);

                var callIds       = callQueueCustomerCalls.Where(x => x.CallQueueCustomerId == cqc.Id).Select(x => x.CallId);
                var customerCalls = calls.Where(x => callIds.Contains(x.Id)).OrderByDescending(x => x.DateCreated);
                if (!customerCalls.Any())
                {
                    customerCalls = calls.Where(x => x.CalledCustomerId == cqc.CustomerId && x.EventId == cqc.EventId).OrderByDescending(x => x.DateCreated);
                }

                var eventCustomer = cqc.EventCustomerId.HasValue ? eventCustomers.First(x => x.Id == cqc.EventCustomerId.Value) : null;
                if (eventCustomer == null)
                {
                    eventCustomer = eventCustomers.FirstOrDefault(x => x.CustomerId == cqc.CustomerId && x.EventId == cqc.EventId);
                }

                var appointment = eventCustomer != null && eventCustomer.AppointmentId.HasValue ? appointments.First(x => x.Id == eventCustomer.AppointmentId.Value) : null;

                var outcome     = string.Empty;
                var disposition = string.Empty;
                var calledBy    = string.Empty;

                var healthPlan   = cqc.HealthPlanId.HasValue ? healthPlans.First(x => x.Id == cqc.HealthPlanId.Value) : null;
                var restrictedTo = healthPlan != null && restrictionIdNamePairs != null?restrictionIdNamePairs.Where(x => x.FirstValue == healthPlan.Id).Select(x => x.SecondValue).Distinct() : null;

                var confirmedBy = eventCustomer != null && eventCustomer.ConfirmedBy.HasValue ? confirmedByIdNamePairs.First(x => x.FirstValue == eventCustomer.ConfirmedBy.Value).SecondValue : "";

                if (customerCalls.Any())
                {
                    outcome = EnumExtension.GetDescription(((CallStatus)customerCalls.First().Status));

                    ProspectCustomerTag prospectCustomerTag;
                    Enum.TryParse(customerCalls.First().Disposition, out prospectCustomerTag);
                    var isDefined = Enum.IsDefined(typeof(ProspectCustomerTag), prospectCustomerTag);
                    disposition = customerCalls.First().Disposition != string.Empty && isDefined?EnumExtension.GetDescription(prospectCustomerTag) : "N/A";

                    calledBy = calledByAgentNameIdPairs.First(x => x.FirstValue == customerCalls.First().CreatedByOrgRoleUserId).SecondValue;
                }

                var model = new ConfirmationReportViewModel
                {
                    PatientId       = customer.CustomerId,
                    Name            = customer.Name.FullName,
                    EventID         = eventData.Id,
                    EventAddress    = eventData.HostAddress,
                    EventDate       = eventData.EventDate,
                    AppointmentTime = appointment != null?eventData.EventDate.Add(appointment.StartTime.TimeOfDay) : (DateTime?)null,
                                          BookingDate       = eventCustomer != null ? eventCustomer.DataRecorderMetaData.DateCreated : (DateTime?)null,
                                          LastContactedDate = customerCalls.Any() ? customerCalls.First().DateCreated : (DateTime?)null,
                                          Outcome           = outcome,
                                          Disposition       = disposition,
                                          CallCount         = customerCalls.Count(),
                                          IsRestricted      = healthPlan != null && healthPlan.RestrictHealthPlanData ? "Yes" : "No",
                                          RestrictedTo      = !restrictedTo.IsNullOrEmpty() ? string.Join(", ", restrictedTo) : "N/A",
                                          CalledBy          = calledBy
                };

                collection.Add(model);
            }

            return(collection);
        }