コード例 #1
0
 // Deletes selected Bike from the Bike list
 public void DeleteBike(object a)
 {
     if (SelectedBike != null)
     {
         Bikes.Remove(SelectedBike);
     }
     else
     {
         MessageBox.Show("Please select a bike first");
     }
 }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,Number,Name,Address,Latitude,Longitude")] Bikes bikes)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bikes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(bikes));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("ID,Name,Rides")] Bikes bikes)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bikes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(bikes));
        }
コード例 #4
0
        public IHttpActionResult GetBikes(int id)
        {
            Bikes bikes = db.Bikes.Find(id);

            if (bikes == null)
            {
                return(NotFound());
            }

            return(Ok(bikes));
        }
コード例 #5
0
        public async Task <bool> UpdateBike(Bikes bike)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(baseUrl);
                HttpResponseMessage result = await client.PutAsJsonAsync(
                    $"Bikes/{bike.Id}", bike);

                return(result.IsSuccessStatusCode);
            }
        }
コード例 #6
0
        public void Put(int id, [FromBody] Bikes value)
        {
            Bikes bikes = Get(id);

            if (bikes != null)
            {
                bikes.Id    = value.Id;
                bikes.Color = value.Color;
                bikes.Price = value.Price;
                bikes.Gear  = value.Gear;
            }
        }
コード例 #7
0
        public IActionResult CreateBike([FromBody] Bikes bike)
        {
            DataContext db = new DataContext();

            if (bike == null)
            {
                return(BadRequest("Invalid Bike!"));
            }
            db.Bikes.Add(bike);
            db.SaveChanges();
            return(Ok("Bike Created"));
        }
コード例 #8
0
 public IActionResult GetBike(int?id)
 {
     try
     {
         Bikes bike = _context.Bikes.Single(s => s.Id == id);
         return(Json(bike));
     }
     catch (Exception e)
     {
         return(BadRequest("Failed to retrieve bike in data."));
     }
 }
コード例 #9
0
        public async Task <bool> AddBike(Bikes bike)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(baseUrl);

                HttpResponseMessage res = await client.PostAsJsonAsync(
                    "Bikes", bike);

                return(res.IsSuccessStatusCode);
            }
        }
コード例 #10
0
        /// <summary>
        /// Returns true if DetailedAthlete instances are equal
        /// </summary>
        /// <param name="other">Instance of DetailedAthlete to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(DetailedAthlete other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     FollowerCount == other.FollowerCount ||
                     FollowerCount != null &&
                     FollowerCount.Equals(other.FollowerCount)
                     ) &&
                 (
                     FriendCount == other.FriendCount ||
                     FriendCount != null &&
                     FriendCount.Equals(other.FriendCount)
                 ) &&
                 (
                     MeasurementPreference == other.MeasurementPreference ||
                     MeasurementPreference != null &&
                     MeasurementPreference.Equals(other.MeasurementPreference)
                 ) &&
                 (
                     Ftp == other.Ftp ||
                     Ftp != null &&
                     Ftp.Equals(other.Ftp)
                 ) &&
                 (
                     Weight == other.Weight ||
                     Weight != null &&
                     Weight.Equals(other.Weight)
                 ) &&
                 (
                     Clubs == other.Clubs ||
                     Clubs != null &&
                     Clubs.SequenceEqual(other.Clubs)
                 ) &&
                 (
                     Bikes == other.Bikes ||
                     Bikes != null &&
                     Bikes.SequenceEqual(other.Bikes)
                 ) &&
                 (
                     Shoes == other.Shoes ||
                     Shoes != null &&
                     Shoes.SequenceEqual(other.Shoes)
                 ));
        }
コード例 #11
0
 public ActionResult Edit(Bikes bike)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bike).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View(bike));
     }
 }
コード例 #12
0
        public async Task <int> AddBike(Bikes bike)
        {
            if (db != null)
            {
                await db.Bikes.AddAsync(bike);

                await db.SaveChangesAsync();

                return(bike.Id);
            }

            return(0);
        }
