68 lines
2.0 KiB
C#
68 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using AvaloniaApplication14_autoTest_190326.Models;
|
|
using AvaloniaApplication14_Di_test_1125.Models;
|
|
using AvaloniaApplication14_Inventory_300326.Models.Models;
|
|
using Microsoft.Extensions.Options;
|
|
using MySqlConnector;
|
|
|
|
namespace AvaloniaApplication14_Inventory_300326.Models.DataBase;
|
|
|
|
public class EquipmentRepository : BaseRepository<Equipment>, IDisposable
|
|
{
|
|
public EquipmentRepository(IOptions<DatabaseSettings> ConnectionString) : base(ConnectionString)
|
|
{
|
|
OpenConnection();
|
|
}
|
|
|
|
public override List<Equipment>? GetAll()
|
|
{
|
|
string sql = "select * from `Equipment`";
|
|
List<Equipment> result = new List<Equipment>();
|
|
try
|
|
{
|
|
using var mc = new MySqlCommand(sql, connection);
|
|
mc.ExecuteNonQuery();
|
|
using var reader = mc.ExecuteReader();
|
|
while (reader.Read())
|
|
{
|
|
Equipment equipment = new Equipment()
|
|
{
|
|
Id = reader.GetInt32("Id"),
|
|
Name = reader.GetString("Name"),
|
|
InvNumber = reader.GetString("InvNumber"),
|
|
Date = reader.GetDateOnly("PurchaseDate"),
|
|
Cost = reader.GetDecimal("Cost"),
|
|
IsWrittenOff = reader.GetBoolean("IsWrittenOff"),
|
|
CurrentEmployeeId = reader.GetInt32("CurrentEmployeeId")
|
|
};
|
|
result.Add(equipment);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine(e);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public override Equipment? GetById(int id)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override bool Delete(int id)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override bool Update(Equipment item)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public override bool Add(Equipment item)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
} |