public ActionResult Dojam(dojmovi Dojam)
        {
            Dojam.idPosiljaoca = Convert.ToInt32(Session["id"]);
            string        constr = ConfigurationManager.ConnectionStrings["ConnectionStringName"].ConnectionString;
            SqlConnection sqlcon = new SqlConnection(constr);

            if (sqlcon.State == ConnectionState.Closed)
            {
                sqlcon.Open();
            }
            //return RedirectToAction(Dojam.idPrimaoca.ToString(), "Korisnik");
            SqlCommand sqlcmd = new SqlCommand("dodajDojam", sqlcon);

            sqlcmd.CommandType = CommandType.StoredProcedure;
            sqlcmd.Parameters.AddWithValue("@idPosiljaoca", Dojam.idPosiljaoca);
            sqlcmd.Parameters.AddWithValue("@idPrimaoca", Dojam.idPrimaoca);
            sqlcmd.Parameters.AddWithValue("@dojam", Dojam.dojam);
            sqlcmd.ExecuteNonQuery();
            sqlcon.Close();
            return(RedirectToAction("Profil/" + Dojam.idPrimaoca.ToString(), "Korisnik"));
        }
        public ActionResult Profil(int id)
        {
            Korisnik       korisnikModel = new Korisnik();
            List <dojmovi> listaDojmova  = new List <dojmovi>();
            List <rute>    listaRuta     = new List <rute>();

            string        constr = ConfigurationManager.ConnectionStrings["ConnectionStringName"].ConnectionString;
            SqlConnection sqlcon = new SqlConnection(constr);

            if (sqlcon.State == ConnectionState.Closed)
            {
                sqlcon.Open();
            }
            SqlCommand    sqlcmd = new SqlCommand("getPodaciKorisnika", sqlcon);
            SqlDataReader reader;

            sqlcmd.CommandType = CommandType.StoredProcedure;
            sqlcmd.Parameters.AddWithValue("@id", id);
            reader = sqlcmd.ExecuteReader();

            while (reader.Read())
            {
                korisnikModel.id       = reader.GetInt32(0);
                korisnikModel.ime      = reader.GetString(1);
                korisnikModel.prezime  = reader.GetString(2);
                korisnikModel.email    = reader.GetString(3);
                korisnikModel.profilna = reader.GetString(7);
                if (!reader.IsDBNull(8))
                {
                    korisnikModel.mjestoStanovanja = reader.GetString(8);
                }
                if (!reader.IsDBNull(9))
                {
                    korisnikModel.brojTelefona = reader.GetString(9);
                }
            }
            reader.Close();

            sqlcmd             = new SqlCommand("selectRute", sqlcon);
            sqlcmd.CommandType = CommandType.StoredProcedure;
            sqlcmd.Parameters.AddWithValue("@id", id);
            reader = sqlcmd.ExecuteReader();

            while (reader.Read())
            {
                rute ruteModel = new rute();
                ruteModel.idRute        = reader.GetInt32(0);
                ruteModel.polaziste     = reader.GetString(2);
                ruteModel.odrediste     = reader.GetString(3);
                ruteModel.datum         = reader.GetDateTime(4);
                ruteModel.vrijeme       = reader.GetTimeSpan(5);
                ruteModel.drzava        = reader.GetString(6);
                ruteModel.nacinPlacanja = reader.GetString(7);
                listaRuta.Add(ruteModel);
            }
            reader.Close();

            sqlcmd             = new SqlCommand("selectDojmove", sqlcon);
            sqlcmd.CommandType = CommandType.StoredProcedure;
            sqlcmd.Parameters.AddWithValue("@id", korisnikModel.id);
            reader = sqlcmd.ExecuteReader();
            while (reader.Read())
            {
                dojmovi dojamModel = new dojmovi();
                dojamModel.idPosiljaoca = reader.GetInt32(1);
                dojamModel.idPrimaoca   = reader.GetInt32(2);
                dojamModel.dojam        = reader.GetString(3);
                //reader.Close();
                SqlCommand    sqlcmd2 = new SqlCommand("getPodaciKorisnika", sqlcon);
                SqlDataReader reader2;
                sqlcmd2.CommandType = CommandType.StoredProcedure;
                sqlcmd2.Parameters.AddWithValue("@id", reader.GetInt32(1));
                reader2 = sqlcmd2.ExecuteReader();

                while (reader2.Read())
                {
                    dojamModel.imePosiljaoca      = reader2.GetString(1);
                    dojamModel.profilnaPosiljaoca = reader2.GetString(7);
                }
                reader2.Close();
                listaDojmova.Add(dojamModel);
            }
            sqlcon.Close();

            ProfilModel profilModel = new ProfilModel();
            dojmovi     Dojam       = new dojmovi();

            profilModel.Dojam        = Dojam;
            profilModel.Korisnik     = korisnikModel;
            profilModel.ListaDojmova = listaDojmova;
            profilModel.ListaRuta    = listaRuta;
            return(View(profilModel));
        }