예제 #1
0
        private void SetupClaims(string username, LoginAs loginAs)
        {
            var cp = GetClaimsPrincipalForUser(username, loginAs);

            StoreClaimsPrincipalInSessionAuthentication(cp);
            //StoreAuthenticatedLoginInSession(user);
        }
예제 #2
0
        public IHttpActionResult LoginAsUser(string username,
                                             string password, LoginAs loginAs)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(username))
                {
                    throw new ArgumentException("Value cannot be null or whitespace.", nameof(username));
                }

                if (string.IsNullOrWhiteSpace(password))
                {
                    throw new ArgumentException("Value cannot be null or whitespace.", nameof(password));
                }

                if (!Authenticate(password))
                {
                    return(Unauthorized());
                }

                SetupClaims(username, loginAs);

                return(this.Accepted());
            }
            catch (Exception ex)
            {
                _log.Error(ex);
                return(InternalServerError());
            }
        }
예제 #3
0
        public async Task <IActionResult> Create()
        {
            ViewBag.LoginAs = LoginAs.ToString();

            if (LoginAs == Shared.Enums.LoginAs.ADMIN)
            {
                ViewBag.Hospitals = await GetHospitalsSelectListAsync();
            }

            var model = new ClinicViewModel {
                listCities = _commonUtils.PopulateCitiesList()
            };

            return(View(model));
        }
        public async Task <IActionResult> Index(int polyclinicId, int doctorId, string userMessage = "")
        {
            if (_workContext.WorkingArea.ServiceSupplyIds != null && _workContext.WorkingArea.ServiceSupplyIds.Any())
            {
                if (!_workContext.WorkingArea.ServiceSupplyIds.Contains(doctorId))
                {
                    throw new AccessDeniedException();
                }
            }

            var cats = _commonUtils.PopulateExpertiseCategoriesList();

            var doctor = await _dbContext.ServiceSupplies.FindAsync(doctorId);

            if (doctor == null)
            {
                throw new EntityNotFoundException();
            }

            ViewBag.Lang = Lng;

            TempData["area"] = LoginAs.ToString();

            if (!string.IsNullOrEmpty(userMessage))
            {
                TempData.Put("message", new MVCResultModel {
                    status = MVCResultStatus.success, message = userMessage
                });
            }

            return(View(new SpecialityViewModel
            {
                PolyclinicId = polyclinicId,
                doctorId = doctorId,
                Categories = cats,
                Expertises = _commonUtils.PopulateExpertisesList(int.Parse(cats.FirstOrDefault().Value)),
                DoctorName = doctor.Person.FullName
            }));
        }
예제 #5
0
        public async Task <ViewResult> Index(string sortOrder, string currentFilter, string searchString, int?page, int?hospitalId = null)
        {
            ViewBag.Lang = Lng;

            ViewBag.LoginAs = LoginAs.ToString();

            if (LoginAs == Shared.Enums.LoginAs.HOSPITALMANAGER)
            {
                hospitalId = _hospitalService.GetCurrentHospital()?.Id;
            }
            else
            {
                ViewBag.Hospitals = await GetHospitalsSelectListAsync();
            }

            ViewBag.HospitalId = hospitalId;

            ViewBag.CurrentSort = sortOrder;

            ViewBag.NameSortParam = sortOrder == "Name" ? "name_desc" : "Name";

            if (!string.IsNullOrEmpty(searchString))
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;

            var queryModel = new QueryModel <Clinic>
            {
                SearchString = searchString,
                SearchStringFilterProperties = new List <Expression <Func <Clinic, string> > >
                {
                    x => x.Name,
                    y => y.Name_Ar,
                    z => z.Name_Ku
                },
                OrderBy       = x => Lng == Lang.KU ? x.Name_Ku : x.Name_Ar,
                IsOrderByDesc = sortOrder == "name_desc" ? true : false
            };

            if (hospitalId != null)
            {
                queryModel.Predicates.Add(x => x.HospitalId == hospitalId);
            }

            var query = _clinicService.DynamicQuery(queryModel);

            var clinics = query.Select(x => new List
            {
                Id          = x.Id,
                Description = Lng == Lang.AR ? x.Description_Ar : Lng == Lang.KU ? x.Description_Ku : x.Description,
                Name        = Lng == Lang.AR ? x.Name_Ar : Lng == Lang.KU ? x.Name_Ku : x.Name,
                Hospital    = x.HospitalId != null ? Lng == Lang.AR ? x.Hospital.Name_Ar : Lng == Lang.KU ? x.Hospital.Name_Ku : x.Hospital.Name : "",
                Managers    = x.ClinicUsers.Where(c => c.IsManager).Select(m => m.Person.FirstName + " " + m.Person.SecondName + " " + m.Person.ThirdName).ToList()
            });

            var pageSize = 10;

            var pageNumber = (page ?? 1);

            var result = clinics.ToPagedList(pageNumber, pageSize);

            return(View(result));
        }
