public void UpdateBikeTest()
        {
            UpdateBikeInfo update = new UpdateBikeInfo
            {
                Manufacturer = "ABC"
            };
            Tandem bike = tandemService.UpdateBike(1, update);

            Assert.IsTrue(bike.Manufacturer == "ABC");
        }
        public void UpdateBikeTest()
        {
            UpdateBikeInfo update = new UpdateBikeInfo()
            {
                Manufacturer = "A"
            };
            ElectricBike bike = electricBikeService.UpdateBike(1, update);

            Assert.IsTrue(bike.Manufacturer == "A");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Update bike information
        /// </summary>
        /// <param name="bikeId">The bike id</param>
        /// <param name="update">The update information</param>
        /// <returns>The bike information after updated</returns>
        public BaseBike UpdateBike(int bikeId, UpdateBikeInfo update)
        {
            BaseBike bike = connecter.SqlData.BaseBikes.Find(bikeId);

            bike.UpdateBike(update);
            int check = connecter.SqlData.SaveChanges();

            bike = connecter.SqlData.BaseBikes.Find(bikeId);
            if (check > 0)
            {
                return(bike);
            }
            return(null);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Update bike information
        /// </summary>
        /// <param name="bikeId">The bike id</param>
        /// <param name="update">The update information</param>
        /// <returns>The bike information after updated</returns>
        public Tandem UpdateBike(int bikeId, UpdateBikeInfo update)
        {
            Tandem bike = connecter.SqlData.Tandems.Find(bikeId);

            if (update.StationId > 0)
            {
                bike.StationId = update.StationId;
            }
            if (update.Value > 0)
            {
                bike.Value = update.Value;
            }
            if (update.QRCode != null)
            {
                bike.QRCode = update.QRCode;
            }
            if (update.Manufacturer != null)
            {
                bike.Manufacturer = update.Manufacturer;
            }
            if (update.BikeStatus > 0)
            {
                bike.BikeStatus = true;
            }
            if (update.BikeStatus < 0)
            {
                bike.BikeStatus = false;
            }
            int check = connecter.SqlData.SaveChanges();

            bike = connecter.SqlData.Tandems.Find(bikeId);
            if (check > 0)
            {
                return(bike);
            }
            return(null);
        }