Esempio n. 1
0
        public async Task <IActionResult> Index()
        {
            var role = await _controllerRepository.InitRole(User);

            if (role == RoleTypes.Patient)
            {
                var userId          = _controllerRepository.GetUserId(User);
                var testingResponse = JsonConvert.DeserializeObject <MksResponse>(
                    await RequestExecutor.ExecuteRequestAsync(
                        MicroservicesEnum.Testing, RequestUrl.CheckNotViewedAnswer, new Parameter[] {
                    new Parameter("userId", userId, ParameterType.RequestBody)
                }));
                if (!testingResponse.Success)
                {
                    throw new Exception(testingResponse.Data);
                }
                var result = JsonConvert.DeserializeObject <bool>(testingResponse.Data);
                if (result)
                {
                    return(RedirectToAction("AlreadyHasCompleteTest", "Test"));
                }
                return(View());
            }
            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 2
0
        public async Task <IActionResult> DoctorRoom(CreatorModel model)
        {
            if (model.IsDoctor)
            {
                var doctorId = _controllerRepository.GetUserId(User);
                ViewBag.DoctorId = doctorId;
                var userResponse = JsonConvert.DeserializeObject <MksResponse>(
                    await RequestExecutor.ExecuteRequestAsync(
                        MicroservicesEnum.User, RequestUrl.GetUserByPatientId, new Parameter[] {
                    new Parameter("patientId", model.UserId, ParameterType.GetOrPost)
                }));
                if (!userResponse.Success)
                {
                    throw new Exception(userResponse.Data);
                }
                var user2 = JsonConvert.DeserializeObject <Users>(userResponse.Data);
                ViewBag.PatientUserId = user2.UserId;
                ViewBag.Role          = "creator";
            }
            else
            {
                ViewBag.DoctorId = model.UserId;
                var patientUserId = _controllerRepository.GetUserId(User);
                ViewBag.PatientUserId = patientUserId;
                ViewBag.Role          = "user";
            }
            var userResponse2 = JsonConvert.DeserializeObject <MksResponse>(
                await RequestExecutor.ExecuteRequestAsync(
                    MicroservicesEnum.User, RequestUrl.GetUserById, new Parameter[] {
                new Parameter("userId", ViewBag.DoctorId, ParameterType.GetOrPost)
            }));

            if (!userResponse2.Success)
            {
                throw new Exception(userResponse2.Data);
            }
            var user          = JsonConvert.DeserializeObject <Users>(userResponse2.Data);
            var userResponse3 = JsonConvert.DeserializeObject <MksResponse>(
                await RequestExecutor.ExecuteRequestAsync(
                    MicroservicesEnum.User, RequestUrl.GetPatientByUserId, new Parameter[] {
                new Parameter("userId", ViewBag.PatientUserId, ParameterType.GetOrPost)
            }));

            if (!userResponse3.Success)
            {
                throw new Exception(userResponse3.Data);
            }
            var patient = JsonConvert.DeserializeObject <PatientModel>(userResponse3.Data);

            ViewBag.PatientName = patient.Fio;
            ViewBag.DoctorName  = user.Fio;
            return(View());
        }
Esempio n. 3
0
        public async Task <IActionResult> CreateCard()
        {
            var userId          = _controllerRepository.GetUserId(User);
            var testingResponse = JsonConvert.DeserializeObject <MksResponse>(
                await RequestExecutor.ExecuteRequestAsync(
                    MicroservicesEnum.Medical, RequestUrl.CreateOutpatientCard, new Parameter[] {
                new Parameter("userId", userId, ParameterType.RequestBody)
            }));

            if (!testingResponse.Success)
            {
                throw new Exception(testingResponse.Data);
            }
            return(Json(new { Success = true, Message = "ok" }));
        }