public COfertaResult() { Oferta = new COferta(); User = new CUser(); }
static public CUser Load(int id, string mail, string clave, string key) { CUser user = new CUser(); user.Valido = false; SqlConnection cnn = CDB.GetConnection(); SqlDataReader dr = null; try { SqlCommand cmd = new SqlCommand("sp_user_get"); cmd.Connection = cnn; cmd.Parameters.AddWithValue("@id", id); cmd.Parameters.AddWithValue("@mail", mail); cmd.Parameters.AddWithValue("@clave", clave); cmd.Parameters.AddWithValue("@key", key); cmd.CommandType = System.Data.CommandType.StoredProcedure; dr = cmd.ExecuteReader(); if (dr.Read()) { int id_usuario = int.Parse(dr["id_usuario"].ToString()); string nombre = dr["nombre"].ToString(); string apaterno = dr["apaterno"].ToString(); string amaterno = dr["amaterno"].ToString(); mail = dr["mail"].ToString(); clave = dr["clave"].ToString(); string link_foto = dr["link_foto"].ToString(); string link_cv = dr["link_cv"].ToString(); string descripcion = dr["descripcion"].ToString(); string sessionkey = dr["sessionkey"].ToString(); int rating = int.Parse(dr["rating"].ToString()); user.Id = id_usuario; user.Mail = mail; user.AMaterno = amaterno; user.APaterno = apaterno; user.CV = link_cv; user.Avatar = link_foto; user.Descripcion = descripcion; user.Key = sessionkey; user.Valido = true; user.Nombre = nombre; user.Rating = rating; } dr.Close(); } catch (Exception ex) { Console.WriteLine("addcarDay exception:" + ex.ToString()); } finally { if (dr != null && !dr.IsClosed) { dr.Close(); } if (cnn != null) { cnn.Close(); } } return(user); }