Esempio n. 1
0
        public async Task <ActionResult> Edit([Bind(Include = "ID,AdditiveType,Miles,Date,Cost,Notes,CarID")] OilAdditive oilAdditive)
        {
            if (ModelState.IsValid)
            {
                db.Entry(oilAdditive).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index", new { CarID = oilAdditive.CarID }));
            }
            if (oilAdditive.CarID > 0)
            {
                ViewBag.CarID = oilAdditive.CarID;
                UpdateCarDescription(oilAdditive.CarID);
                PopulateCarDropDownList(oilAdditive.CarID);
            }
            return(View(oilAdditive));
        }
Esempio n. 2
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            if (id <= 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OilAdditive oilAdditive = await db.OilAdditive.FindAsync(id);

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

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

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