Preferred Language:
Listing 33.20 - MovieService.asmx
<%@ WebService Language="C#" Class="MovieService" %>
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using System.Web.Script.Services;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class MovieService : System.Web.Services.WebService
{
[WebMethod]
public List<Movie> SelectAll()
{
MyDatabaseDataContext db = new MyDatabaseDataContext();
return db.Movies.ToList();
}
[WebMethod]
public int Insert(Movie movieToAdd)
{
MyDatabaseDataContext db = new MyDatabaseDataContext();
db.Movies.InsertOnSubmit(movieToAdd);
db.SubmitChanges();
return movieToAdd.Id;
}
}
ASP.NET 3.5 Unleashed
- Containing almost 2,000 pages of code samples and in-depth explanation of the
ASP.NET 3.5 Framework, ASP.NET 3.5 Unleashed is the most comprehensive book
written on the ASP.NET 3.5 Framework.
ASP.NET 3.5 Unleashed is now available in your local bookstore and online (Published January 7, 2008).
All of the code samples from this book are hosted "live" at this website.
Click here
to view the table of contents and code samples.