コード例 #13
0
 public ActionResult Add(Bikes bike)
 {
     if (ModelState.IsValid)
     {
         db.Bikes.Add(bike);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View());
     }
 }
コード例 #14
0
 public void EditBike(object a)
 {
     if (SelectedBike != null)
     {
         Bikes dbBike = db.Bikes.Local.First(bike => bike.Id == SelectedBike.Id);
         PropertyCopy.Copy(dbBike, SelectedBike);
         db.SaveChanges();
     }
     else
     {
         MessageBox.Show("Er is geen bike gekozen!!!");
     }
 }
コード例 #15
0
        public IHttpActionResult DeleteBikes(int id)
        {
            Bikes bikes = db.Bikes.Find(id);

            if (bikes == null)
            {
                return(NotFound());
            }

            db.Bikes.Remove(bikes);
            db.SaveChanges();

            return(Ok(bikes));
        }
コード例 #16
0
 public IActionResult DeleteBike([FromBody] int?id)
 {
     try
     {
         Bikes bikeToDelete = _context.Bikes.Single(s => s.Id == id);
         _context.Bikes.Remove(bikeToDelete);
         _context.SaveChangesAsync();
     }
     catch (Exception e)
     {
         return(BadRequest("Failed to remove bike."));
     }
     return(Ok("Delete Success"));
 }
コード例 #17
0
        // Show details for individual Bike
        public ActionResult Show(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Bikes Bike = db.Bikes.SqlQuery("select * from Bikes where BikeID=@BikeID", new SqlParameter("@BikeID", id)).FirstOrDefault();

            if (Bike == null)
            {
                return(HttpNotFound());
            }
            return(View(Bike));
        }
コード例 #18
0
ファイル: FlowContext.cs プロジェクト: lulzzz/Kakegurui
 /// <summary>
 /// 根据时间级别获取数据源和表名
 /// </summary>
 /// <param name="type">视频结构化数据类型</param>
 /// <returns>第一个参数表示数据源,第二个参数表示是否接收分表,null表示不分表</returns>
 public Tuple <IQueryable <VideoStruct>, string> Queryable(VideoStructType type)
 {
     if (type == VideoStructType.机动车)
     {
         return(new Tuple <IQueryable <VideoStruct>, string>(Vehicles.AsNoTracking(), VehicleTable));
     }
     else if (type == VideoStructType.非机动车)
     {
         return(new Tuple <IQueryable <VideoStruct>, string>(Bikes.AsNoTracking(), BikeTable));
     }
     else
     {
         return(new Tuple <IQueryable <VideoStruct>, string>(Pedestrains.AsNoTracking(), PedestrainTable));
     }
 }
コード例 #19
0
        public void TestWinnerOutcome()
        {
            Bikes.StartingPosition1    = 0;
            Bikes.BikeRacetrackLength1 = 50;
            int BikeRacerAmount = 45;
            int BikesNumber     = 2;
            int expectedWin     = 90;
            int expectedLose    = 0;

            Bikess[0] = new Bikes()
            {
                BikesPictureBox = null
            };
            Bikess[1] = new Bikes()
            {
                BikesPictureBox = null
            };
            Tom      = pFactory.getBikeRacer("Tom", null, null);
            Tom.Cash = BikeRacerAmount;
            Tom.PlaceBet((int)BikeRacerAmount, BikesNumber);

            bool nowin = true;
            int  win   = -1;

            while (nowin)
            {
                for (int i = 0; i < Bikess.Length; i++)
                {
                    if (Bikes.Run(Bikess[i]))
                    {
                        win = i + 1;
                        Tom.Collect(win);
                        nowin = false;
                    }
                }
            }
            if (Tom.bet.bikeNum == win)
            {
                Assert.AreEqual(expectedWin, Tom.Cash, "Account doesn't credited ");
            }
            if (Tom.bet.bikeNum != win)
            {
                Assert.AreEqual(expectedLose, Tom.Cash, "Account doesn't debited ");
            }
        }
