Пример #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"));
        }
Пример #2
0
        public async Task <IActionResult> Patients()
        {
            var role = await _controllerRepository.InitRole(User);

            ViewBag.Role = role;
            //if (role == RoleTypes.None)
            //    return RedirectToAction("Login", "User");
            //if (role == RoleTypes.Patient)
            //    return RedirectToAction("Index", "Home");
            var userResponse = JsonConvert.DeserializeObject <MksResponse>(
                await RequestExecutor.ExecuteRequestAsync(
                    MicroservicesEnum.User, RequestUrl.GetPatients));
            var users = new List <PatientModel>();

            if (!userResponse.Success)
            {
                throw new Exception(userResponse.Data);
            }
            else
            {
                users.AddRange(JsonConvert.DeserializeObject <IEnumerable <PatientModel> >(userResponse.Data));
            }
            return(View(users));
        }