Example #1
0
        public ActionResult Edit([Bind(Include = "Faculty_Id,Faculty_Code,Faculty_Name,Faculty_Name_Eng,Faculty_Acronym,Order_Id")] Mstr_Faculty mstr_Faculty)
        {
            if (ModelState.IsValid)
            {
                db.Entry(mstr_Faculty).State = EntityState.Modified;
                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    Mstr_Faculty faculty = db.Mstr_Faculty.Find(mstr_Faculty.Faculty_Id);
                    if (faculty == null)
                    {
                        return(HttpNotFound());
                    }
                    TempData["shortMessage"] = "Kode Fakultas / Nama Fakultas telah ada.";
                    return(RedirectToAction("Edit", mstr_Faculty));

                    throw;
                }
                return(RedirectToAction("Index"));
            }
            return(View(mstr_Faculty));
        }
Example #2
0
        public ActionResult Create([Bind(Include = "Faculty_Id,Faculty_Code,Faculty_Name,Faculty_Name_Eng,Faculty_Acronym,Order_Id")] Mstr_Faculty mstr_Faculty)
        {
            if (ModelState.IsValid)
            {
                db.Mstr_Faculty.Add(mstr_Faculty);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mstr_Faculty));
        }
Example #3
0
        // GET: Faculty/Details/5
        public ActionResult Details(short?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Mstr_Faculty mstr_Faculty = db.Mstr_Faculty.Find(id);

            if (mstr_Faculty == null)
            {
                return(HttpNotFound());
            }
            return(View(mstr_Faculty));
        }
Example #4
0
        // GET: Faculty/Delete/5
        //public ActionResult Delete(short? id)
        //{
        //    if (id == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    Mstr_Faculty mstr_Faculty = db.Mstr_Faculty.Find(id);
        //    if (mstr_Faculty == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    return View(mstr_Faculty);
        //}

        // POST: Faculty/Delete/5
        //[HttpPost, ActionName("Delete")]
        //[ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(short id)
        {
            Mstr_Faculty mstr_Faculty = db.Mstr_Faculty.Find(id);

            db.Mstr_Faculty.Remove(mstr_Faculty);
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                TempData["gagalHapus"] = "Gagal Hapus, Data sudah digunakan";
                return(RedirectToAction("Index"));
            }
            TempData["berhasilHapus"] = "Berhasil Hapus Data.";
            return(RedirectToAction("Index"));
        }
Example #5
0
        // GET: Faculty/Edit/5
        public ActionResult Edit(short?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (TempData["shortMessage"] != null)
            {
                ViewBag.message = TempData["shortMessage"].ToString();
            }
            Mstr_Faculty mstr_Faculty = db.Mstr_Faculty.Find(id);

            if (mstr_Faculty == null)
            {
                return(HttpNotFound());
            }
            return(View(mstr_Faculty));
        }