コード例 #20
0
        public async Task <IActionResult> UpdateBike([FromBody] Bikes bike)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await adminRepository.UpdateBike(bike);

                    return(Ok());
                }
                catch (Exception)
                {
                    return(BadRequest());
                }
            }

            return(BadRequest());
        }
コード例 #21
0
        // On load of program, loads bike information from text file.
        private void form1_Load(object sender, EventArgs e)
        {
            TextReader tr = new StreamReader("data.txt");
            string     bikeData;

            while ((bikeData = tr.ReadLine()) != null)
            {
                Bikes temp = new Bikes();
                temp.makeName  = bikeData;
                temp.bikeModel = tr.ReadLine();
                temp.engSize   = tr.ReadLine();
                temp.bikeYear  = tr.ReadLine();
                temp.bikeCost  = tr.ReadLine();
                myBikes.Add(temp);
            }
            myBikes.Sort();
            DisplayRecords();
            tr.Close();
        }
コード例 #22
0
        public async Task <IActionResult> BikeCreate(Bikes bike)
        {
            TempData["message"] = string.Empty;
            string message;

            if (bike == null)
            {
                return(View(new Bikes()));
            }

            bool succeeded = await repo.AddBike(bike);

            if (succeeded)
            {
                return(RedirectToAction("BikeIndex"));
            }

            return(View(bike));
        }
コード例 #23
0
        public IActionResult UpdateBike(int index, [FromBody] Bikes bike)
        {
            if (!Context.Bikes.Any(a => a.ID == index))
            {
                return(BadRequest("No Bike found"));
            }
            var b = Context.Bikes.Where(a => a.ID == index).FirstOrDefault();

            b.Brand          = bike.Brand;
            b.Category       = bike.Category;
            b.LastService    = bike.LastService;
            b.Notes          = bike.Notes;
            b.PriceAddHour   = bike.PriceAddHour;
            b.PriceFirstHour = bike.PriceFirstHour;
            b.PurchaseDate   = bike.PurchaseDate;
            Context.SaveChanges();

            return(Ok("Bike Updated"));
        }
コード例 #24
0
        public async Task <Bikes> GetBike(int?bikeId)
        {
            Bikes bike = new Bikes();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(baseUrl);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage res = await client.GetAsync($"Bikes?={bikeId}");

                if (res.IsSuccessStatusCode)
                {
                    var response = res.Content.ReadAsStringAsync().Result;
                    bike = JsonConvert.DeserializeObject <Bikes>(response);
                }
            }

            return(bike);
        }
コード例 #25
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (FollowerCount != null)
         {
             hashCode = hashCode * 59 + FollowerCount.GetHashCode();
         }
         if (FriendCount != null)
         {
             hashCode = hashCode * 59 + FriendCount.GetHashCode();
         }
         if (MeasurementPreference != null)
         {
             hashCode = hashCode * 59 + MeasurementPreference.GetHashCode();
         }
         if (Ftp != null)
         {
             hashCode = hashCode * 59 + Ftp.GetHashCode();
         }
         if (Weight != null)
         {
             hashCode = hashCode * 59 + Weight.GetHashCode();
         }
         if (Clubs != null)
         {
             hashCode = hashCode * 59 + Clubs.GetHashCode();
         }
         if (Bikes != null)
         {
             hashCode = hashCode * 59 + Bikes.GetHashCode();
         }
         if (Shoes != null)
         {
             hashCode = hashCode * 59 + Shoes.GetHashCode();
         }
         return(hashCode);
     }
 }
