コード例 #1
0
 public FastCar(CarColor color) : base(color)
 {
     Pieces      = new List <Piece>();
     Speed       = Config.FAST_CAR_SPEED;
     SpecialProb = Config.FAST_CAR_SPECIAL_PROB;
     InitPieces();
 }
コード例 #2
0
 public CarEntity(CarId id, string make, string model, string no, CarColor color = CarColor.White) : base(id)
 {
     Make  = make;
     Model = model;
     No    = no;
     Color = color;
 }
コード例 #3
0
        public async Task <IActionResult> AddCarPost(CarsDTO model)
        {
            var client = _httpClientFactory.CreateClient(Constants.ClientWithToken);

            model.Color     = model.Colors.ToString();
            model.Status    = model.Statuses.ToString();
            model.Condition = model.Conditions.ToString();

            CarColor col = StringToEnumConverter.ParseEnum <CarColor>("Ash");

            var response = await client.PostAsJsonAsync <CarsDTO, bool>(Constants.Routes.AddCar, model);

            var items = response.Object;

            if (response.ValidationErrors.Count > 0)
            {
                TempData["error"] = "An Error Occurred " + response.Code + ": " + response.ShortDescription;
                return(View("AddNewCar", model));
                //return RedirectToAction("AddNewCar");
            }
            else
            {
                //return View("AddNewCar", model);
                return(RedirectToAction("GetAllCars"));
            }
        }
コード例 #4
0
 //metode der tjekker om bilens farve bliver sat.
 public void TjekCarColor(CarColor c)
 {
     if (c != CarColor.Black)
     {
         throw new ArgumentOutOfRangeException("METHOD: Bilens farve skal være enten: Black, White, Gray, Red, Green eller Blue.");
     }
     //else if (c != CarColor.Blue)
     //{
     //    throw new ArgumentOutOfRangeException("Bilens farve skal være enten: Black, White, Gray, Red, Green eller Blue.");
     //}
     //else if (c != CarColor.Gray)
     //{
     //    throw new ArgumentOutOfRangeException("Bilens farve skal være enten: Black, White, Gray, Red, Green eller Blue.");
     //}
     //else if (c != CarColor.Green)
     //{
     //    throw new ArgumentOutOfRangeException("Bilens farve skal være enten: Black, White, Gray, Red, Green eller Blue.");
     //}
     //else if (c != CarColor.Red)
     //{
     //    throw new ArgumentOutOfRangeException("Bilens farve skal være enten: Black, White, Gray, Red, Green eller Blue.");
     //}
     //else if (c != CarColor.White)
     //{
     //    throw new ArgumentOutOfRangeException("Bilens farve skal være enten: Black, White, Gray, Red, Green eller Blue.");
     //}
     else
     {
         this.Color = c;
     }
 }
コード例 #5
0
        static void Main(string[] args)
        {
            CarColor car1 = CarColor.Blue;

            PaintCar(car1);



            int solution;

            DoubleIt(15, out solution);

            System.Console.WriteLine(solution);

            int num1 = 10;
            int num2 = 20;

            System.Console.WriteLine("Before Swap num1: {0}, num2 {1}", num1, num2);
            Swap(ref num1, ref num2);
            System.Console.WriteLine("After Swap num1: {0}, num2 {1}", num1, num2);

            System.Console.WriteLine("1, 2, 3 = {0}", GetSumMore(1, 2, 3));

            PrintInfo(zipCode: 15137, name: "Joel");

            System.Console.WriteLine("5.0 + 4.5 = {0}", GetSum(5.0, 4.5));
            System.Console.WriteLine("5.0 + 4.5 = {0}", GetSum("5.0", "4.5"));
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: ryanpierson87/C-Lessons
        public static void Main(string[] args)
        {
            //PrintInfo(zipCode: 15147, name: "Derek");
            CarColor car1 = CarColor.Blue;

            PaintCar(car1);
        }
コード例 #7
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            double x = 5;
            double y = 4;

            Console.WriteLine("{0} + {1} = {2}", x, y, Suma(x, y));
            int sol;

            dubleaza(15, out sol);
            Console.WriteLine("15 * 2 = {0}", sol);
            int a = 1;
            int b = 2;

            Console.WriteLine("a = {0}   b = {1} \n dupa :", a, b);
            Swap(ref a, ref b);
            Console.WriteLine("a = {0}   b = {1}", a, b);
            Console.WriteLine(" 1 + 2 +..+ 7 = {0}", S_n(1, 2, 3, 4, 5, 6, 7));
            printI(zipCode: 15212, name: "AXL");
            Console.WriteLine("1 + 2 = {0}", Suma("1", "2"));

            CarColor car1 = CarColor.Blue;

            PaintCar(car1);
            Console.ReadLine();
        }
