public Utilizador GetTeste(ref int id) { string connetionString = null; string sql = null; connetionString = ConfigurationManager.ConnectionStrings["Database1"].ConnectionString; using (SqlConnection cnn = new SqlConnection(connetionString)) { sql = "@select * from dbo.User where idUser = @id"; cnn.Open(); using (SqlCommand cmd = new SqlCommand(sql, cnn)) { cmd.Parameters.AddWithValue("@id", id); SqlDataReader dr = cmd.ExecuteReader(); string nome = dr["Username"].ToString(); string email = dr["Email"].ToString(); string password = dr["Password"].ToString(); int idu = Convert.ToInt32(dr["idUser"]); Utilizador user = new Utilizador(id, nome, email, password); return(user); } } }
public void Teste(ref Utilizador user) { string connetionString = null; string sql = null; //connetionString = ConfigurationManager.ConnectionStrings["Database1"].ConnectionString; connetionString = @"Data Source=.\SQLEXPRESS; AttachDbFilename=..\App_Start\Database1.mdf; Integrated Security=True; Connect Timeout=30; User Instance=True"; using (SqlConnection cnn = new SqlConnection(connetionString)) { sql = @"insert into dbo.User (idUser, Username, Email, Password) values(@id, @username, @email, @password);"; cnn.Open(); using (SqlCommand cmd = new SqlCommand(sql, cnn)) { cmd.Parameters.AddWithValue("@id", user.GetId()); cmd.Parameters.AddWithValue("@username", user.GetNome()); cmd.Parameters.AddWithValue("@email", user.GetEmail()); cmd.Parameters.AddWithValue("@password", user.GetPassword()); cmd.ExecuteNonQuery(); } } }
public int Insert(ref Utilizador user) { int id = user.GetId(); string username = user.GetNome(); string email = user.GetEmail(); string password = user.GetPassword(); string sqlCode = @"insert into dbo.User (idUser, Username, Email, Password) values(@id, @username, @email, @password);"; int ret = DbAccess.SaveData(sqlCode, user); if (ret == 1) { string ut_sql_code = @"insert into dbo.User_has_Utensilios (FK_idUser_UserUtensilios, FK_idUtensilio_UserUtensilios) values(@id, @ut_id);"; foreach (Utensilio ut in user.GetPref_utensilios()) { int ut_id = ut.GetId(); DbAccess.SaveData(ut_sql_code, user); } string it_sql_code = @"insert into dbo.User_has_Ingredientes (FK_idUser_UserIngrediente, FK_idIngrediente_UserIngrediente) values(@id, @it_id);"; foreach (Ingrediente it in user.GetPref_ingredientes()) { int it_id = it.GetId(); DbAccess.SaveData(it_sql_code, user); } string cat_sql_code = @"insert into dbo.User_has_Ingredientes (FK_idUser_UserCategoria, FK_idCategoria_UserCategoria) values(@id, @cat_id);"; foreach (Categoria cat in user.GetPref_categorias()) { int cat_id = cat.GetId(); DbAccess.SaveData(cat_sql_code, user); } } return(ret); }
public Receita[] ConsultarReceitasUtilizador(ref int idUser) { Utilizador _user = dao_utilizador.Get(ref idUser)[0]; return(_user.GetReceitas()); }
public void RegistarUtilizador(ref string nomeUser, ref string password, ref string email) { Utilizador _user = new Utilizador(nomeUser, email, password); dao_utilizador.Insert(ref _user); }
public void SetUtilizador(ref Utilizador utilizador) { this.utilizador = utilizador; }
public void Update(ref Utilizador user) { throw new System.Exception("Not implemented"); }
public Comentario(string texto, int receita, Utilizador user) { this.texto = texto; this.receita = receita; this.user = user; }