init
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using Kreta.BusinessLogic.HelperClasses;
|
||||
using Kreta.Core.ConnectionType;
|
||||
using Kreta.DataAccessManual;
|
||||
|
||||
namespace Kreta.BusinessLogic.Helpers
|
||||
{
|
||||
public class TelepulesHelper : LogicBase
|
||||
{
|
||||
public TelepulesHelper(IConnectionType connectionType) : base(connectionType) { }
|
||||
|
||||
public List<TelepulesListCO> GetTelepulesek()
|
||||
{
|
||||
return Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
{
|
||||
var dal = h.TelepulesDal();
|
||||
var ds = dal.GetSzuletesiHelysegNevData();
|
||||
|
||||
List<TelepulesListCO> list =
|
||||
(from telepules in ds.Tables[0].AsEnumerable()
|
||||
orderby telepules.Field<string>("TELEPULESNEV")
|
||||
select new TelepulesListCO
|
||||
{
|
||||
TelepulesNev = telepules.Field<string>("TELEPULESNEV"),
|
||||
Id = telepules.Field<int>("ID")
|
||||
}).ToList();
|
||||
|
||||
return list;
|
||||
});
|
||||
}
|
||||
|
||||
public List<TelepulesListCO> GetSzuletesiHelysegNevList()
|
||||
{
|
||||
return Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
{
|
||||
var dal = h.TelepulesDal();
|
||||
var ds = dal.GetSzuletesiHelysegNevData();
|
||||
|
||||
var list = new List<TelepulesListCO>();
|
||||
foreach (DataRow row in ds.Tables[0].Rows)
|
||||
{
|
||||
var co = new TelepulesListCO
|
||||
{
|
||||
TelepulesNev = row["TELEPULESNEV"].ToString()
|
||||
};
|
||||
|
||||
list.Add(co);
|
||||
}
|
||||
|
||||
//NOTE: Az adatszótárból Budapest többször fel van sorolva az összes kerülettel, ezért kiszedjük mindet,
|
||||
// mert a születési helynél nem tüntetünk fel kerületet. és simán kerület nélkül beszúrjuk az első helye.
|
||||
list.RemoveAll(x => x.TelepulesNev.Contains("Budapest"));
|
||||
list.Insert(0, new TelepulesListCO { TelepulesNev = "Budapest" });
|
||||
|
||||
return list;
|
||||
});
|
||||
}
|
||||
|
||||
public List<IranyitoszamListCO> GetIranyitoszamok(string iranyitoszam)
|
||||
{
|
||||
return Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
{
|
||||
var dal = h.TelepulesDal();
|
||||
var ds = dal.GetIranyitoszamok(iranyitoszam);
|
||||
|
||||
var list = new List<IranyitoszamListCO>();
|
||||
foreach (DataRow row in ds.Tables[0].Rows)
|
||||
{
|
||||
var co = new IranyitoszamListCO()
|
||||
{
|
||||
Iranyitoszam = row["IRANYITOSZAM"].ToString()
|
||||
};
|
||||
|
||||
list.Add(co);
|
||||
}
|
||||
|
||||
return list;
|
||||
});
|
||||
}
|
||||
|
||||
public List<TelepulesListCO> GetTelepulesek(string iranyitoszam)
|
||||
{
|
||||
return Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
{
|
||||
var dal = h.TelepulesDal();
|
||||
var ds = dal.GetTelepulesek(iranyitoszam);
|
||||
|
||||
var list = new List<TelepulesListCO>();
|
||||
foreach (string telepulesNev in ds.Tables[0].Rows.Cast<DataRow>().Select(x => x["TELEPULESNEV"].ToString()).Distinct())
|
||||
{
|
||||
var co = new TelepulesListCO
|
||||
{
|
||||
TelepulesNev = telepulesNev
|
||||
};
|
||||
|
||||
list.Add(co);
|
||||
}
|
||||
|
||||
return list;
|
||||
});
|
||||
}
|
||||
|
||||
public List<IranyitoszamTelepulesListCO> GetIranyitoszamokEsTelepulesek()
|
||||
{
|
||||
return Dal.CustomConnection.Run(ConnectionType, h =>
|
||||
{
|
||||
var dal = h.TelepulesDal();
|
||||
var ds = dal.GetTelepulesek(string.Empty);
|
||||
|
||||
var list = new List<IranyitoszamTelepulesListCO>();
|
||||
|
||||
foreach (DataRow row in ds.Tables[0].Rows)
|
||||
{
|
||||
var co = new IranyitoszamTelepulesListCO();
|
||||
co.Iranyitoszam = row["IRANYITOSZAM"].ToString();
|
||||
co.TelepulesNev = row["TELEPULESNEV"].ToString();
|
||||
list.Add(co);
|
||||
}
|
||||
|
||||
return list.OrderBy(e => e.Iranyitoszam).ToList();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user