コード例 #1
0
        public JsonResult UpdateLabTestingFail(int id)
        {
            var result  = _labTestingService.UpdateFail(id);
            var result1 = _labTestingService.GetLabTesting(id);
            //từ labtesting lấy ra samplegetting
            var s = result1.SampleGettingId; var sampleGetting = _sampleGettingService.GetSampleGetting(int.Parse(s.ToString()));
            //từ samplegetting lấy ra appointment
            var z = sampleGetting.AppointmentId; var appointment = _appointmentService.GetSingleById(int.Parse(z.ToString()));
            //từ samplegetting lấy ra sample
            var m = sampleGetting.SampleId; var sample = _sampleService.GetSampleById(int.Parse(m.ToString()));
            //từ appointment lấy ra patient
            var l = appointment.PatientId; var patient = _patientService.GetPatientById(int.Parse(l.ToString()));

            if (result == true)
            {
                var   tokens  = _tokenService.GetAll();
                int[] roleIds =
                {
                    (int)RoleEnum.Receptionist,
                    (int)RoleEnum.Cashier,
                    (int)RoleEnum.Manager
                };
                var data = new
                {
                    roleIds,
                    message = "Bệnh nhân: " + patient.FullName + " ĐT:" + patient.PhoneNumber + " Cần làm lại xét nghiệm: " + sample.SampleName,
                };
                SendNotificationUtils.SendNotification(data, tokens);

                /*
                 * var tokens = _appointmentService.GetAllTokens();
                 * foreach (var token in tokens)
                 * {
                 *  var data = new
                 *  {
                 *      to = token.TokenString,
                 *      data = new
                 *      {
                 *          message = "Bệnh nhân: " + patient.FullName + " ĐT:" + patient.PhoneNumber + " Cần làm lại xét nghiệm: " + sample.SampleName,
                 *      }
                 *  };
                 *  try
                 *  {
                 *      SendNotificationUtils.SendNotification(data);
                 *  }
                 *  catch (Exception ex)
                 *  {
                 *      //
                 *  }
                 * }/**/
            }
            return(Json(new
            {
                sucess = result
            }));
        }