クラス オブジェクトで Web サービスを使用する方法について疑問に思っています。BOL に Customer、Task、Project などのクラス オブジェクトがあります。ADO.net を使用してデータ層に接続しています。プロジェクト "WebServices" というフォルダーを追加し、BOL のメソッドを使用してデータを取得し、データを Web サービスの Json オブジェクトにフェッチしました。WebServices をデータベースに直接接続するか、BAL を使用してデータを取得し、その後 Json にフェッチする必要があるかどうか疑問に思っています。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Compudata_ProjectManager.CodeFile.BOL;
using System.Web.Script.Services;
namespace Compudata_ProjectManager.WebServices
{
/// <summary>
/// Summary description for CustomerList
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// 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 CustomerList : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public List<Customer> FetchCustomersList(string name)
{
var cust = new Customer();
var fetchNames = cust.GetAllCustomerNames().Where(n => n.FirstName.ToLower().StartsWith(name.ToLower()));
return fetchNames.ToList();
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public List<Location> FetchCustomerAddressList(string name)
{
var Addresses = new Location();
var fetchAddress = Location.GetAllAddress();
return fetchAddress.ToList();
}
}
}