示例#1
0
        public async Task <dynamic> Get(string companyName)
        {
            if (CheckClientSecret())
            {
                try
                {
                    using (HttpClient client = new HttpClient())
                        using (Entities db = new Entities())
                        {
                            CompanyRoot.Company company = await CompanySearch.GetCompany(client, companyName, db);

                            ContactRoot.Contact contact = await ContactSearch.GetContacts(client, company.Results.FirstOrDefault());

                            return(ContactSearch.CreateContactDTOs(contact));
                        }
                }
                catch (Exception ex)
                {
                    return(ex);
                }
            }
            else
            {
                return(new HttpResponseMessage(System.Net.HttpStatusCode.Forbidden));
            }
        }
示例#2
0
        public List <Contact> Search(ContactSearch search)
        {
            try
            {
                if (search != null)
                {
                    if (search.Id > 0)
                    {
                        return(db.Contacts.Where(x => x.Id == search.Id).ToList());
                    }

                    return(db.Contacts.Where(p =>
                                             p.FirstName.ToLower().Contains(search.FirstName) &&
                                             p.LastName.ToLower().Contains(search.LastName) &&
                                             p.Address.ToLower().Contains(search.Address) &&
                                             p.PhoneNum.ToLower().Contains(search.PhoneNum))
                           .ToList());
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.ToString());
            }
            return(null);
        }
        public PagedResponse <ContactDto> Execute(ContactSearch search)
        {
            var query = _context.Contact.AsQueryable();

            if (!string.IsNullOrEmpty(search.Address) || !string.IsNullOrWhiteSpace(search.Address))
            {
                query = query.Where(x => x.Address.ToLower().Contains(search.Address.ToLower()));
            }

            var skipCount = search.PerPage * (search.Page - 1);

            var response = new PagedResponse <ContactDto>
            {
                CurrentPage  = search.Page,
                ItemsPerPage = search.PerPage,
                TotalCount   = query.Count(),
                Items        = query.Skip(skipCount).Take(search.PerPage).Select(x => new ContactDto
                {
                    Id      = x.Id,
                    Address = x.Address
                }).ToList()
            };

            return(response);
        }
示例#4
0
 public List <Contact> SearchContact(ContactSearch contact)
 {
     try
     {
         return(_blContact.Search(contact));
     }
     catch (Exception e)
     {
         throw new Exception("Exception: " + e.Message);
     }
 }
示例#5
0
        public IHttpActionResult GetList(ContactSearch search)
        {
            AuthDetails authdet = LoginUserDetails();
            var         filters = new List <MySqlParameter>
            {
                datatableService.CreateSqlParameter("@pUserId", authdet.UserId, MySqlDbType.Int32)
            };
            var result = service.GetList(search, filters);

            return(Ok(result));
        }
示例#6
0
        public GetContactsResponse GetContacts([FromBody] ContactSearch search)
        {
            var searchResults = _contacts.Where(c => c.Forename.ToLower().Contains(search.SearchTerm.ToLower()) ||
                                                c.Surname.ToLower().Contains(search.SearchTerm.ToLower())).ToList();

            return(new GetContactsResponse
            {
                Results = searchResults,
                TotalResultCount = searchResults.Count(),
                ResultsPerPage = 10
            });
        }
示例#7
0
        public async Task <object> Search(Guid userId, ContactSearch search)
        {
            var client      = new SearchServiceClient(_options.ServiceName, new SearchCredentials(_options.AdminApiKey));
            var indexClient = client.Indexes.GetClient(_options.IndexName);
            var result      = await indexClient.Documents.SearchAsync($"(userid:{userId.ToString()}) AND ({search.Phrase})",
                                                                      new SearchParameters()
            {
                QueryType    = QueryType.Full,
                Select       = search.SelectFields,
                SearchFields = search.SearchFields
            });

            return(result.Results);
        }
示例#8
0
        public IList<Contact> FindContacts(ContactSearch searchType, string searchValue)
        {
            try {
                if (searchType == ContactSearch.Name)
                    return _contactRepository.FindContactsByContactName(searchValue);

                return searchType == ContactSearch.MobilePhone
                           ? _contactRepository.FindContactsByMobilePhone(searchValue)
                           : new List<Contact>();
            } catch (Exception ex) {
                LoggingUtility.LogException(ex);
                throw;
            }
        }
