protected override byte[] GetItem(byte[] id) { using (var rep = new TalonRep()) { var conv = new ModelsForWpf.Converter <ModelsForWpf.Talon>(); var us = new Talon(conv.ByteArrayToObject(id)); return(conv.ObjectToByteArray(Converter.ToTalon(rep.GetItem(us.Id)))); } }
protected override async Task Delete(byte[] id) { using (var rep = new TalonRep()) { var conv = new ModelsForWpf.Converter <ModelsForWpf.Talon>(); var us = new Talon(conv.ByteArrayToObject(id)); await rep.Delete(us.Id); } }
protected override async Task Update(byte[] item) { using (var rep = new TalonRep()) { var conv = new ModelsForWpf.Converter <ModelsForWpf.Talon>(); var us = new Talon(conv.ByteArrayToObject(item)); await rep.Update(us); await rep.Save(); } }
protected override byte[] GetItems() { using (var rep = new TalonRep()) { var conv = new ModelsForWpf.Converter <List <ModelsForWpf.Talon> >(); var lst = new List <ModelsForWpf.Talon>(); foreach (var u in rep.GetItems()) { lst.Add(Converter.ToTalon(u)); } return(conv.ObjectToByteArray(lst)); } }
static public ModelsForWpf.Slot ToSlot(Slot slot, ModelsForWpf.Parking p = null) { var ret = new ModelsForWpf.Slot(slot.Id, new List <ModelsForWpf.Talon>(), slot.XCord, slot.YCord, null); using (var talonRep = new TalonRep()) { foreach (var t in talonRep.GetItems()) { if (t.Slot_Id == ret.Id) { ret.Talons.Add(ToTalon(t)); } } } ret.Parking = p; return(ret); }
static public ModelsForWpf.Car ToCar(Car car, ModelsForWpf.User owner = null) { var ret = new ModelsForWpf.Car(); ret.Id = car.Id; ret.Info = car.Info; ret.RegNum = car.RegNum; ret.Owner = owner; ret.UserTalons = new List <ModelsForWpf.Talon>(); using (var rep = new TalonRep()) { foreach (var t in rep.GetItems()) { if (t.Car_Id == ret.Id) { var talon = ToTalon(t); talon.Car = ret; ret.UserTalons.Add(talon); } } } return(ret); }