Beispiel #1
0
        public bool SetUserInfo(int id, string username, string password)
        {
            Connection c = new Connection();

            Utilizadores = new UtilizadorDAO(c);
            // Encontra o utilizador através do seu username
            Utilizador updated = Utilizadores.FindById(id);

            if (username != null)
            {
                if (Utilizadores.FindByUsername(username) == true)
                {
                    throw new InvalidOperationException("There already exists a user with the same username!");
                }
                else
                {
                    updated.Username = username;
                }
            }
            if (password != null)
            {
                updated.Password = password;
            }

            return(Utilizadores.Update(updated));
        }
Beispiel #2
0
 public ActionResult Edit(int id, Utilizador smodel)
 {
     try
     {
         IConnection connection = new Connection();
         connection.Fetch();
         IDAO <Utilizador> uDAO = new UtilizadorDAO(connection);
         uDAO.Update(Convert.ToString(id), smodel);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }