public void OnGet()
        {
            HttpContext.Session.Remove("token");
            HttpContext.Session.Remove("role");

            HttpContext.Response.Redirect(CurentCultureUtils.GetCurrentCultureLink("Authentication/Login"));
        }
        public static void RedirectRequests(RewriteContext context)
        {
            var request = context.HttpContext.Request;
            var path    = request.Path.Value;

            var publicRoutes = new List <string>
            {
                "Index",
                "Authentication/Login",
                "Authentication/Register"
            };

            var isUserLoggedIn = AuthenticationUtils.IsUserLoggedIn(context.HttpContext);

            bool isRoutePublic = false;

            publicRoutes.ForEach(route =>
            {
                if (path.Contains(route))
                {
                    isRoutePublic = true;
                }
            });

            if (!isUserLoggedIn && !isRoutePublic)
            {
                context.HttpContext.Response.Redirect(CurentCultureUtils.GetCurrentCultureLink("Authentication/Login"));
            }
        }
Example #3
0
        private string GetLozalizedReasons(Appointment appointment)
        {
            string currentCulture = CurentCultureUtils.GetCurrentCulture();

            return(string.Join(", ",
                               appointment.AppointmentReasons.Where(appToReas => appToReas.Reason != null && appToReas.Reason.LangReasonDictionary != null)
                               .Select(appToReas => appToReas.Reason.LangReasonDictionary[currentCulture]).ToList()));
        }
Example #4
0
        public async Task <IActionResult> OnPostAsync(int selectedDoctorId, int[] selectedReasonsIds, DateTime pickedDate)
        {
            if (ModelState.IsValid)
            {
                if (pickedDate < DateTime.UtcNow)
                {
                    ModelState.AddModelError("Date", _cultureLocalizer.Text("Date must be from the future"));
                }
                else
                {
                    Appointment.Doctor = new Doctor()
                    {
                        UserId = selectedDoctorId
                    };
                    if (selectedReasonsIds.Length > 0)
                    {
                        Appointment.AppointmentReasons = new List <Appointment2Reason>();
                        Array.ForEach(selectedReasonsIds, (reasonId) =>
                        {
                            Appointment.AppointmentReasons.Add(new Appointment2Reason()
                            {
                                ReasonId = reasonId
                            });
                        });
                    }
                    var patientId = AuthenticationUtils.GetPatientId(HttpContext);
                    if (patientId.HasValue)
                    {
                        Appointment.Patient = new Patient()
                        {
                            UserId = patientId.Value
                        };
                    }


                    Appointment.AppointmentDate = pickedDate;
                    appointmentsSetResponse     = await _appointmentsService.SetAppointment(Appointment);

                    if (appointmentsSetResponse == AppointmentSetResponse.CORRECT)
                    {
                        HttpContext.Response.Redirect(CurentCultureUtils.GetCurrentCultureLink("Appointments/AppointmentMade"));

                        return(null);
                    }
                }
            }


            await OnGetAsync();

            SelectedDoctor = selectedDoctorId;
            SelectedResons = selectedReasonsIds;
            Date           = pickedDate;
            return(Page());
        }
Example #5
0
        public static void RedirectRequests(RewriteContext context)
        {
            var request = context.HttpContext.Request;
            var path    = request.Path.Value;

            var currentCulture = CurentCultureUtils.GetCurrentCulture();

            if (!CurentCultureUtils.SupportedCultures.Contains(path.Split("/")[1]))
            {
                context.HttpContext.Response.Redirect($"/{currentCulture}{ request.Path.Value }");
            }
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                var user = new User()
                {
                    Login    = LoginForm.Username,
                    Password = LoginForm.Password
                };
                var authenticationReponse = await authenticationService.Login(user);

                if (authenticationReponse.WasAuthenticationCorrect)
                {
                    HttpContext.Response.Redirect(CurentCultureUtils.GetCurrentCultureLink("Index"));

                    return(null);
                }
                Msg = _cultureLocalizer.Text("InvalidLogin");
            }

            return(Page());
        }
Example #7
0
        public async Task OnGetAsync()
        {
            if (AvailableDoctors == null)
            {
                var availableDoctors = await _appointmentsService.GetAllAvailableDoctors();

                AvailableDoctors = new SelectList(availableDoctors, nameof(Doctor.UserId), nameof(Doctor.FullName));
            }
            if (AvailableReasons == null)
            {
                var curentCulture = CurentCultureUtils.GetCurrentCulture();
                var reasonFromApi = await _appointmentsService.GetAllAppointmentReasons();

                var reasons = reasonFromApi.Select(reason =>
                                                   new
                {
                    Id    = reason.ReasonId,
                    Value = reason.LangReasonDictionary[curentCulture]
                })
                              .ToList();
                AvailableReasons = new SelectList(reasons, "Id", "Value");
            }
        }