예제 #1
0
 protected override byte[] GetItem(byte[] id)
 {
     using (var rep = new CarRep())
     {
         var conv = new ModelsForWpf.Converter <ModelsForWpf.Car>();
         var us   = new Car(conv.ByteArrayToObject(id));
         return(conv.ObjectToByteArray(Converter.ToCar(rep.GetItem(us.Id))));
     }
 }
예제 #2
0
        static public ModelsForWpf.Talon ToTalon(Talon talon)
        {
            var ret = new ModelsForWpf.Talon(talon.Id, talon.One, talon.Two, null, null);

            using (var rep = new CarRep())
                ret.Car = ToCar(rep.GetItem(talon?.Car_Id ?? -1));
            using (var rep = new SlotRep())
                ret.Slot = ToSlot(rep.GetItem(talon?.Slot_Id ?? -1));

            return(ret);
        }
예제 #3
0
        static public ModelsForWpf.User ToUser(User user)
        {
            var ret = new ModelsForWpf.User();

            ret.Id       = user.Id;
            ret.IsAdmin  = user.IsAdmin;
            ret.PhoneNum = user.PhoneNum;
            ret.Password = user.Password;
            ret.Login    = user.Login;
            ret.FullName = user.FullName;
            ret.Cars     = new List <ModelsForWpf.Car>();
            using (var userCarRep = new UserCarRep())
                using (var carRep = new CarRep())
                {
                    foreach (var uc in userCarRep.GetItems())
                    {
                        if (uc.Owner_Id == ret.Id)
                        {
                            ret.Cars.Add(ToCar(carRep.GetItem(uc.Car_Id), ret));
                        }
                    }
                }
            return(ret);
        }