first commit
This commit is contained in:
1 parent
a9f02f8595
commit
1f6634add4
83 files changed
+28739
No files matched your search
@@ -0,0 +1,57 @@
|
||||
using MySql.Data.MySqlClient;
|
||||
using PaymentLogs.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PaymentLogs.Repositories
|
||||
{
|
||||
internal class CourseRepo : Repo<int, Course>
|
||||
{
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
DataBase db = new DataBase();
|
||||
db.openConnection();
|
||||
_data.Clear();
|
||||
string sql = " SELECT * FROM courses ";
|
||||
MySqlCommand cmd = new MySqlCommand(sql, db.getConnection());
|
||||
MySqlDataReader reader = cmd.ExecuteReader();
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
Course course = new Course() {
|
||||
Id = reader.GetInt32("id"),
|
||||
Name = reader.GetString("name"),
|
||||
Type = reader.GetString("type"),
|
||||
Cost = reader.GetInt32("cost"),
|
||||
Duration = reader.GetInt32("duration"),
|
||||
StudentsCount = reader.GetInt32("students_count")
|
||||
};
|
||||
_data[course.Id] = course;
|
||||
}
|
||||
db.closeConnection();
|
||||
}
|
||||
|
||||
|
||||
public override void Save()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Course ByName(string name)
|
||||
{
|
||||
foreach (var course in _data.Values)
|
||||
{
|
||||
if (course.Name.ToLower().Equals(name.ToLower()))
|
||||
{
|
||||
return course;
|
||||
}
|
||||
}
|
||||
return _data.Values.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user