예제 #1
0
 public static SearchGateway<Comment> GetCommentSearch()
 {
     if(CommentSearh == null)
     {
         CommentSearh = new SearchGateway<Comment>("api/Comment?ticketId=");
     }
     return CommentSearh;
 }
예제 #2
0
 public static SearchGateway<Project> GetProjectSearch()
 {
     if (ProjectSearch == null)
     {
         ProjectSearch = new SearchGateway<Project>("api/Project?departmentId=");
     }
     return ProjectSearch;
 }
예제 #3
0
        /// <summary>
        /// Uses the Command Pattern and executes the generate search result logic
        /// </summary>
        /// <returns> an outcome object containing the search results</returns>
        public Outcome Execute()
        {
            var result   = new Outcome();
            var response = new SearchResponseDTO();
            var messages = new List <string>();

            var gateway = new SearchGateway();

            // Gets user info
            var gatewayResponse = gateway.RetrieveUsers();

            if (!gatewayResponse.IsSuccessful)
            {
                response.IsSuccessful = false;
                response.Messages     = gatewayResponse.Messages;
                result.Result         = response;
            }

            // Filters the user search based on the distance of the coordinates
            var filteredResults = gatewayResponse.Results.Select(x => new
            {
                x.User,
                x.FirstName,
                x.LastName,
                x.SkillLevel,
                UserCoordinate = new GeoCoordinate(x.Latitude, x.Longitude),
            }).Where(x => ValidatedLocations.ContainsKey(x.UserCoordinate) && x.SkillLevel.Contains(Criteria.Skill) && x.User != Criteria.RequestedUser);

            // Map the filteredResults to a list of SearchResult objects
            var searchResults = filteredResults.Select(x => new SearchResult()
            {
                User      = x.User,
                FirstName = x.FirstName,
                LastName  = x.LastName,
                Skill     = x.SkillLevel,
                Distance  = Math.Round(ValidatedLocations[x.UserCoordinate], 2)
            }).AsEnumerable();

            searchResults = searchResults.OrderBy(x => x.Distance);

            // Changes the response data based if filtered data has any users in it
            if (!searchResults.Any())
            {
                response.IsSuccessful = false;
                messages.Add(SearchConstants.NO_NEARBY_USERS_ERROR);
                response.Messages = messages;
            }
            else
            {
                response.IsSuccessful = true;
                messages.Add(SearchConstants.USERS_FOUND_ERROR);
                response.Messages      = messages;
                response.SearchResults = searchResults.ToList();
            }

            result.Result = response;
            return(result);
        }
        public void ListofStockOut()
        {
            SearchGateway          StockOut       = new SearchGateway();
            List <SearchViewModel> listofStockOut = null;

            salseGridview.Rows.Clear();
            listofStockOut = StockOut.AllStockOut();
            if (listofStockOut != null)
            {
                salseGridview.ColumnCount      = 8;
                salseGridview.Columns[0].Name  = "SL";
                salseGridview.Columns[0].Width = 20;
                salseGridview.Columns[1].Name  = "Category";
                salseGridview.Columns[1].Width = 30;
                salseGridview.Columns[2].Name  = "Company";
                salseGridview.Columns[2].Width = 30;
                salseGridview.Columns[3].Name  = "Items Name";
                salseGridview.Columns[3].Width = 50;
                salseGridview.Columns[4].Name  = "Quantity";
                salseGridview.Columns[4].Width = 50;
                salseGridview.Columns[5].Name  = "Price";
                salseGridview.Columns[5].Width = 50;
                salseGridview.Columns[6].Name  = "Type of Stock Out";
                salseGridview.Columns[6].Width = 50;
                salseGridview.Columns[7].Name  = "Date";
                salseGridview.Columns[7].Width = 50;

                int rn = 0;
                foreach (SearchViewModel sales in listofStockOut)
                {
                    int inc = listofStockOut.Count;
                    if (inc > rn)
                    {
                        rn++;
                    }
                    salseGridview.Rows.Add(rn, sales.CatagoryName, sales.CompanyName, sales.ItemName, sales.Quantity, sales.Price, sales.Type, sales.Date);
                }
            }
        }
예제 #5
0
 public YellowstonePathology.YpiConnect.Contract.Search.SearchResultCollection GetClientRecentCases(YellowstonePathology.YpiConnect.Contract.Search.Search search)
 {
     SearchGateway gateway = new SearchGateway();
     return gateway.GetClientRecentCases(search);
 }
예제 #6
0
 public YellowstonePathology.YpiConnect.Contract.Search.SearchResultCollection GetClientCasesByPatientLastNameAndFirstName(YellowstonePathology.YpiConnect.Contract.Search.Search search)
 {
     SearchGateway gateway = new SearchGateway();
     return gateway.GetClientCasesByPatientLastNameAndFirstName(search);
 }
예제 #7
0
 public YellowstonePathology.Business.Client.Model.Client GetClient(int clientId)
 {
     SearchGateway gateway = new SearchGateway();
     return gateway.GetClient(clientId);
 }
예제 #8
0
 public void AcknowledgeDistributions(string reportDistributionLogIdStringList)
 {
     SearchGateway gateway = new SearchGateway();
     gateway.AcknowledgeDistributions(reportDistributionLogIdStringList);
 }
