Ejemplo n.º 1
0
 public Result Register(UserDataObject user)
 {//registers new user
     try
     {
         UserBusinessLayer customerBusiness = new UserBusinessLayer();
         Result            res = customerBusiness.Register(user);
         return(res);
     }
     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);
         }
     }
 }