示例#1
0
        protected override async Task Update(byte[] item)
        {
            using (var rep = new CarRep())
            {
                var conv = new ModelsForWpf.Converter <ModelsForWpf.Car>();
                var us   = new Car(conv.ByteArrayToObject(item));
                await rep.Update(us);

                await rep.Save();
            }
        }
示例#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));
                        }
                    }
                }
        }