public static BomoUsuario VerificarUsuarioBomo(string password, string user) { try { var usuario = new BomoUsuario(); DBContext db = new DBContext(); //var check = Encrypt(password); var pass = Encrypt(password); var query = from u in db.BomoUsuario where u.bomoCliente.email == user && u.senha == pass select u; foreach (BomoUsuario u in query) { usuario = u; } return usuario; } catch (Exception) { return null; } }
public HttpResponseMessage GetUsuario([FromBody]JObject modelUser) { try { //System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer(); //var data = js.Deserialize<Cliente>(dataCliente); dynamic json = modelUser; BomoUsuario usuario = new BomoUsuario(); string email = ""; email = json["emailUsuario"]; DBContext db = new DBContext(); usuario = (from usu in db.BomoUsuario where usu.bomoCliente.email == email select usu).First(); return Request.CreateResponse(HttpStatusCode.OK, new { usuario }); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); } }
public HttpResponseMessage CadastroUsuario([FromBody]JObject model) { try { //System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer(); //var data = js.Deserialize<Cliente>(dataCliente); dynamic json = model; var usuario = new BomoUsuario(); var cliente = new BomoCliente(); var bomoEmpresa = new BomoEmpresa(); int idEmpresa = 0; idEmpresa = json["idEmpresa"]; string email = json["email"]; string senha = json["senha"]; DBContext db = new DBContext(); cliente = (from cli in db.BomoCliente where cli.email == email select cli).First(); usuario.senha = Simple.Encrypt(senha); usuario.bomoCliente = cliente; if (idEmpresa > 0) { bomoEmpresa = (from emp in db.BomoEmpresa where emp.idBomoEmpresa == idEmpresa select emp).First(); usuario.bomoEmpresa = bomoEmpresa; } db.BomoUsuario.Add(usuario); db.SaveChanges(); return Request.CreateResponse(HttpStatusCode.OK, new { usuario.idBomoUsuario }); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message); } }