using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using WEBSWAPP.Website.Data;
using System.Collections.Generic;
namespace Webswapp.Website.Categories.ASPNET3.AjaxToolKit
{
/// <summary>
/// This class serves the AJAX requests for queries against the Location table
/// </summary>
[WebService(Namespace = "http://webswapp.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class Locations : System.Web.Services.WebService
{
[System.Web.Services.WebMethod]
public string[] GetCitySuggestions(string prefixText, int count)
{
WEBSWAPP.Website.Data.SamplesDataContext db = new WEBSWAPP.Website.Data.SamplesDataContext();
List<WEBSWAPP.Website.Data.Location> locations = db.Locations
.Where(l => l.TypeId == 3 && l.Name.StartsWith(prefixText))
.OrderBy(l => l.Name)
.Take(count)
.ToList();
return locations
.Select(l => AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(
l.Name + ", " + l.Location1.Name + ", " + l.Location1.Location1.Name, l.Id.ToString()))
.ToArray();
}
}
}