示例#1
0
 public string ActualizarEmpleado(string id, TR_empleado empleado)
 {
     try
     {
         var resultado = procedimiento.ExisteEmpleado(id);
         if (resultado == true)
         {
             procedimiento.ActualizarEmpleado(empleado);
             return("OK");
         }
         return("El run ingresado no arrojó resultados");
     }
     catch (NullReferenceException)
     {
         return("Todos los campos deben estar completos");
     }
     catch (InvalidCastException)
     {
         return("El tipo de formato enviado no corresponde");
     }
     catch (Exception)
     {
         return("Ha ocurrido un error al momento de actualizar");
     }
 }
示例#2
0
 public string AgregarEmpleado(TR_empleado empleado)
 {
     try
     {
         procedimiento.AgregarEmpleado(empleado);
         return("OK");
     }
     catch (NullReferenceException)
     {
         return("Todos los campos deben estar completos");
     }
     catch (InvalidCastException)
     {
         return("El tipo de formato enviado no corresponde");
     }
     //catch (DbEntityValidationException e)
     //{
     //    foreach (var eve in e.EntityValidationErrors)
     //    {
     //        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
     //            eve.Entry.Entity.GetType().Name, eve.Entry.State);
     //        foreach (var ve in eve.ValidationErrors)
     //       {
     //            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
     //                ve.PropertyName, ve.ErrorMessage);
     //        }
     //    }
     //    throw;
     //}
     catch (DbUpdateException)
     {
         return("El run ingresado ya se encuentra registrado");
     }
     catch (Exception)
     {
         return("Ha ocurrido un error al momento de registrar");
     }
 }