<%@ WebHandler language= "C #" class= "Producthandler"%>
using System;
Using System.Web;
Using Jbtcard.entity.companyentity;
Using Jbtcard.business.companybs;
Using System.Collections.Generic;
Using Newtonsoft.json;
Using System.Web.SessionState;
Public class Producthandler:ihttphandler, IRequiresSessionState, ireadonlysessionstate{
public void ProcessRequest (HttpContext context) {
String moduleid = context.request.form["mo Duleid "].tostring ();
String message = "";
Switch (ModuleID)
{
Case "getptypelist":
ilist<producttypeidnameentity> list = Producttypebs.get Ptypelistidname ();
Message = Web effects convert.serializeobject (list);
break;
Case "Getcompanybyid":
int cid = Convert.ToInt32 (context.session["CID"); companyentity company = Companybs.get Companyentybyid (1);
Message = Javascriptconvert.serializeobject (company);
break;
Case "Insert":
String CoNDIS = context.request.form["Condi"].tostring ();
ProductEntity model = (productentity) javascriptconvert.deserializeobject (CoNDIS, typeof (ProductEntity));
BOOL B = productbs.addproduct (model);
if (b)
{
Message = "{success:true}";
}
Else
{
Throw new Exception ("Product addition failed!") ");
}
Break
}
Context.response.contenttype = "Text/javascript";
Context.Response.Write (message);
}
public bool IsReusable {
get {
return false;
}
}
}