Exemple #1
0
        public async Task <IEnumerable <dynamic> > GetAllPositionsStaffData(string sourcemarket, string criteria)
        {
            sourcemarket = "ALL";   //obsolete params for now 20180923

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

            var rawdata = await _positionAssignRepo.GetPositionAssignData();

            var rawlist = rawdata.ToList();


            var groupedBySeason = rawlist.GroupBy(x => x.Season)
                                  .Select(x => new
            {
                Season  = x.Key,
                HeadOfs = x.ToList().GroupBy(y => y.HeadOf).Select(y =>
                                                                   new
                {
                    HeadOf       = y.Key,
                    Destinations = y.ToList().GroupBy(m => m.Destination)
                                   .Select(m =>
                                           new
                    {
                        Destination = m.Key,
                        Positions   = m.ToList()
                                      .Select(n =>
                                              new
                        {
                            id                = n.Id,
                            firstName         = n.FirstName,
                            firstNameLastName = n.FirstNameLastName,
                            lastName          = n.LastName,
                            staffID           = n.StaffID,
                            mplID             = n.MPLID,
                            mplIDVersion      = n.MPLIDVersion,
                            profile           = n.Profile,
                            languages         = n.Languages,
                            highseason        = n.HighSeason,
                            mPLPositionType   = n.MPLPositionType,
                            mplDlRequired     = n.MPL_DL_Required,
                            nat               = n.Nat,
                            headof            = n.HeadOf,
                            concepthotel      = n.ConceptHotel,
                            jobTitle          = n.JobTitle,
                            sourceMarket      = n.SourceMarket,
                            startDate         = n.StartDate,
                            email             = n.Email,
                            endDate           = n.EndDate,
                            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);
        }
        public async Task <IEnumerable <dynamic> > GetAllPositionsAssignData(string sourcemarket, string jobfamily, string positiontype, string criteria)
        {
            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(',');


            //int arrlength = Sourcemarkets.Length;


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

                var rawlist = rawdata.ToList();

                if (!string.IsNullOrEmpty(criteria))
                {
                    rawlist = FilterByCriteria(criteria,
                                               rawlist).ToList();
                }
                // HeadOf -> Destination -> Jobtitle
                var groupedBySeason = rawlist.GroupBy(x => x.HeadOf)
                                      .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,
                                PositionAssignId  = n.PositionAssignId,
                                firstName         = n.FirstName,
                                firstNameLastName = n.FirstNameLastName,
                                lastName          = n.LastName,
                                staffID           = n.StaffID,
                                mplID             = n.MPLID,
                                season            = n.Season,
                                mplIDVersion      = n.MPLIDVersion,
                                profile           = n.Profile,
                                education         = n.Education,
                                languages         = n.Languages,
                                highseason        = n.HighSeason,
                                mplPositionType   = n.MPLPositionType,
                                mplDlRequired     = n.MPL_DL_Required,
                                nat          = n.Nat,
                                headof       = n.HeadOf,
                                concepthotel = n.ConceptHotel,
                                jobTitle     = n.JobTitle,
                                accept       = n.Accept,
                                acting       = n.Acting,


                                sourceMarket      = n.SourceMarket,
                                mplSourceMarket   = n.MPLSourceMarket,
                                positionStartDate = n.PositionStartDate,
                                startDate         = n.StartDate,
                                endDate           = n.EndDate,
                                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);
            }

            catch (Exception e)
            {
                Console.Write(e);
                throw;
            }
        }