Beispiel #1
0
        public async Task <ActionResult> Create([Bind(Include = "id,yr")] tyear tyear)
        {
            if (ModelState.IsValid)
            {
                db.tyears.Add(tyear);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(tyear));
        }
Beispiel #2
0
        // GET: tyears/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tyear tyear = await db.tyears.FindAsync(id);

            if (tyear == null)
            {
                return(HttpNotFound());
            }
            return(View(tyear));
        }
Beispiel #3
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            try
            {
                tyear tyear = await db.tyears.FindAsync(id);

                db.tyears.Remove(tyear);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMsg = "This record cannot be deleted.  It's value may be assigned to another table.";
                return(View("Delete"));
            }
        }
Beispiel #4
0
        public async Task <ActionResult> Edit([Bind(Include = "id,yr")] tyear tyear)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Entry(tyear).State = EntityState.Modified;
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(tyear));
                }
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMsg = "Unable to save your changes due to a data error.  Make sure there is not a duplicate record.";
                return(View(tyear));
            }
        }