Example #1
0
        public EmployerSearchDTO SearchBusinesses(EmployerSearchDTO searchData)
        {
            searchData.SearchResults = null;
            var email = HttpContext.Current.User.Identity.Name;

            if (searchData.SearchType == EmployerSearchTypeDTO.Business_Location_Name)
            {
                //Get any matching business locations
                var busLocs = (from busLoc in db.BusinessLocations
                               where busLoc.Name.ToLower().Contains(searchData.Name.ToLower())
                               select new BusinessLocationSummaryDTO {
                    BusinessId = busLoc.Business.Id, BusinessName = busLoc.Business.Name, Id = busLoc.Id, Name = busLoc.Name, HasInternalLocations = busLoc.Business.HasMultiInternalLocations
                }).ToList();
                //Also match any business names
                var businesses = (from bus in db.Businesses
                                  join busLoc in db.BusinessLocations on bus.Id equals busLoc.Business.Id
                                  where bus.Name.ToLower().Contains(searchData.Name.ToLower())
                                  select new BusinessLocationSummaryDTO {
                    BusinessId = busLoc.Business.Id, BusinessName = busLoc.Business.Name, Id = busLoc.Id, Name = busLoc.Name, HasInternalLocations = busLoc.Business.HasMultiInternalLocations
                }).ToList();

                businesses.AddRange(busLocs);

                searchData.SearchResults = businesses.Distinct().ToList();
            }
            else if (searchData.SearchType == EmployerSearchTypeDTO.Manager_Name)
            {
                searchData.SearchResults = (from busLoc in db.BusinessLocations
                                            join mgr in db.Employees on busLoc.Id equals mgr.BusinessLocation.Id
                                            where mgr.ManagerBusinessLocations.Contains(busLoc) &&
                                            (
                                                (mgr.FirstName.ToLower().Contains(searchData.Name.ToLower()) || mgr.LastName.ToLower().Contains(searchData.Name.ToLower())) ||      //TODO - doe we need to join into User Profile table to search names? what is source of truth
                                                (searchData.Name.ToLower().Equals(mgr.FirstName.ToLower() + " " + mgr.LastName.ToLower()))
                                            )
                                            select new BusinessLocationSummaryDTO {
                    BusinessId = busLoc.Business.Id, BusinessName = busLoc.Business.Name, Id = busLoc.Id, Name = busLoc.Name, HasInternalLocations = busLoc.Business.HasMultiInternalLocations
                }).ToList();
            }

            //Now get summary of all Employer requests from the current user
            searchData.SearchRequests = (from er in db.EmployerRequests
                                         where er.UserProfile.Email == email
                                         select new EmployerRequestDTO {
                Id = er.Id, Status = (RequestStatusDTO)er.Status, Business_Id = er.BusinessLocation.Business.Id, BusinessLocation_Id = er.BusinessLocation.Id, CreatedDate = er.CreatedDate
            }).ToList();

            searchData.CurrentBusinesses = (from busLoc in db.BusinessLocations
                                            join emp in db.Employees on busLoc.Id equals emp.BusinessLocation.Id
                                            join usr in db.UserProfiles on emp.UserProfile.Id equals usr.Id
                                            where usr.Email == email
                                            select busLoc.Id).ToList();
            return(searchData);
        }
Example #2
0
        public ActionResult Search(EmployerSearchDTO searchData)
        {
            if (ModelState.IsValid)
            {
                using (HttpClientWrapper httpClient = new HttpClientWrapper(Session))
                {
                    HttpResponseMessage response = httpClient.PostAsJsonAsync("api/EmployerAPI/SearchBusinesses", searchData).Result;
                    searchData = JsonConvert.DeserializeObject <EmployerSearchDTO>(response.Content.ReadAsStringAsync().Result);
                }
            }

            return(PartialView(searchData));
        }
Example #3
0
 public ActionResult GetSearchResult(Guid id, string Name, string searchType)
 {
     if (searchType == "BusinessSearch")
     {
         EmployerSearchDTO searchData = new EmployerSearchDTO()
         {
             id         = id,
             Name       = Name,
             SearchType = EmployerSearchTypeDTO.Business_Location_Name
         };
         return(RedirectToAction("BusinessProfileDetails", "Roster", searchData));
     }
     else
     {
         return(RedirectToAction("ExternalUserProfile", "Roster", new { externalUserID = id }));
     }
 }