public async Task <IEnumerable <dynamic> > GetAllUnAssignedPositions(string sourcemarket, string jobfamily, string positiontype, string criteria)


        {
            //sourcemarket = "ALL";   //obsolete params for now 20180923


            if (sourcemarket == "null")
            {
                sourcemarket = "ALL";
            }
            if (jobfamily == "null")
            {
                jobfamily = "ALL";
            }
            if (positiontype == "null")
            {
                positiontype = "ALL";
            }

            string[] SourceMarkets = sourcemarket.Split(',');
            string[] JobFamilys    = jobfamily.Split(',');
            string[] PositionTypes = positiontype.Split(',');

            var rawdata = await _positionAssignRepo.GetUnAssignedPositions(SourceMarkets, sourcemarket, JobFamilys, jobfamily, PositionTypes, positiontype);

            var rawlist = rawdata.ToList();

            if (!string.IsNullOrEmpty(criteria))
            {
                rawlist = FilterByCriteriaVacant(criteria,
                                                 rawlist).ToList();
            }

            var groupedBySeason = rawlist.GroupBy(x => x.SDD_DM)
                                  .Select(x => new
            {
                Season  = x.Key,
                HeadOfs = x.ToList().GroupBy(y => y.Destination).Select(y =>
                                                                        new
                {
                    HeadOf       = y.Key,
                    Destinations = y.ToList().GroupBy(m => m.JobTitle)
                                   .Select(m =>
                                           new
                    {
                        Destination = m.Key,
                        Positions   = m.ToList()
                                      .Select(n =>
                                              new
                        {
                            id                = n.Id,
                            firstName         = n.FirstName,
                            firstNameLastName = n.FirstNameLastName,
                            lastName          = n.LastName,
                            lastName2         = n.LastName2,
                            staffID           = n.StaffID,
                            mplID             = n.MPLID,
                            mplIDVersion      = n.MPLIDVersion,
                            profile           = n.Profile,
                            languages         = n.Languages,
                            highseason        = n.HighSeason,
                            mPLPositionType   = n.MPLPositionType,
                            mplSourceMarket   = n.MPLSourceMarket,
                            mplDlRequired     = n.MPL_DL_Required,
                            nat               = n.Nat,
                            season            = n.Season,
                            headof            = n.HeadOf,
                            concepthotel      = n.ConceptHotel,
                            jobTitle          = n.JobTitle,
                            sourceMarket      = n.SourceMarket,
                            positionStartDate = n.PositionStartDate,
                            email             = n.Email,
                            positionEndDate   = n.PositionEndDate,
                            driver            = n.Driver,
                            drivingYear       = n.DrivingYear,
                            status            = n.Status,
                            positionType      = n.PositionType
                        }).ToList().OrderBy(o => o.lastName)
                    }).OrderBy(j => j.Destination)
                }
                                                                        ).OrderBy(d => d.HeadOf)
            }).OrderBy(h => h.Season);

            return(groupedBySeason);
        }