コード例 #8
0
        public CarDesignArr GetDesigns()
        {
            CarColor   carColor   = null;
            ColorType  colorTypes = null;
            BodyDesign bodyDesign = null;

            CarDesignArr carDesignArr = new CarDesignArr();

            carDesignArr.Fill();

            if (cmb_Color.SelectedIndex != -1)
            {
                carColor = cmb_Color.SelectedItem as CarColor;
            }
            if (cmb_ColorType.SelectedIndex != -1)
            {
                colorTypes = cmb_ColorType.SelectedItem as ColorType;
            }
            if (cmb_Body.SelectedIndex != -1)
            {
                bodyDesign = cmb_Body.SelectedItem as BodyDesign;
            }

            return(carDesignArr.Filter(carColor, colorTypes, bodyDesign));
        }
コード例 #9
0
        public override void CheckAndUpdateInformation(string i_InputToCheck, int i_MemberIndex)
        {
            int firstCarMember = (int)Enum.GetValues(typeof(eCarMembers)).Cast <eCarMembers>().First();

            if (i_MemberIndex < firstCarMember)
            {
                CheckAndUpdateVehicleInformation(i_InputToCheck, i_MemberIndex);
            }
            else
            {
                eCarMembers memberToCheck = (eCarMembers)i_MemberIndex;
                switch (memberToCheck)
                {
                case eCarMembers.CarColor:
                {
                    m_CarColor = CarColor.ParseFromString(i_InputToCheck);
                    break;
                }

                case eCarMembers.NumOfCarDoors:
                {
                    m_NumOfCarDoors = NumOfCarDoors.ParseFromString(i_InputToCheck);
                    break;
                }
                }
            }
        }
コード例 #10
0
ファイル: PRODRepository.cs プロジェクト: dtalon42/Portfolio
        public List <CarColor> GetCarColor()
        {
            List <CarColor> carColors = new List <CarColor>();

            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
                SqlCommand cmd = new SqlCommand();

                cmd.Connection  = conn;
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.CommandText = "GetColor";


                conn.Open();
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        CarColor currentRow = new CarColor();

                        currentRow.color_ID = (int)dr["color_ID"];
                        currentRow.color    = dr["color"].ToString();

                        carColors.Add(currentRow);
                    }
                }
            }
            return(carColors);
        }
