public Client getClient(int? id) { var c = dc.Clients.Include("Banks").FirstOrDefault(i => i.Id == id); if (c != null) { Client vc = new Client(); vc.Id = c.Id; vc.FirstName = c.FirstName; vc.LastName = c.LastName; vc.AccountNumber = c.AccountNumber; var lbs = new List<Bank>(); foreach (var item in c.Banks) { Bank b = new Bank(); b.Id = item.Id; b.Name = item.Name; b.Code = item.Code; lbs.Add(b); } vc.Banks = lbs; return vc; } return null; }
public Bank getBank(int? id) { var c = dc.Banks.FirstOrDefault(i => i.Id == id); if (c != null) { Bank vc = new Bank(); vc.Id = c.Id; vc.Name = c.Name; vc.Code = c.Code; return vc; } return null; }
public Bank createBank(BankCreateForHttpPost cp) { var c = new Bank(); c.Id = dc.Banks.Max(n => n.Id) + 1; c.Name = cp.Name; c.Code = cp.Code; dc.Banks.Add(c); dc.SaveChanges(); return getBank(c.Id); }
public List<Bank> getListOfBanks() { var cs = dc.Banks.OrderBy(n => n.Id); List<Bank> lb = new List<Bank>(); foreach (var item in cs) { Bank cn = new Bank(); cn.Id = item.Id; cn.Name = item.Name; cn.Code = item.Code; lb.Add(cn); } return lb; }