示例#1
0
 public List <CustomerDataObject> RetrieveAll(Retrieve_message msg, string apiKey)
 {
     BusinessLayer.CustomerBusinessLayer BLObject = new BusinessLayer.CustomerBusinessLayer();
     try
     {
         return(BLObject.RetrieveAll(msg, apiKey));
     }
     catch (Exception e)
     {
         #region catchblock
         if (e.Message == "wrongkey")
         {
             Result ErrorObj = new Result()
             {
             };
             ErrorObj.Status           = "Failure";
             ErrorObj.ExceptionDetails = "Invalid Api Key";
             ErrorObj.ExceptionType    = "AuthorizationException";
             throw new WebFaultException <Result>(ErrorObj, System.Net.HttpStatusCode.Unauthorized);
         }
         else
         {
             Result ErrorObj = new Result();
             ErrorObj.Status           = "Failure";
             ErrorObj.ExceptionType    = e.GetType().ToString().Split('.')[1];
             ErrorObj.ExceptionDetails = e.Message;
             throw new WebFaultException <Result>(ErrorObj, System.Net.HttpStatusCode.InternalServerError);
         }
         #endregion
     }
 }
示例#2
0
 public Result Delete(Retrieve_message message, string apiKey)
 {
     try
     {
         BusinessLayer.CustomerBusinessLayer b = new BusinessLayer.CustomerBusinessLayer();
         return(b.Delete(message, apiKey));
     }
     catch (Exception e)
     {
         if (e.Message == "wrongkey")
         {
             Result ErrorObj = new Result();
             ErrorObj.Status           = "Failure";
             ErrorObj.ExceptionDetails = "Invalid Api Key";
             ErrorObj.ExceptionType    = "AuthorizationException";
             throw new WebFaultException <Result>(ErrorObj, System.Net.HttpStatusCode.Unauthorized);
         }
         else
         {
             Result obj = new Result();
             obj.Status           = "Failure";
             obj.ExceptionType    = e.GetType().ToString().Split('.')[1];
             obj.ExceptionDetails = e.Message;
             throw new WebFaultException <Result>(obj, System.Net.HttpStatusCode.InternalServerError);
         }
     }
 }
示例#3
0
 public Result Update(CustomerDataObject customer, string apiKey)
 {
     try
     {
         BusinessLayer.CustomerBusinessLayer BLObject = new BusinessLayer.CustomerBusinessLayer();
         return(BLObject.Update(customer, apiKey));
     }
     catch (Exception e)
     {
         if (e.Message == "wrongkey")
         {
             Result ErrorObj = new Result();
             ErrorObj.Status           = "Failure";
             ErrorObj.ExceptionDetails = "Invalid Api Key";
             ErrorObj.ExceptionType    = "AuthorizationException";
             throw new WebFaultException <Result>(ErrorObj, System.Net.HttpStatusCode.Unauthorized);
         }
         else if (e.Message.Contains("null"))
         {
             Result obj = new Result();
             obj.Status           = "Failure";
             obj.ExceptionType    = "RequiredFieldException";
             obj.ExceptionDetails = "Required Field Cannot be null";
             throw new WebFaultException <Result>(obj, System.Net.HttpStatusCode.InternalServerError);
         }
         else
         {
             Result obj = new Result();
             obj.Status           = "Failure";
             obj.ExceptionType    = e.GetType().ToString().Split('.')[1];
             obj.ExceptionDetails = e.Message;
             throw new WebFaultException <Result>(obj, System.Net.HttpStatusCode.InternalServerError);
         }
     }
 }