コード例 #11
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Red,Green,Blue")] CarColor carColor)
        {
            if (id != carColor.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(carColor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CarColorExists(carColor.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(carColor));
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: Holofiber/DerekBanas
        static void Main(string[] args)
        {
            double x = 5;
            double y = 4;

            Console.WriteLine("5+4={0}", GetSum(x, y));
            Console.WriteLine("x " + x);

            int solution;

            Doublelt(15, out solution);
            Console.WriteLine("15 * 2 = {0}", solution);

            int num1 = 10;
            int num2 = 20;

            Console.WriteLine("Before Swap num1 : {0} num2 :{1}", num1, num2);
            Swap(ref num1, ref num2);
            Console.WriteLine("After Swap num1 : {0} num2 :{1}", num1, num2);

            Console.WriteLine("1+2+3={0}", GetSumeMore(1, 2, 3));

            PrintInfo(zipCode: 15147, name: "Derek");

            Console.WriteLine("5.0 + 4.5 = {0}", GetSum(5.0, 4.5));

            Console.WriteLine("5.0 + 4.5 = {0}", GetSum("5,0", "4,5"));

            CarColor car1 = CarColor.Red;

            PaintCar(car1);

            Console.ReadLine();
        }
コード例 #13
0
 /// <summary>
 /// Her sætter vi vores contructor
 /// </summary>
 /// <param name="color"></param>
 /// <param name="doors"></param>
 /// <param name="model"></param>
 /// <param name="regrNr"></param>
 public Car(CarColor color, int doors, string model, string regrNr)
 {
     Color  = color;
     Doors  = doors;
     Model  = model;
     RegrNr = regrNr;
 }
コード例 #14
0
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            CarColor carColor = FormToCarColor();

            CarDesignArr carDesignArr = new CarDesignArr();

            carDesignArr.Fill();

            if (carColor.Id == 0)
            {
            }
            else
            {
                if (carDesignArr.DoesExist(carColor))
                {
                    MessageBox.Show("You can not delete this Car color, it is connected" +
                                    " to 1 or more Orders", "Can not delete Car color",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (MessageBox.Show("Are you sure you want to delete this" +
                                        " Car color? ", "Warning", MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        carColor.Delete();
                        ClearForm();
                        CarColorArrToForm(null);
                    }
                }
            }
        }
コード例 #15
0
 //Car-klassens Constructor
 public Car(int d, string m, string r, CarColor c)
 {
     this.Doors          = d;
     this.Model          = m;
     this.RegistrationNo = r;
     this.Color          = c;
 }
コード例 #16
0
        public Resp_Binary Modify(CarColor model)
        {
            if (model.IsNull())
            {
                return new Resp_Binary {
                           message = "请选择要操作的记录"
                }
            }
            ;

            var record = _carColorRepository.GetById(model.ID);

            if (record.IsNull())
            {
                return new Resp_Binary {
                           message = "未找到记录信息,请刷新页面"
                }
            }
            ;

            record.Name = model.Name;

            _carColorRepository.Update(record);
            if (_carColorRepository.UnitOfWork.Commite() > 0)
            {
                return(Resp_Binary.Modify_Sucess);
            }

            return(Resp_Binary.Modify_Failed);
        }
コード例 #17
0
        static void Main(string[] args)
        {
            //PASSING BY VALUE
            float x = 5f;
            float y = 4f;

            Swap(x, y);

            Console.WriteLine("You can see that they are still not swapped here\n" +
                              "x = {0}\ny = {1}", x, y);

            //by default, c# is pass by value
            //it can be changed explicitly using "ref"

            Swap(ref x, ref y);

            Console.WriteLine("You can see that they are SWAPPED here\n" +
                              "x = {0}\ny = {1}", x, y);

            //swap back for next experiment
            Swap(ref x, ref y);

            //if using default, it can be swapped using "out".
            //See the method below to know how

            float nX = 0, nY = 0;

            Swap(x, y, out nX, out nY);

            x = nX;
            y = nY;

            Console.WriteLine("You can see that they are SWAPPED AGAIN here\n" +
                              "x = {0}\ny = {1}", x, y);

            Console.WriteLine();
            Console.WriteLine("x : 5 + y : 4 = {0}", GetSum(x, y));

            //OUT PARAMETER
            Console.WriteLine();

            float doubled;
            bool  flag = DoubleTrouble(2, out doubled);

            Console.WriteLine("var : 5 * 2 = {0} -> flag {1}", doubled, flag);

            //PARAMS
            Console.WriteLine();
            Console.WriteLine("GetSumMore: {0}", GetSumMore(1, 2, 3));

            //ENUMS
            Console.WriteLine();

            CarColor car1 = CarColor.Orange;

            PaintCar(car1);

            Console.ReadLine();
        }
コード例 #18
0
        public ActionResult DeleteConfirmed(int idCar, int idColor)
        {
            CarColor carColor = db.CarColors.Find(idCar, idColor);

            db.CarColors.Remove(carColor);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #19
0
 public void Delete(CarColor entity)
 {
     using (carcontext context = new carcontext())
     {
         var addedColor = context.Entry(entity);
         addedColor.State = EntityState.Deleted;
     }
 }
コード例 #20
0
 public CarModel(CarManufacturer carManufacturer, CarName carName, CarColor carColor, int carConstructionYear)
 {
     this.carType             = CarType.Auto;
     this.carManufacturer     = carManufacturer;
     this.carName             = carName;
     this.carColor            = carColor;
     this.CarConstructionYear = carConstructionYear;
 }
コード例 #21
0
 public CarSetEvent(CarId carId, string make, string model, string no, CarColor color = CarColor.White)
 {
     CarId = carId;
     Make  = make;
     Model = model;
     No    = no;
     Color = color;
 }
コード例 #22
0
        public override string ToString()
        {
            StringBuilder carStr = new StringBuilder(base.ToString());

            carStr.AppendLine(string.Format("Color: {0}", CarColor.ToString()));
            carStr.AppendLine(string.Format("Number of doors: {0}", NumOfDoors.ToString()));
            return(carStr.ToString());
        }
コード例 #23
0
 public static ColorReadModel ToReadModel(this CarColor color)
 {
     return(new ColorReadModel()
     {
         Color = color.Color,
         Id = color.Id
     });
 }
コード例 #24
0
 public void Update(CarColor entity)
 {
     using (carcontext context = new carcontext())
     {
         var updatedColor = context.Entry(entity);
         updatedColor.State = EntityState.Modified;
         context.SaveChanges();
     }
 }
コード例 #25
0
 public AbstractCar(CarColor color, string regNumber, string number, string model,
                    int year)
 {
     this.color = color;
     this.registrationNumber = regNumber;
     this.number             = number;
     this.year  = year;
     this.model = model;
 }
コード例 #26
0
 public void Add(CarColor entity)
 {
     using (carcontext context = new carcontext())
     {
         var addedColor = context.Entry(entity);
         addedColor.State = EntityState.Added;
         context.SaveChanges();
     }
 }
コード例 #27
0
 public void Delete(CarColor entity)
 {
     using (CarRentalContext context = new CarRentalContext())
     {
         var deletedCarColor = context.Entry(entity);
         deletedCarColor.State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
コード例 #28
0
        static void Main(string[] args)
        {
            // ----- PASSING BY VALUE -----
            double x = 5;
            double y = 4;

            Console.WriteLine("5 + 4 = {0}", GetSum(x, y));

            // Even though the value for x changed in the method
            // it remains unchanged here
            Console.WriteLine("x = {0}", x);

            // ----- OUT PARAMETER -----
            // You can pass a variable as an output variable even without assigning a value to it
            int solution;

            // A parameter passed with "out" has its value assigned in the method
            DoubleIt(15, out solution);

            Console.WriteLine("15 * 2 = {0}", solution);

            // ----- PASS BY REFERENCE -----
            int num1 = 10;
            int num2 = 20;

            Console.WriteLine("Before Swap num1 : {0} num2 : {1}", num1, num2);

            Swap(ref num1, ref num2);

            Console.WriteLine("After Swap num1 : {0} num2 : {1}", num1, num2);

            // ----- PARAMS -----
            // You are able to pass a variable amount of data of the same data type
            // into a method using params.
            // You can also pass in an array
            Console.WriteLine("1 + 2 + 3 = {0}", GetSumMore(1, 2, 3));

            // ----- NAMED PARAMETERS -----
            // You can pass values in any order if you used named parameters
            PrintInfo(zipCode: 15147, name: "Made Up");

            // ----- METHOD OVERLOADING -----
            // You can define methods with the same name that will be called
            // depending on what data is sent automatically
            Console.WriteLine("5.0 + 4.0 = {0}", GetSum(5.0, 4.0));

            Console.WriteLine("5 + 4 = {0}", GetSum(5, 4));

            Console.WriteLine("5 + 4 = {0}", GetSum("5", "4"));

            // ----- ENUM -----
            CarColor car1 = CarColor.Blue;

            PaintCar(car1);

            Console.ReadLine();
        }
コード例 #29
0
 public Car NewCar(string brand, string model, DateTime plateDate, CarColor color = CarColor.Black)
 {
     return(new Car
     {
         Brand = brand,
         Model = model,
         PlateDate = plateDate,
         Color = color
     });
 }
コード例 #30
0
        public IActionResult Delete(CarColor color)
        {
            var result = _colorService.Delete(color);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
コード例 #31
0
 public Car(
     string modelName, 
     float engineDisplacement, 
     DateTime manufactured, 
     CarColor carColor, 
     decimal price)
 {
     _modelName = modelName;
     _engineDisplacement = engineDisplacement;
     _manufactured = manufactured;
     _carColor = carColor;
     _price = price;
 }
コード例 #32
0
ファイル: MiniVan.cs プロジェクト: rojac07/COM
 public MiniVan(string name, CarColor color, int sp)
     : base(name, color, sp)
 {
 }
コード例 #33
0
ファイル: GamePark.cs プロジェクト: jojozhuang/Projects
 private string GetCarColor(CarColor color)
 {
     switch (color)
     {
         case CarColor.Black:
             return "黑色";
         case CarColor.Blue:
             return "蓝色";
         case CarColor.Red:
             return "红色";
         case CarColor.Silver:
             return "银色";
         case CarColor.White:
             return "白色";
         case CarColor.Yellow:
             return "黄色";
         default:
             return "未知色";
     }
 }
コード例 #34
0
ファイル: Car.cs プロジェクト: rojac07/COM
 public Car(string name, CarColor color)
     : this(name, color, 0)
 {
 }
コード例 #35
0
ファイル: Car.cs プロジェクト: rojac07/COM
 public Car(string name, CarColor color, int sp)
 {
     mPetName = name;
     mCarColor = color;
     mCurrSpeed = sp;
 }
コード例 #36
0
ファイル: MiniVan.cs プロジェクト: rojac07/COM
 public MiniVan(string name, CarColor color)
     : base(name, color)
 {
 }
コード例 #37
0
ファイル: HotRod.cs プロジェクト: rojac07/COM
 public HotRod(string name, CarColor color)
     : base(name, color)
 {
 }
コード例 #38
0
ファイル: Car.cs プロジェクト: denjai/TU-Plovdiv
 public Car(CarModel model, CarColor clr, string reg, Owner owner)
     : this(model, clr, reg)
 {
     this.owner = new Owner(owner);
 }
コード例 #39
0
ファイル: Car.cs プロジェクト: denjai/TU-Plovdiv
 public Car(CarModel model, CarColor clr, string reg)
 {
     this.color = clr;
     this.model = model;
     this.regNumber = reg;
 }
コード例 #40
0
ファイル: HotRod.cs プロジェクト: rojac07/COM
 public HotRod(string name, CarColor color, int sp)
     : base(name, color, sp)
 {
 }