using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace AppliDeWS {
	/// <summary>
	/// Description résumée de MonService
	/// </summary>
	[WebService( Namespace = "http://tempuri.org/" )]
	[WebServiceBinding( ConformsTo = WsiProfiles.BasicProfile1_1 )]
	[System.ComponentModel.ToolboxItem( false )]
	[System.Web.Script.Services.ScriptService]
	public class MonService : System.Web.Services.WebService {

		[WebMethod]
		public int Additionner( int i1, int i2 ) {
			return i1 + i2;
		}
		[WebMethod]
		public object Rechercher( string nomOuPrenom ) {
			using( DAL.AnnuaireEntities dc = new DAL.AnnuaireEntities() ) {
				return dc.Personnes
					.Where( p => p.Nom.Contains( nomOuPrenom ) || p.Prenom.Contains( nomOuPrenom ) )
					.Select( p => new {
						p.Nom,
						p.Prenom,
						p.Titre.Civilite
					} ).ToList();
			}
			
		}
	}
}
