public wsSQLResult LoginUsuario(Stream JSONdataStream) { wsSQLResult result = new wsSQLResult(); try { string queLaClave = ""; int idCliente = 0; StreamReader reader = new StreamReader(JSONdataStream); string JSONdata = reader.ReadToEnd(); JavaScriptSerializer jss = new JavaScriptSerializer(); Cliente_ obj = jss.Deserialize <Cliente_>(JSONdata); if (obj == null) { result.WasSucceful = 0; result.Exception = "No se pudo deserializar el JSON"; return(result); } var log = FiltradoPorCorreo(obj.Correo); if (log.Count == 0) { result.WasSucceful = 0; result.Exception = "Usuario y clave invalidos"; return(result); } var lista = log.ToList(); foreach (var i in lista) { queLaClave = i.Clave; idCliente = i.Id; } if (queLaClave != obj.Clave) { result.WasSucceful = 0; result.Exception = "Usuario y clave invalidos"; return(result); } else { result.WasSucceful = idCliente; result.Exception = ""; return(result); } } catch (Exception ex) { result.WasSucceful = 0; result.Exception = ex.Message; return(result); } }
public wsSQLResult CrearUsuario(Stream JSONdataStream) { wsSQLResult result = new wsSQLResult(); try { StreamReader reader = new StreamReader(JSONdataStream); string JSONdata = reader.ReadToEnd(); JavaScriptSerializer jss = new JavaScriptSerializer(); Cliente_ obj = jss.Deserialize <Cliente_>(JSONdata); if (obj == null) { result.WasSucceful = 0; result.Exception = "No se pudo deserializar el JSON a Cliente_"; return(result); } Cliente newCustomer = new Cliente { Nombres = obj.Nombres, Correo = obj.Correo, Clave = obj.Clave }; if (FiltradoPorCorreo(obj.Correo).Count != 0) { result.WasSucceful = 0; result.Exception = "Correo ya existe"; return(result); } BDUsuario.Cliente.InsertOnSubmit(newCustomer); BDUsuario.SubmitChanges(); result.WasSucceful = 1; result.Exception = ""; return(result); } catch (Exception e) { result.WasSucceful = 0; result.Exception = e.Message; return(result); } }