예제 #1
0
        protected override byte[] GetItems()
        {
            using (var rep = new CarRep())
            {
                var conv = new ModelsForWpf.Converter <List <ModelsForWpf.Car> >();
                var lst  = new List <ModelsForWpf.Car>();
                foreach (var u in rep.GetItems())
                {
                    lst.Add(Converter.ToCar(u));
                }

                return(conv.ObjectToByteArray(lst));
            }
        }
예제 #2
0
        protected override async Task Create(byte[] item)
        {
            using (var uc = new UserCarRep())
                using (var rep = new CarRep())
                {
                    var conv = new ModelsForWpf.Converter <ModelsForWpf.Car>();
                    var temp = conv.ByteArrayToObject(item);
                    var us   = new Car(temp);
                    await rep.Create(us);

                    await rep.Save();

                    foreach (var c in rep.GetItems())
                    {
                        if (c.RegNum == us.RegNum)
                        {
                            await uc.Create(new UserCars(0, temp.Owner.Id, c.Id));
                        }
                    }
                }
        }