예제 #9
0
        /// <summary>
        /// Executes the strategy of searching nearby users based on an address
        /// </summary>
        /// <returns> The users with their username, skill, workout type, and distance that fits the search criteria</returns>
        public Outcome Execute()
        {
            var searchResponse = new SearchResponseDTO();
            var response       = new Outcome();

            // Validates the Criteria that the user has entered
            var criteriaValidator = new ValidateSearchNearbyCriteria()
            {
                SearchNearbyCriteria = Search
            };

            var validatedCriteria = (SearchResponseDTO)criteriaValidator.Execute().Result;

            // if validator fails, return the result
            if (!validatedCriteria.IsSuccessful)
            {
                response.Result = validatedCriteria;
                return(response);
            }

            // Validates the location that the user inputted
            var locationValidator = new WebAPILocationValidator()
            {
                RequestedLocation = Search.RequestedSearch
            };
            var validatedLocation = (WebAPIGeocode)locationValidator.Execute().Result;

            if (!validatedLocation.IsValid)
            {
                response.Result = Error(LocationConstants.ADDRESS_NOT_VALID_ERROR);
                return(response);
            }

            var gateway = new SearchGateway();

            // Retrieve all locations from database
            var locationResponseDTO = gateway.RetrieveLocations();

            if (!locationResponseDTO.IsSuccessful)
            {
                response.Result = Error(locationResponseDTO.Messages.First());
            }

            var locations = locationResponseDTO.LocationResults;

            if (!locations.Any())
            {
                response.Result = Error(LocationGatewayConstants.NO_LOCATION_FOUND_ERROR);
                return(response);
            }

            // Filtering the locations based on the distance
            var filterLocation = new FilterGeoCoordinates()
            {
                UserLocation   = new GeoCoordinate(validatedLocation.Latitude, validatedLocation.Longitude),
                GeoCoordinates = locations,
                Distance       = Search.Distance.Value,
            };
            var filteredGeocoordinates = (Dictionary <GeoCoordinate, double>)filterLocation.Execute().Result;

            if (!filteredGeocoordinates.Any())
            {
                response.Result = Error(SearchConstants.NO_NEARBY_USERS_ERROR);
                return(response);
            }

            // Generates the search results
            var filterSearch = new GenerateSearchResults()
            {
                Criteria           = Search,
                ValidatedLocations = filteredGeocoordinates
            };

            response.Result = (SearchResponseDTO)filterSearch.Execute().Result;

            return(response);
        }
예제 #10
0
        public Outcome Execute()
        {
            var result   = new Outcome();
            var response = new SearchResponseDTO();
            var messages = new List <string>();

            // Validates the Criteria that the user has entered
            var validator = new ValidateSearchUserCriteria()
            {
                SearchUserCriteria = SearchUserCriteria
            };

            var validatedCriteria = (SearchResponseDTO)validator.Execute().Result;

            // if validator fails, return the result
            if (!validatedCriteria.IsSuccessful)
            {
                result.Result = validatedCriteria;
                return(result);
            }

            // retrieve users
            var gatewayResponse = new SearchGateway().RetrieveUsers();

            if (!gatewayResponse.IsSuccessful)
            {
                response.IsSuccessful = false;
                response.Messages     = gatewayResponse.Messages;
                result.Result         = response;
                return(result);
            }

            // Gets the user info based on username
            var requestedBy = gatewayResponse.Results.Where(x => x.User == SearchUserCriteria.RequestedBy).FirstOrDefault();

            if (requestedBy == null)
            {
                response.IsSuccessful = false;
                messages.Add(SearchConstants.NO_REQUESTEDBY_ERROR);
                response.Messages = messages;
                result.Result     = response;
                return(result);
            }

            var requestedUser = gatewayResponse.Results.Where(x => x.User == SearchUserCriteria.RequestedUser).FirstOrDefault();

            if (requestedUser == null)
            {
                response.IsSuccessful = false;
                messages.Add(SearchConstants.NO_USER_ERROR);
                response.Messages = messages;
                result.Result     = response;
                return(result);
            }

            // Creates Geocoordinates based on the two users location and generates a search result
            var requestedByCoord   = new GeoCoordinate(requestedBy.Latitude, requestedBy.Longitude);
            var requestedUserCoord = new GeoCoordinate(requestedUser.Latitude, requestedUser.Longitude);

            var userResult = new SearchResult()
            {
                User      = requestedUser.User,
                FirstName = requestedUser.FirstName,
                LastName  = requestedUser.LastName,
                Skill     = requestedUser.SkillLevel,
                Distance  = Math.Round(((requestedUserCoord.GetDistanceTo(requestedByCoord)) / 1609.344), 2)
            };

            response.IsSuccessful  = true;
            response.SearchResults = new List <SearchResult>();
            response.SearchResults.Add(userResult);
            messages.Add(SearchConstants.USER_FOUND);
            response.Messages = messages;
            result.Result     = response;

            return(result);
        }
예제 #11
0
 public SearchManager()
 {
     searchGateway = new SearchGateway();
 }
예제 #12
0
        public YellowstonePathology.YpiConnect.Contract.Search.SearchResultCollection GetClientCasesNotAcknowledged(YellowstonePathology.YpiConnect.Contract.Search.Search search)
        {
            SearchGateway gateway = new SearchGateway();

            return(gateway.GetClientCasesNotAcknowledged(search));
        }
예제 #13
0
        public YellowstonePathology.YpiConnect.Contract.Search.SearchResultCollection GetClientCasesByPatientLastNameAndFirstName(YellowstonePathology.YpiConnect.Contract.Search.Search search)
        {
            SearchGateway gateway = new SearchGateway();

            return(gateway.GetClientCasesByPatientLastNameAndFirstName(search));
        }
예제 #14
0
        public void AcknowledgeDistributions(string reportDistributionLogIdStringList)
        {
            SearchGateway gateway = new SearchGateway();

            gateway.AcknowledgeDistributions(reportDistributionLogIdStringList);
        }
예제 #15
0
        public YellowstonePathology.Business.Client.Model.Client GetClient(int clientId)
        {
            SearchGateway gateway = new SearchGateway();

            return(gateway.GetClient(clientId));
        }