How to return Json response message for http error like 404 in wcf Service?

202 Views Asked by At

I have the below function which i am returning employees list. If there is no list present in DB, I need to return httpstatusErrorcode with error message

public List<SelectEventsMClass> FetchAllEmployes(int EmployTypeID)
{
    try
    {
        var EventsList = new List<SelectEventsMClass>();
        Employ.Data.EmployTableAdapters.EventsMSelectAllTableAdapter Adp = new Data.EmployTableAdapters.EventsMSelectAllTableAdapter();
        Employ.Data.Employ.EventsMSelectAllDataTable Dtl = Adp.GetData(intEventTypeID);
        if (Dtl.Rows.Count > 0)
        {
           var EventsList = (from lst in Dtl.AsEnumerable()
                          select new SelectEventsMClass
                          {
                              TransID = lst.Field<Guid>("TransID"),
                              SchoolTransID = lst.Field<Guid>("SchoolTransID"),
                              AcadamicTransID = lst.Field<Guid>("AcadamicTransID"),
                              EventTypeID = lst.Field<int>("EventTypeID"),
                              EventTitle = lst.Field<string>("EventTitle"),

                          }).ToList();
        }
        return EventsList;                 
    }
    catch (Exception ex)
    {
        throw ex;
    }
}
0

There are 0 best solutions below