示例#9
0
 public DataTable <ContactDatatable> GetList(ContactSearch search, List <MySqlParameter> filters)
 {
     try
     {
         using (var ctx = new AppDb())
         {
             var result = datatableService.GetDataTableResult <ContactDatatable>("contact_list_sp", search, filters);
             return(result);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#10
0
        public string Search([FromBody] ContactSearch info)
        {
            var query = (from cc in _context.Contact
                         join ca in _context.Account on cc.Accountid equals ca.Accountid
                         where (cc.Name.Contains(info.Name) || cc.Name.Equals("")) &&
                         (cc.Ownerid.Contains(info.Ownerid) || cc.Ownerid.Equals("")) &&
                         (cc.Phone.Contains(info.Phone) || cc.Phone.Equals(""))
                         select cc
                         )
                        .Include(a => a.Account)
                        .ToList <Contact>();

            return(JsonConvert.SerializeObject(query, Formatting.Indented, new JsonSerializerSettings {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            }));
        }
        /// <summary>
        /// Return a list of the top 100 unique places clustered by a given placetype for set of tags or machine tags.
        /// </summary>
        /// <param name="placeType">The ID for a specific place type to cluster photos by. </param>
        /// <param name="woeId">A Where on Earth identifier to use to filter photo clusters. </param>
        /// <param name="placeId">A Flickr Places identifier to use to filter photo clusters. </param>
        /// <param name="threshold">The minimum number of photos that a place type must have to be included.
        /// If the number of photos is lowered then the parent place type for that place will be used.</param>
        /// <param name="contactType">The type of contacts to return places for. Either all, or friends and family only.</param>
        /// <param name="minUploadDate">Minimum upload date.</param>
        /// <param name="maxUploadDate">Maximum upload date.</param>
        /// <param name="minTakenDate">Minimum taken date.</param>
        /// <param name="maxTakenDate">Maximum taken date.</param>
        /// <returns></returns>
        public PlaceCollection PlacesPlacesForContacts(PlaceType placeType, string woeId, string placeId, int threshold,
                                                       ContactSearch contactType, DateTime minUploadDate,
                                                       DateTime maxUploadDate, DateTime minTakenDate,
                                                       DateTime maxTakenDate)
        {
            CheckRequiresAuthentication();

            var parameters = new Dictionary <string, string>();

            parameters.Add("method", "flickr.places.placesForContacts");

            parameters.Add("place_type_id", placeType.ToString("D"));
            if (!string.IsNullOrEmpty(woeId))
            {
                parameters.Add("woe_id", woeId);
            }
            if (!string.IsNullOrEmpty(placeId))
            {
                parameters.Add("place_id", placeId);
            }
            if (threshold > 0)
            {
                parameters.Add("threshold", threshold.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            if (contactType != ContactSearch.None)
            {
                parameters.Add("contacts", (contactType == ContactSearch.AllContacts ? "all" : "ff"));
            }
            if (minUploadDate != DateTime.MinValue)
            {
                parameters.Add("min_upload_date", UtilityMethods.DateToUnixTimestamp(minUploadDate));
            }
            if (maxUploadDate != DateTime.MinValue)
            {
                parameters.Add("max_upload_date", UtilityMethods.DateToUnixTimestamp(maxUploadDate));
            }
            if (minTakenDate != DateTime.MinValue)
            {
                parameters.Add("min_taken_date", UtilityMethods.DateToMySql(minTakenDate));
            }
            if (maxTakenDate != DateTime.MinValue)
            {
                parameters.Add("max_taken_date", UtilityMethods.DateToMySql(maxTakenDate));
            }

            return(GetResponseCache <PlaceCollection>(parameters));
        }
示例#12
0
        private ContactSearch GetFilledRandomContactSearch(string OmitPropName)
        {
            ContactSearch contactSearch = new ContactSearch();

            if (OmitPropName != "ContactID")
            {
                contactSearch.ContactID = GetRandomInt(1, 11);
            }
            if (OmitPropName != "ContactTVItemID")
            {
                contactSearch.ContactTVItemID = GetRandomInt(1, 11);
            }
            if (OmitPropName != "FullName")
            {
                contactSearch.FullName = GetRandomString("", 5);
            }

            return(contactSearch);
        }
示例#13
0
        private bool IsValid(ContactSearch cs)
        {
            var pattern           = @"^[a-zA-Z0-9 ]*$";
            var patternOnlyDigits = @"^[0-9]*$";

            //FirstName
            if (!String.IsNullOrEmpty(cs.FirstName))
            {
                if (!Regex.IsMatch(cs.FirstName, pattern))
                {
                    return(false);
                }
            }
            //LastName
            if (!String.IsNullOrEmpty(cs.LastName))
            {
                if (!Regex.IsMatch(cs.LastName, pattern))
                {
                    return(false);
                }
            }
            //Address
            if (!String.IsNullOrEmpty(cs.Address))
            {
                if (!Regex.IsMatch(cs.Address, pattern))
                {
                    return(false);
                }
            }
            //PhoneNum
            if (!String.IsNullOrEmpty(cs.PhoneNum))
            {
                if (!Regex.IsMatch(cs.PhoneNum, patternOnlyDigits))
                {
                    return(false);
                }
            }

            return(true);
        }
        private IEnumerable <ValidationResult> Validate(ValidationContext validationContext, ActionDBTypeEnum actionDBType)
        {
            string        retStr        = "";
            Enums         enums         = new Enums(LanguageRequest);
            ContactSearch contactSearch = validationContext.ObjectInstance as ContactSearch;

            contactSearch.HasErrors = false;

            if (contactSearch.ContactID < 1)
            {
                contactSearch.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._MinValueIs_, "ContactID", "1"), new[] { "ContactID" }));
            }

            if (contactSearch.ContactTVItemID < 1)
            {
                contactSearch.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._MinValueIs_, "ContactTVItemID", "1"), new[] { "ContactTVItemID" }));
            }

            if (string.IsNullOrWhiteSpace(contactSearch.FullName))
            {
                contactSearch.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "FullName"), new[] { "FullName" }));
            }

            if (!string.IsNullOrWhiteSpace(contactSearch.FullName) && contactSearch.FullName.Length > 255)
            {
                contactSearch.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._MaxLengthIs_, "FullName", "255"), new[] { "FullName" }));
            }

            retStr = "";      // added to stop compiling CSSPError
            if (retStr != "") // will never be true
            {
                contactSearch.HasErrors = true;
                yield return(new ValidationResult("AAA", new[] { "AAA" }));
            }
        }