예제 #6
0
        public async Task <IActionResult> Edit(int?id)
        {
            ViewBag.LoginAs = LoginAs.ToString();

            if (LoginAs == Shared.Enums.LoginAs.CLINICMANAGER)
            {
                id = _clinicService.GetCurrentClinic()?.Id;
            }
            else
            {
                if (LoginAs == Shared.Enums.LoginAs.ADMIN)
                {
                    ViewBag.Hospitals = await GetHospitalsSelectListAsync();
                }
            }

            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            var clinic = _clinicService.GetClinicById((int)id);

            if (clinic == null)
            {
                throw new EntityNotFoundException();
            }

            var phonesCount = clinic.PhoneNumbers?.Count ?? 0;

            var phonesArray = clinic.PhoneNumbers != null?clinic.PhoneNumbers.ToArray() : new ShiftCenterPhoneModel[3];

            var model = new ClinicViewModel
            {
                Id                     = clinic.Id,
                Name                   = clinic.Name,
                Name_Ku                = clinic.Name_Ku,
                Name_Ar                = clinic.Name_Ar,
                Description            = clinic.Description,
                Description_Ku         = clinic.Description_Ku,
                Description_Ar         = clinic.Description_Ar,
                CityId                 = clinic.IsIndependent == true ? (int)clinic.CityId : clinic.Hospital.CityId,
                listCities             = _commonUtils.PopulateCitiesList(),
                Address                = clinic.IsIndependent == true ? clinic.Address : clinic.Hospital.Address,
                Address_Ku             = clinic.IsIndependent == true ? clinic.Address_Ku : clinic.Hospital.Address_Ku,
                Address_Ar             = clinic.IsIndependent == true ? clinic.Address_Ar : clinic.Hospital.Address_Ar,
                Phone1                 = phonesCount >= 1 ? phonesArray[0].PhoneNumber : null,
                Phone2                 = phonesCount >= 2 ? phonesArray[1].PhoneNumber : null,
                Phone3                 = phonesCount >= 3 ? phonesArray[2].PhoneNumber : null,
                Phone1IsForReserve     = phonesCount >= 1 && phonesArray[0].IsForReserve,
                Phone2IsForReserve     = phonesCount >= 2 && phonesArray[1].IsForReserve,
                Phone3IsForReserve     = phonesCount >= 3 && phonesArray[2].IsForReserve,
                GoogleMap_lat          = clinic.Location != null && clinic.Location?.Y > 0 ? clinic.Location?.Y.ToString() : "",
                GoogleMap_lng          = clinic.Location != null && clinic.Location?.X > 0 ? clinic.Location?.X.ToString() : "",
                FinalBookMessage       = clinic.FinalBookMessage,
                FinalBookMessage_Ku    = clinic.FinalBookMessage_Ku,
                FinalBookMessage_Ar    = clinic.FinalBookMessage_Ar,
                FinalBookSMSMessage    = clinic.FinalBookSMSMessage,
                FinalBookSMSMessage_Ku = clinic.FinalBookSMSMessage_Ku,
                FinalBookSMSMessage_Ar = clinic.FinalBookSMSMessage_Ar,
                Notification           = clinic.Notification,
                Notification_Ku        = clinic.Notification_Ku,
                Notification_Ar        = clinic.Notification_Ar,
                IsGovernmental         = clinic.IsGovernmental,
                IsHostelry             = clinic.IsHostelry,
                Type                   = clinic.Type,
                HospitalId             = clinic.HospitalId,
                Logo                   = clinic.Logo
            };

            if (!string.IsNullOrEmpty(model.Logo))
            {
                ViewBag.LogoPreview = "<img src=" + model.Logo + " alt=\"Logo\">";
            }

            return(View("Create", model));
        }
예제 #7
0
        protected internal ClaimsPrincipal GetClaimsPrincipalForUser(string username, LoginAs loginAs)
        {
            var claims = loginAs == LoginAs.SystemAdmin ? GetClaimsForUserAsSystemAdmin(username) : GetClaimsForUser(username);
            var id     = new ClaimsIdentity(new GenericIdentity(username), claims, "Forms", string.Empty, string.Empty);

            return(new ClaimsPrincipal(id));
        }
예제 #8
0
 /// <summary>
 /// Search and login as the edited user.
 /// </summary>
 public void SearchAndLoginAsTheEditedUser()
 {
     UserSearch.SendKeys(uName);
     LoginAs.Click();
 }