Ejemplo n.º 1
0
        public async Task <IActionResult> SetStatusUnderWriterApproved([FromBody] dynamic data)
        {
            try
            {
                var existingIO = _inspectionOrderRepository.Retrieve((Guid)data.id);

                existingIO.Policy.InspectionStatusId = (string)data.status;

                existingIO.Policy.MitigationStatusId = (string)data.mitigationStatus;

                if (existingIO.Policy.MitigationStatusId == MitigationStatusConstants.OutstandingItems ||
                    existingIO.Policy.MitigationStatusId == MitigationStatusConstants.NoneRequired)
                {
                    _inspectionOrderRepository.SendEmailToInsured(
                        Domain.CustomCodes.AppSettings.WebHost,
                        Domain.CustomCodes.AppSettings.EmailSender,
                        existingIO);
                }

                _inspectionOrderRepository.InsertOrUpdateIO(existingIO);

                await _inspectionOrderService.SendEmailToInspectionUWA(existingIO, Domain.CustomCodes.AppSettings.WebHost);

                return(Ok());
            }
            catch (Exception e)
            {
                return(BadRequest());
            }
        }
        public InspectionOrder ProcessIO(InspectionOrder inspectionOrder, Guid assignedById)
        {
            // From Pending Assignment to Ready To Schedule
            //if (inspectionOrder.InspectorId != null &&
            //    inspectionOrder.Policy.InspectionStatusId == InspectionStatusConstants.PendingAssignment)
            //{
            //    inspectionOrder.Policy.InspectionStatusId = InspectionStatusConstants.ReadyToSchedule;
            //}

            // From Ready To Schedule to Scheduled
            //if (inspectionOrder.Policy.InspectionStatusId == InspectionStatusConstants.ReadyToSchedule &&
            //    inspectionOrder.InspectionDate != null)
            //{
            //    inspectionOrder.Policy.InspectionStatusId = InspectionStatusConstants.Scheduled;
            //}

            switch (inspectionOrder.Policy.InspectionStatusId)
            {
            case InspectionStatusConstants.PendingAssignment:
                inspectionOrder.CreatedDate = DateTime.Now.Date;
                break;

            case InspectionStatusConstants.ReadyToSchedule:
                inspectionOrder.AssignedDate = DateTime.Now.Date;
                inspectionOrder.AssignedById = assignedById;
                break;

            case InspectionStatusConstants.Scheduled:
                if (inspectionOrder.AssignedById == null)
                {
                    inspectionOrder.AssignedDate = DateTime.Now.Date;
                    inspectionOrder.AssignedById = assignedById;
                }
                this.SendInsuredEmailOnScheduled(inspectionOrder, Domain.CustomCodes.AppSettings.WebHost);
                break;

            default:
                break;
            }

            if (inspectionOrder.Policy.MitigationStatusId == MitigationStatusConstants.OutstandingItems ||
                inspectionOrder.Policy.MitigationStatusId == MitigationStatusConstants.Completed ||
                inspectionOrder.Policy.MitigationStatusId == MitigationStatusConstants.NoneRequired)
            {
                _inspectionOrderRepository.SendEmailToInsured(
                    Domain.CustomCodes.AppSettings.WebHost,
                    Domain.CustomCodes.AppSettings.EmailSender,
                    inspectionOrder);
            }

            return(inspectionOrder);
        }