コード例 #26
0
        public IActionResult UpdateBike(int index, [FromBody] Bikes bike)
        {
            DataContext db = new DataContext();

            if (!db.Bikes.Any(a => a.ID == index))
            {
                return(BadRequest("No Bike found"));
            }
            var b = db.Bikes.Where(a => a.ID == index).FirstOrDefault();

            b.Brand                   = bike.Brand;
            b.Category                = bike.Category;
            b.DateoflastService       = bike.DateoflastService;
            b.Notes                   = bike.Notes;
            b.PriceForAdditionalHours = bike.PriceForAdditionalHours;
            b.PriceFirstHour          = bike.PriceFirstHour;
            b.PurchaseDate            = bike.PurchaseDate;
            db.SaveChanges();

            return(Ok("Bike Updated"));
        }
コード例 #27
0
        }//END of ResetFields

        /// <summary>
        /// This method allows users to update details from the selected item in the ListView each text box to a new
        /// instance of the 'Bikes' class. Then the updated item is loaded back into the ListArray. For tbSize.Text
        /// and tbCost.Text IF do not have they already have symbols representing the data for their particular field
        /// then it is added. The fields are then resetted, the ListArray is sorted, items are redisplayed in the
        /// ListView, temporary xml file saved and a status message is displayed.
        /// </summary>
        public void UpdateBike()
        {
            Bikes updatedBikes = new Bikes();

            updatedBikes.make  = tbMake.Text;
            updatedBikes.model = tbModel.Text.ToUpper();
            updatedBikes.size  = tbSize.Text;
            updatedBikes.year  = tbYear.Text;
            updatedBikes.cost  = tbCost.Text;

            int indx = lvwBikeDetails.FocusedItem.Index;

            myBikes[indx].make  = updatedBikes.make;
            myBikes[indx].model = updatedBikes.model;
            myBikes[indx].year  = updatedBikes.year;

            if (tbSize.Text.EndsWith("cc"))
            {
                myBikes[indx].size = updatedBikes.size;
            }
            else
            {
                myBikes[indx].size = updatedBikes.size + "cc";
            }

            if (tbCost.Text.StartsWith("$"))
            {
                myBikes[indx].cost = updatedBikes.cost;
            }
            else
            {
                myBikes[indx].cost = "$" + updatedBikes.cost;
            }
            ResetFields();
            myBikes.Sort();
            DisplayInfo();
            TempSave();
            stsMessage.Text = "Record has been updated";
        }//END of UpdateBike
コード例 #28
0
        public Tuple <int, int> PageCount(int pagesToDisplay, int pastMidPoint, int pagesOnEachSide, int endOfStartPage)
        {
            int pageCount = Convert.ToInt32(Math.Ceiling(Bikes.Count() / (double)BikePerPage));
            int startPage = 1;
            int endPage   = 1;

            if (pageCount > 0)
            {
                if (pageCount <= pagesToDisplay)
                {
                    startPage = 1;
                    endPage   = pageCount;
                }
                else
                {
                    if (CurrentPage >= pastMidPoint)
                    {
                        startPage = CurrentPage - pagesOnEachSide;

                        if (CurrentPage <= pageCount - pagesOnEachSide)
                        {
                            endPage = CurrentPage + pagesOnEachSide;
                        }
                        else
                        {
                            startPage = pageCount - endOfStartPage + 1;
                            endPage   = pageCount;
                        }
                    }
                    else
                    {
                        startPage = 1;
                        endPage   = endOfStartPage;
                    }
                }
            }
            return(Tuple.Create(startPage, endPage));
        }
コード例 #29
0
 public void AddBike(object a)
 {
     if (Model == "" || Brand == "" || Price <= 0)
     {
         MessageBox.Show("Vul geldige gegevens in");
         return;
     }
     else
     {
         Bikes bike = new Bikes()
         {
             Model  = Model,
             Brand  = Brand,
             Gender = Gender,
             Price  = Price,
         };
         Stores dbStore = db.Stores.Local.First(s => s == SelectedStore);
         dbStore.AvailableBikes.Add(bike);
         db.Bikes.Add(bike);
         db.SaveChanges();
         MessageBox.Show("Bike is toegevoegd");
     };
 }
コード例 #30
0
 public void SetBikeFromEnumConstant()
 {
     this.myBike = Bikes.Daccordi;
 }