コード例 #1
0
        public static String commerce()
        {
            UpdatedCar newCar = Access.sHttp.getPostData().DeserializeObject <CommerceSessionTrans>().updatedCar;
            CommerceSessionResultTrans commerceSessionResultTrans = new CommerceSessionResultTrans();
            UpdatedCar responseCar = new UpdatedCar();

            using (var session = SessionManager.getSessionFactory().OpenSession())
                using (var transaction = session.BeginTransaction())
                {
                    CarEntity carEntity = session.Load <CarEntity>(Access.CurrentSession.ActivePersona.SelectedCar.Id);
                    carEntity.vinyls           = newCar.customCar.vinyls;
                    carEntity.paints           = newCar.customCar.paints;
                    carEntity.performanceParts = newCar.customCar.performanceParts;
                    carEntity.skillModParts    = newCar.customCar.skillModParts;
                    carEntity.visualParts      = newCar.customCar.visualParts;
                    carEntity.heatLevel        = 1;

                    responseCar.customCar     = CustomCar.getCustomCar(carEntity);
                    responseCar.durability    = carEntity.durability;
                    responseCar.heatLevel     = 1;
                    responseCar.id            = carEntity.id;
                    responseCar.ownershipType = "CustomizedCar";

                    session.Update(carEntity);
                    transaction.Commit();
                }

            commerceSessionResultTrans.updatedCar = responseCar;
            return(commerceSessionResultTrans.SerializeObject());
        }
コード例 #2
0
        static void Main(string[] args)
        {
            FamilyCar familyCar = new FamilyCar();
            SuperCar  superCar  = new SuperCar();
            NormalCar normalCar = new NormalCar();

            List <Car> cars = new List <Car>
            {
                normalCar, familyCar, superCar
            };

            foreach (var car in cars)
            {
                car.Display();
                car.Ride();
                car.Brake();
                car.Park();
                Console.WriteLine();
            }

            CustomCar customCar = new CustomCar();

            customCar.Display();
            customCar.Ride();
            customCar.Brake();
            customCar.SetParkBehavior(new Behavior.Park.SelfPark());
            customCar.Park();

            Console.ReadKey();
        }
コード例 #3
0
        public static CustomCar getCustomCar(this CarEntity carEntity)
        {
            CustomCar customCar = new CustomCar();

            customCar.baseCarId          = carEntity.baseCarId;
            customCar.carClassHash       = carEntity.carClassHash;
            customCar.id                 = carEntity.id;
            customCar.name               = carEntity.name;
            customCar.paints             = carEntity.paints.DeserializeObject <List <CustomPaintTrans> >();
            customCar.performanceParts   = carEntity.performanceParts.DeserializeObject <List <PerformancePartTrans> >();
            customCar.physicsProfileHash = carEntity.physicsProfileHash;
            customCar.rating             = carEntity.rating;
            customCar.resalePrice        = carEntity.resalePrice;
            customCar.skillModParts      = carEntity.skillModParts.DeserializeObject <List <SkillModPartTrans> >();
            customCar.vinyls             = carEntity.vinyls.DeserializeObject <List <CustomVinylTrans> >();
            customCar.visualParts        = carEntity.visualParts.DeserializeObject <List <VisualPartTrans> >();

            return(customCar);
        }
コード例 #4
0
ファイル: CarDonateCommand.cs プロジェクト: Fooxboy/HydraBot
        public static string CreateCar(string name, User user)
        {
            if (user.DonateMoney < 30)
            {
                return("❌ У Вас недостаточно донат рублей.");
            }
            using (var db = new Database())
            {
                var usr = db.Users.Single(u => u.Id == user.Id);
                usr.DonateMoney -= 30;

                var car = new CustomCar();
                car.Id         = db.CustomCars.Count() + 1;
                car.Name       = name;
                car.IsModerate = true;
                car.UserId     = user.Id;
                db.CustomCars.Add(car);
                db.SaveChanges();
            }

            return("🏎 Ваш автомобиль отправлен на модерацию, Вы получите уведомление, если Ваш авто примут.");
        }