Exemplo n.º 1
0
 public Cliente ActualizarCliente(Cliente cliente)
 {
     ClienteDA servicio = new ClienteDA();
     if (string.IsNullOrWhiteSpace(cliente.MailCli01) || string.IsNullOrWhiteSpace(cliente.TelCli01)) 
     {
         throw new WebFaultException<string>("El e-mail y el teléfono no pueden estar vacíos.", System.Net.HttpStatusCode.ExpectationFailed);
     }
     if (!servicio.verificarCorreo(cliente.MailCli01, cliente.IdCli))
     {
         throw new WebFaultException<string>("El correo ingresado ya se encuentra registrado para otro cliente. Ingrese uno diferente.", System.Net.HttpStatusCode.Conflict);
     }
     if (!Regex.IsMatch(cliente.MailCli01, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase)) 
     {
         throw new WebFaultException<string>("El correo ingresado no es válido. Ingrese uno diferente.", System.Net.HttpStatusCode.ExpectationFailed);
     }
     if (cliente.TelCli01.Length != 7 || !IsNumeric(cliente.TelCli01))
     {
         throw new WebFaultException<string>("El teléfono ingresado no es válido. Ingrese uno diferente.", System.Net.HttpStatusCode.ExpectationFailed);
     }
     return servicio.actualizarCliente(cliente);
 }
Exemplo n.º 2
0
 public Cliente ObtenerCliente(string codigo)
 {
     ClienteDA servicio = new ClienteDA();
     return servicio.obtenerCliente(Convert.ToInt32(codigo));
 }