/// <summary>
        /// Gets the facility role list custom.
        /// </summary>
        /// <param name="corporateId">The corporate identifier.</param>
        /// <param name="facilityId">The facility identifier.</param>
        /// <param name="roleId">The role identifier.</param>
        /// <returns></returns>
        public List <FacilityRoleCustomModel> GetFacilityRoleListCustom(int corporateId, int facilityId, int roleId)
        {
            var list = new List <FacilityRoleCustomModel>();

            using (var rep = UnitOfWork.FacilityRoleRepository)
            {
                var facilityRoleList = corporateId > 0 ?
                                       (facilityId == 0
                    ? rep.Where(fr => !fr.IsDeleted && fr.IsActive && fr.CorporateId == corporateId).ToList()
                    : rep.Where(fr => !fr.IsDeleted && fr.IsActive && fr.CorporateId == corporateId &&
                                fr.FacilityId == facilityId).ToList())
                                      :
                                       rep.Where(fr => !fr.IsDeleted && fr.IsActive).ToList();

                if (roleId > 0)
                {
                    facilityRoleList = facilityRoleList.Where(r => r.RoleId == roleId).ToList();
                }


                using (var facBal = new FacilityBal())
                {
                    using (var corpBal = new CorporateBal())
                    {
                        using (var roleBal = new RoleBal())
                        {
                            list.AddRange(facilityRoleList.Select(item => new FacilityRoleCustomModel
                            {
                                FacilityRoleId = item.FacilityRoleId,
                                FacilityId     = item.FacilityId,
                                RoleId         = item.RoleId,
                                CorporateId    = item.CorporateId,
                                CreatedBy      = item.CreatedBy,
                                CreatedDate    = item.CreatedDate,
                                ModifiedBy     = item.ModifiedBy,
                                ModifiedDate   = item.ModifiedDate,
                                IsDeleted      = item.IsDeleted,
                                DeletedBy      = item.DeletedBy,
                                DeletedDate    = item.DeletedDate,
                                IsActive       = item.IsActive,
                                FacilityName   = facBal.GetFacilityNameById(item.FacilityId),
                                CorporateName  = corpBal.GetCorporateNameById(item.CorporateId),
                                RoleName       = roleBal.GetRoleNameById(item.RoleId)
                            }));
                        }
                    }
                }
                list = list.GroupBy(x => new { x.RoleName, x.FacilityId }).Select(x => x.FirstOrDefault()).ToList();
                return(list.OrderBy(x => x.RoleName).ToList());
            }
        }
        public List <FacilityRoleCustomModel> GetUserTypeRoleDropDownInTaskPlan(int corporateId, int facilityId, bool carePlanAccessible)
        {
            var list = new List <FacilityRoleCustomModel>();

            using (var rep = UnitOfWork.FacilityRoleRepository)
            {
                var facilityRoleList = rep.Where(x => x.IsDeleted != true && x.CorporateId == corporateId && x.FacilityId == facilityId && x.CarePlanAccessible == carePlanAccessible).ToList();
                using (var roleBal = new RoleBal())
                {
                    list.AddRange(facilityRoleList.Select(item => new FacilityRoleCustomModel
                    {
                        RoleId   = item.RoleId,
                        RoleName = roleBal.GetRoleNameById(item.RoleId)
                    }));
                }
                return(list);
            }
        }