示例#15
0
 public List <Contact> Search(ContactSearch cs)
 {
     try
     {
         //Validation
         if (cs != null)
         {
             ValidationResult results = validatorSearch.Validate(cs);
             if (results.IsValid)
             {
                 return(_dalContact.Search(cs));
             }
             else
             {
                 //!results.IsValid
                 if (results.Errors != null && results.Errors.Count > 0)
                 {
                     foreach (var failure in results.Errors)
                     {
                         throw new Exception(
                                   $"Property {failure.PropertyName} failed validation. Error was: {failure.ErrorMessage}");
                     }
                 }
             }
         }
         return(null);
     }
     catch (ValidationException e)
     {
         throw new Exception($"validation error: {e.ToString()}");
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
 public PlaceCollection PlacesPlacesForContacts(PlaceType placeType, string woeId, string placeId, int threshold,
                                                ContactSearch contactType, DateTime minUploadDate,
                                                DateTime maxUploadDate, DateTime minTakenDate,
                                                DateTime maxTakenDate);
        public async Task <object> Search([FromBody] ContactSearch search)
        {
            var userId = _claimsProvider.GetUserId(Request.HttpContext);

            return(Ok(await _service.Search(userId, search)));
        }
 public IActionResult Get([FromQuery] ContactSearch search,
                          [FromServices] IGetContactQuery query)
 {
     return(Ok(_executor.ExecuteQuery(query, search)));
 }
示例#19
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     ContactSearch.NewSearch();
 }
 public ContactSearchTest()
 {
     contactSearch = new ContactSearch();
 }
示例#21
0
        /// <summary>
        /// Return a list of the top 100 unique places clustered by a given placetype for set of tags or machine tags.
        /// </summary>
        /// <param name="placeType">The ID for a specific place type to cluster photos by. </param>
        /// <param name="woeId">A Where on Earth identifier to use to filter photo clusters. </param>
        /// <param name="placeId">A Flickr Places identifier to use to filter photo clusters. </param>
        /// <param name="threshold">The minimum number of photos that a place type must have to be included. If the number of photos is lowered then the parent place type for that place will be used.</param>
        /// <param name="contactType">The type of contacts to return places for. Either all, or friends and family only.</param>
        /// <param name="minUploadDate">Minimum upload date.</param>
        /// <param name="maxUploadDate">Maximum upload date.</param>
        /// <param name="minTakenDate">Minimum taken date.</param>
        /// <param name="maxTakenDate">Maximum taken date.</param>
        /// <returns></returns>
        public PlaceCollection PlacesPlacesForContacts(PlaceType placeType, string woeId, string placeId, int threshold, ContactSearch contactType, DateTime minUploadDate, DateTime maxUploadDate, DateTime minTakenDate, DateTime maxTakenDate)
        {
            CheckRequiresAuthentication();

            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("method", "flickr.places.placesForContacts");

            parameters.Add("place_type_id", placeType.ToString("D"));
            if (!String.IsNullOrEmpty(woeId)) parameters.Add("woe_id", woeId);
            if (!String.IsNullOrEmpty(placeId)) parameters.Add("place_id", placeId);
            if (threshold > 0) parameters.Add("threshold", threshold.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            if (contactType != ContactSearch.None) parameters.Add("contacts", (contactType == ContactSearch.AllContacts ? "all" : "ff"));
            if (minUploadDate != DateTime.MinValue) parameters.Add("min_upload_date", UtilityMethods.DateToUnixTimestamp(minUploadDate));
            if (maxUploadDate != DateTime.MinValue) parameters.Add("max_upload_date", UtilityMethods.DateToUnixTimestamp(maxUploadDate));
            if (minTakenDate != DateTime.MinValue) parameters.Add("min_taken_date", UtilityMethods.DateToMySql(minTakenDate));
            if (maxTakenDate != DateTime.MinValue) parameters.Add("max_taken_date", UtilityMethods.DateToMySql(maxTakenDate));

            return GetResponseCache<PlaceCollection>(parameters);
        }