public async Task <ActionResult> Create([Bind(Include = "ID,AdditiveType,Miles,Date,Cost,Notes,CarID")] FuelAdditive fuelAdditive)
        {
            if (ModelState.IsValid)
            {
                db.FuelAdditive.Add(fuelAdditive);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index", new { CarID = fuelAdditive.CarID }));
            }

            if (fuelAdditive.CarID > 0)
            {
                ViewBag.CarID = fuelAdditive.CarID;
                UpdateCarDescription(fuelAdditive.CarID);
            }
            return(View(fuelAdditive));
        }
        public async Task <ActionResult> Edit([Bind(Include = "ID,AdditiveType,Miles,Date,Cost,Notes,CarID")] FuelAdditive fuelAdditive)
        {
            if (ModelState.IsValid)
            {
                db.Entry(fuelAdditive).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index", new { CarID = fuelAdditive.CarID }));
            }
            if (fuelAdditive.CarID > 0)
            {
                ViewBag.CarID = fuelAdditive.CarID;
                UpdateCarDescription(fuelAdditive.CarID);
                PopulateCarDropDownList(fuelAdditive.CarID);
            }
            return(View(fuelAdditive));
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            if (id <= 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            FuelAdditive fuelAdditive = await db.FuelAdditive.FindAsync(id);

            if (fuelAdditive.CarID > 0)
            {
                ViewBag.CarID = fuelAdditive.CarID;
                UpdateCarDescription(fuelAdditive.CarID);
            }
            db.FuelAdditive.Remove(fuelAdditive);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        // GET: FuelAdditive/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null || id <= 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FuelAdditive fuelAdditive = await db.FuelAdditive.FindAsync(id);

            if (fuelAdditive == null)
            {
                return(HttpNotFound());
            }
            else if (fuelAdditive.CarID > 0)
            {
                ViewBag.CarID = fuelAdditive.CarID;
                UpdateCarDescription(fuelAdditive.CarID);
            }
            return(View(fuelAdditive));
        }