Advertisement
Guest User

Untitled

a guest
May 30th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. [OperationContract]
  2. [WebInvoke(Method = "POST", UriTemplate = "/postUporabnik",
  3. RequestFormat = WebMessageFormat.Json,
  4. ResponseFormat = WebMessageFormat.Json)]
  5. string postUporabnik(uporabnik uporabnik);
  6.  
  7.  
  8.  
  9. public string postUporabnik(uporabnik uporabnik)
  10. {
  11. int stPrej = getVseUporabnike().Count();
  12. using (SqlConnection myConnection = new SqlConnection(con))
  13. {
  14.  
  15. SqlCommand myCommand = new SqlCommand("INSERT INTO uporabnik(id,ime,priimek,geslo,uporabniskoIme,datumRojstva,eMail,ulica,postnaStevilka,imePoste) VALUES(@id,@ime,@priimek,@geslo,@uporabniskoIme,@datumRojstva,@eMail,@ulica,@postnaStevilka,@imePoste)", myConnection);
  16. myConnection.Open();
  17. int id = getVseUporabnike().Last().id + 1;
  18. myCommand.Parameters.AddWithValue("@id", id);
  19. myCommand.Parameters.AddWithValue("@ime", uporabnik.ime);
  20. myCommand.Parameters.AddWithValue("@priimek", uporabnik.priimek);
  21. myCommand.Parameters.AddWithValue("@geslo", uporabnik.geslo);
  22. myCommand.Parameters.AddWithValue("@datumRojstva", uporabnik.datumRojstva);
  23. myCommand.Parameters.AddWithValue("@uporabniskoIme", uporabnik.uporabniskoIme);
  24. myCommand.Parameters.AddWithValue("@eMail", uporabnik.eMail);
  25. myCommand.Parameters.AddWithValue("@ulica", uporabnik.ulica);
  26. myCommand.Parameters.AddWithValue("@postnaStevilka", uporabnik.postnaStevilka);
  27. myCommand.Parameters.AddWithValue("@imePoste", uporabnik.imePoste);
  28. myCommand.ExecuteNonQuery();
  29. myConnection.Close();
  30. myCommand.Dispose();
  31. }
  32. if (stPrej < getZdravila().Count)
  33. {
  34. return "uspeh";
  35. }
  36. else return "neuspeh";
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement