Esempio n. 1
0
 public int Divide(int a, int b)
 {
     try
     {
         return(a / b);
     }
     catch (DivideByZeroException ex)
     {
         var fault = new HelloFault
         {
             ErrorCode        = "101",
             ErrorDescription = "Divide by Zero"
         };
         throw new FaultException <HelloFault>(fault);
     }
 }
Esempio n. 2
0
 public string GetEmployeeName(int ID)
 {
     try
     {
         return("My name is John Doe");
     }
     catch (Exception)
     {
         var fault = new HelloFault
         {
             ErrorCode        = "99",
             ErrorDescription = "Please check values"
         };
         throw new FaultException <HelloFault>(fault);
     }
 }
Esempio n. 3
0
 public Employee GetEmployee(int ID)
 {
     try
     {
         var allEmps = GetAllEmployees();
         return(allEmps.First(x => x.ID == ID));
     }
     catch (Exception ex)
     {
         var fault = new HelloFault
         {
             ErrorCode        = "100",
             ErrorDescription = ex.Message
         };
         throw new FaultException <HelloFault>(fault);
     }
 }