Esempio n. 1
0
        public ActionResult Delete(int?id)
        {
            DeparmentDBHelper db   = new DeparmentDBHelper();
            Department        dept = db.GetDepartments().FirstOrDefault(d => d.Id == id);

            return(View(dept));
        }
Esempio n. 2
0
        public ActionResult Delete(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Id Required"));
            }

            DeparmentDBHelper db = new DeparmentDBHelper();

            db.DeleteDeptDetails(id);



            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        public ActionResult create(string Name, string Location)
        {
            try
            {
                Department d = new Department()
                {
                    Name     = Name,
                    Location = Location
                };

                DeparmentDBHelper db = new DeparmentDBHelper();
                db.InsertDeptDetails(d);

                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                return(View());
            }
        }
Esempio n. 4
0
        public ActionResult Edit(string Id, string Name, string Location)
        {
            try
            {
                Department d = new Department()
                {
                    Id       = Convert.ToInt32(Id),
                    Name     = Name,
                    Location = Location
                };

                DeparmentDBHelper db = new DeparmentDBHelper();
                db.UpdateDeptDetails(d);
                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                return(View());
            }
        }
Esempio n. 5
0
        public ActionResult Index()
        {
            DeparmentDBHelper db = new DeparmentDBHelper();

            return(View(db.GetDepartments().ToList()));
        }