예제 #1
0
        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);
                }
            }
        }
예제 #2
0
        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();
                }
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        public Receita[] ConsultarReceitasUtilizador(ref int idUser)
        {
            Utilizador _user = dao_utilizador.Get(ref idUser)[0];

            return(_user.GetReceitas());
        }
예제 #5
0
        public void RegistarUtilizador(ref string nomeUser, ref string password, ref string email)
        {
            Utilizador _user = new Utilizador(nomeUser, email, password);

            dao_utilizador.Insert(ref _user);
        }
예제 #6
0
파일: Planeador.cs 프로젝트: AnaSofiagm/LI4
 public void SetUtilizador(ref Utilizador utilizador)
 {
     this.utilizador = utilizador;
 }
예제 #7
0
 public void Update(ref Utilizador user)
 {
     throw new System.Exception("Not implemented");
 }
예제 #8
0
 public Comentario(string texto, int receita, Utilizador user)
 {
     this.texto   = texto;
     this.receita = receita;
     this.user    = user;
 }