Information Publishing System JQUERY+MVC Architecture Development (6) BLL layer provides WCF services __jquery

Source: Internet
Author: User
Tags serialization

BLL layer We use WCF to provide services, this layer we only publish only one service, in order to make our code more maintainable, we introduce the abstract factory model.

In this case, we will first create three interfaces:

1) iinfo

Inforesult ADD (info info);
Inforesult Update (info info);
Inforesult Delete (int infoid);
Infolist getinfolist (SearchInfo searchinfo);
Infolist Getinfobyid (int infoid);

2) Iinfotype
The same as above, no longer repeat.

3) Iuserinfo
The same as above, no longer repeat.

Then implement these three interfaces, we also use INFOBLL for example as follows:

Using System;

Using System.Collections.Generic;

Using System.Linq;

Using System.Text;

Using Infopub.dal;

Using Infopub.modal;

Namespace Infopub.bllservice

{

public class Infobll:iinfo

{

Private Infodal infodal=new infodal ();

Public Inforesult ADD (Info model)

{

return Infodal.add (model);

}

Public Inforesult Update (Info model)

{

return infodal.update (model);

}

Public Inforesult Delete (int infoid)

{

Return Infodal.delete (infoid);

}

Public infolist getinfolist (SearchInfo searchinfo)

{

Return Infodal.getinfolist (SearchInfo);

}

Public infolist Getinfobyid (int infoid)

{

Return Infodal.getinfobyid (infoid);

}

}

}

Then we create a factory interface:

Using System;

Using System.Collections.Generic;

Using System.Linq;

Using System.Text;

Namespace InfoPub.BLLService.Interface

{

public interface Inbllfactory

{

Iinfo Createinfo ();

Iinfotype Createinfotype ();

Iuserinfo Createuserinfo ();

}

}

Then implement the factory class:

Using System;

Using System.Collections.Generic;

Using System.Linq;

Using System.Text;

Using InfoPub.BLLService.Interface;

Namespace Infopub.bllservice

{

public class Bllfactory:inbllfactory

{

Public Iinfo Createinfo ()

{

return new INFOBLL ();

}

Public Iinfotype Createinfotype ()

{

return new INFOTYPEBLL ();

}

Public Iuserinfo Createuserinfo ()

{

return new USERINFOBLL ();

}

}

}

To access the factory class we define a factory-provided class:

Using System;

Using System.Collections.Generic;

Using System.Linq;

Using System.Text;

Namespace Infopub.bllservice

{

public class Common

{

public static bllfactory bllfactory=new bllfactory ();

}

}

So that we can access our factory class, and in order to provide the factory class method to WCF, we add a Commondata class, which resembles our façade:

Using System;

Using System.Collections.Generic;

Using System.Linq;

Using System.Text;

Namespace Infopub.bllservice

{

public class Commondata

{

#region Global Variables

public static Iinfo info = Common.bllFactory.CreateInfo ();

public static Iinfotype InfoType = Common.bllFactory.CreateInfoType ();

public static Iuserinfo UserInfo = Common.bllFactory.CreateUserInfo ();

#endregion

}

}

Then define our WCF contract:

Using System;

Using System.Collections.Generic;

Using System.Linq;

Using System.Runtime.Serialization;

Using System.ServiceModel;

Using System.Text;

Using Infopub.modal;

Namespace Infopub.bllservice

{

[ServiceContract]

public interface Iinfopubservice

{

[OperationContract]

Inforesult Addinfo (info info);

[OperationContract]

Inforesult Updateinfo (info info);

[OperationContract]

Inforesult deleteinfo (int infoid);

[OperationContract]

Infolist getinfolist (SearchInfo searchinfo);

[OperationContract]

Infolist Getinfobyid (int infoid);

[OperationContract]

Inforesult Addinfotype (InfoType infotype);

[OperationContract]

Inforesult Updateinfotype (InfoType infotype);

[OperationContract]

Inforesult deleteinfotype (int infotypeid);

[OperationContract]

Infotypelist getinfotypelist (Searchinfotype searchinfotype);

[OperationContract]

Infotypelist Getinfotypebyid (int infoid);

[OperationContract]

Inforesult Adduserinfo (UserInfo UserInfo);

[OperationContract]

Inforesult Updateuserinfo (UserInfo UserInfo);

[OperationContract]

Inforesult deleteuserinfo (int userinfoid);

[OperationContract]

Infolist getuserinfolist (Searchuserinfo searchuserinfo);

[OperationContract]

Infolist Getuserinfobyid (int userinfoid);

}

}

It is implemented as follows:

Using System;

Using System.Collections.Generic;

Using System.Linq;

Using System.Runtime.Serialization;

Using System.ServiceModel;

Using System.Text;

Using Infopub.modal;

Namespace Infopub.bllservice

{

public class Infopubservice:iinfopubservice

{

Public Inforesult Addinfo (info info)

{

return CommonData.info.Add (info);

}

Public Inforesult Updateinfo (info info)

{

return CommonData.info.Update (info);

}

Public Inforesult deleteinfo (int infoid)

{

Return CommonData.info.Delete (infoid);

}

Public infolist getinfolist (SearchInfo searchinfo)

{

Return CommonData.info.GetInfoList (SearchInfo);

}

Public infolist Getinfobyid (int infoid)

{

Return CommonData.info.GetInfoById (infoid);

}

Public Inforesult Addinfotype (InfoType infotype)

{

Return CommonData.infoType.Add (InfoType);

}

Public Inforesult Updateinfotype (InfoType infotype)

{

Return CommonData.infoType.Update (InfoType);

}

Public Inforesult deleteinfotype (int infotypeid)

{

Return CommonData.infoType.Delete (Infotypeid);

}

Public infotypelist getinfotypelist (Searchinfotype searchinfotype)

{

Return CommonData.infoType.GetInfoTypeList (Searchinfotype);

}

Public infotypelist Getinfotypebyid (int infoid)

{

Return CommonData.infoType.GetInfoTypeById (infoid);

}

Public Inforesult Adduserinfo (UserInfo UserInfo)

{

Return CommonData.userInfo.Add (UserInfo);

}

Public Inforesult Updateuserinfo (UserInfo UserInfo)

{

Return CommonData.userInfo.Update (UserInfo);

}

Public Inforesult deleteuserinfo (int userinfoid)

{

Return CommonData.userInfo.Delete (userinfoid);

}

Public infolist getuserinfolist (Searchuserinfo searchuserinfo)

{

Return CommonData.userInfo.GetUserInfoList (Searchuserinfo);

}

Public infolist Getuserinfobyid (int userinfoid)

{

Return CommonData.userInfo.GetUserInfoById (userinfoid);

}

}

}

Here is our class diagram relationship:

What I need to explain is that this is a class diagram that was generated in reverse with EA and then manually modified.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.