コード例 #1
0
        public void BDDScenario_1_1_TestCarCreation(string make,
                                                    string model,
                                                    string engine,
                                                    int doors,
                                                    int wheels,
                                                    CarBodyType bodyType)
        {
            IVehicleFactory <Car, CreateCarCommand> factory = new CarFactory();

            CreateCarCommand createCarCommand = new CreateCarCommand(make,
                                                                     model,
                                                                     engine,
                                                                     doors,
                                                                     wheels,
                                                                     bodyType);

            Car car = factory.Create(createCarCommand);

            Assert.NotNull(car);
            Assert.Equal(make, car.Make);
            Assert.Equal(model, car.Model);
            Assert.Equal(engine, car.Engine);
            Assert.Equal(doors, car.Doors);
            Assert.Equal(wheels, car.Wheels);
            Assert.Equal(bodyType, car.BodyType);
        }
コード例 #2
0
ファイル: HW1.cs プロジェクト: chervonuj/test1
 public Car(int year, string name, int price, CarBodyType type)
 {
     Year     = year;
     Name     = name;
     Price    = price;
     BodyType = type;
 }
コード例 #3
0
 protected override ValidationResult IsValid(object bodyType, ValidationContext validationContext)
 {
     if (CarBodyType.ToArray().Contains(bodyType))
     {
         return(ValidationResult.Success);
     }
     else
     {
         return(new ValidationResult("Invalid car body type"));
     }
 }
コード例 #4
0
 public bool Save(CarBodyType obj, ref string message)
 {
     if (obj.TypeId == 0)
     {
         return(Add(obj, ref message));
     }
     else
     {
         return(Update(obj.TypeId, obj));
     }
 }
コード例 #5
0
 public CarBodyTypeViewModel CopyFields(CarBodyType from, CarBodyTypeViewModel to)
 {
     if (to == null)
     {
         throw new NullReferenceException();
     }
     if (from == null)
     {
         throw new NullReferenceException();
     }
     to.Id   = from.Id;
     to.Name = from.Name;
     return(to);
 }
コード例 #6
0
 public CreateCarCommand(string make,
                         string model,
                         string engine,
                         int doors,
                         int wheels,
                         CarBodyType bodyType)
 {
     this.Make     = make;
     this.Model    = model;
     this.Engine   = engine;
     this.Doors    = doors;
     this.Wheels   = wheels;
     this.BodyType = bodyType;
 }
コード例 #7
0
 private Car(string make,
             string model,
             string engine,
             int doors,
             int wheels,
             CarBodyType bodyType) : this()
 {
     this.Make     = make;
     this.Model    = model;
     this.Engine   = engine;
     this.Doors    = doors;
     this.Wheels   = wheels;
     this.BodyType = bodyType;
 }
コード例 #8
0
        private bool Update(long Id, CarBodyType obj)
        {
            bool state = false;

            var objEx = _uow.BodyTypes.Get(Id);

            objEx        = obj;
            objEx.TypeId = (int)Id;
            _uow.BodyTypes.Update(Id, objEx);
            int result = _uow.Complete();

            if (result > 0)
            {
                state = true;
            }
            return(state);
        }
コード例 #9
0
        private bool Add(CarBodyType obj, ref string message)
        {
            bool state = false;

            // Check if there is an existing name
            if (!_uow.BodyTypes.IsExists(obj))
            {
                _uow.BodyTypes.Add(obj);
                int result = _uow.Complete();
                if (result > 0)
                {
                    state = true;
                }
            }
            else
            {
                message = "Data Exists!";
            }

            return(state);
        }
コード例 #10
0
        public async Task <IActionResult> AddCarBodyType(string name)
        {
            if (!String.IsNullOrEmpty(name))
            {
                try
                {
                    var carBody = new CarBodyType
                    {
                        Name = name,
                    };

                    await _dbContext.CarBodyTypes.AddAsync(carBody);

                    await _dbContext.SaveChangesAsync();

                    return(Json(carBody));
                }
                catch (Exception)
                {
                    return(Json("fail"));
                }
            }
            return(Json("fail"));
        }
コード例 #11
0
 public Porsche(CarBodyType type) : base(type)
 {
 }
コード例 #12
0
 public Car(string model, string make, CarBodyType type, int price, int year, int mile, double size, string des,
            string color, string socure, string img) : base(model, make, price, year, mile, size, des, color, socure, img)
 {
     BodyType = type;
 }
コード例 #13
0
 public Ducati(CarBodyType type) : base(type)
 {
 }
コード例 #14
0
 public bool Remove(CarBodyType obj)
 {
     throw new NotImplementedException();
 }
コード例 #15
0
 public Etron(CarBodyType type) : base(type)
 {
 }
コード例 #16
0
 public Bentley(CarBodyType type) : base(type)
 {
 }
コード例 #17
0
 public IActionResult GetBodyTypes()
 {
     return(Ok(CarBodyType.ToArray()));
 }
コード例 #18
0
 public Car(string make, string model, decimal price, int year, string color, decimal mileage, string description, BitmapImage image, CarBodyType bodyType) : base(make, model, price, year, color, mileage, description, image)
 {
     this.bodyType = bodyType;
 }
コード例 #19
0
 public PorscheMacan(CarBodyType type) : base(type)
 {
 }
コード例 #20
0
 public AudiRS5(CarBodyType type) : base(type)
 {
 }
コード例 #21
0
 public VolkswagenGroup(CarBodyType type)
 {
     this.bodyType = type;
 }
コード例 #22
0
 public Bugatti(CarBodyType type) : base(type)
 {
 }