-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dodani su repozitoriji i metode
- Loading branch information
Showing
6 changed files
with
144 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SZUUP.Models | ||
{ | ||
public class Jelo | ||
{ | ||
public int Id_jelo { get; set; } | ||
public int Id_Kategorija { get; set; } | ||
public string Naziv { get; set; } | ||
public float Cijena { get; set; } | ||
public string Detalji { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SZUUP.Models | ||
{ | ||
internal class Zaposlenik | ||
{ | ||
public int Id_zaposlenika { get; set; } | ||
public string Kor_ime { get; set; } | ||
public string Lozinka { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using DBLayer; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data.SqlClient; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using SZUUP.Models; | ||
|
||
namespace SZUUP.Repozitoris | ||
{ | ||
public class RepozitorijJelo | ||
{ | ||
public static Jelo GetJelo(int id) | ||
{ | ||
Jelo jelo = null; | ||
string sql = $"SELECT * FROM jelo WHERE Id_jelo = {id}"; | ||
DB.OpenConnection(); | ||
var reader = DB.GetDataReader(sql); | ||
if (reader.HasRows) | ||
{ | ||
reader.Read(); | ||
jelo = CreateObject(reader); | ||
reader.Close(); | ||
} | ||
DB.CloseConnection(); | ||
return jelo; | ||
} | ||
public static List<Jelo> GetJelo() | ||
{ | ||
List<Jelo> jela = new List<Jelo>(); | ||
string sql = "SELECT * FROM jelo"; | ||
DB.OpenConnection(); | ||
var reader = DB.GetDataReader(sql); | ||
while (reader.Read()) | ||
{ | ||
Jelo jelo = CreateObject(reader); | ||
Jelo.Add(jelo); | ||
} | ||
reader.Close(); | ||
DB.CloseConnection(); | ||
return jelo; | ||
} | ||
|
||
private static Jelo CreateObject(SqlDataReader reader) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using DBLayer; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Data.SqlClient; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel; | ||
|
||
namespace SZUUP.Repozitoris | ||
{ | ||
public class RepozitorijZaposlenik | ||
{ | ||
string sql = $"SELECT * FROM zaposlenik WHERE Kor_ime = '{Kor_ime}'"; | ||
return FetchZaposlenik(sql); | ||
} | ||
public static Zaposlenik GetZaposlenik(int id) | ||
{ | ||
string sql = $"SELECT * FROM zaposlenik WHERE Id_zaposlenika = {id}"; | ||
return FetchTeacher(sql); | ||
} | ||
private static Teacher FetchTeacher(string sql) | ||
{ | ||
DB.OpenConnection(); | ||
var reader = DB.GetDataReader(sql); | ||
Teacher teacher = null; | ||
if (reader.HasRows == true) | ||
{ | ||
reader.Read(); | ||
teacher = CreateObject(reader); | ||
reader.Close(); | ||
} | ||
DB.CloseConnection(); | ||
return teacher; | ||
} | ||
private static Teacher CreateObject(SqlDataReader reader) | ||
{ | ||
int id = int.Parse(reader["Id"].ToString()); | ||
string firstName = reader["FirstName"].ToString(); | ||
string lastName = reader["LastName"].ToString(); | ||
string username = reader["Username"].ToString(); | ||
string password = reader["Password"].ToString(); | ||
var teacher = new Teacher | ||
{ | ||
Id = id, | ||
FirstName = firstName, | ||
LastName = lastName, | ||
Username = username, | ||
Password = password | ||
}; | ||
return teacher; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters