Exemplo n.º 1
0
        public ActionResult Details(int?id)
        {
            DepartmentDBHelper db   = new DepartmentDBHelper();
            Department         dept = db.GetDepartments().FirstOrDefault(d => d.Id == id);

            return(View(dept));
        }
Exemplo n.º 2
0
        public ActionResult DeletePost(int?id)
        {
            try
            {
                DepartmentDBHelper db = new DepartmentDBHelper();
                db.DeleteDepartment(id);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Exemplo n.º 3
0
        public ActionResult Create(string Name, string Location)
        {
            try
            {
                Department d = new Department()
                {
                    Name     = Name,
                    Location = Location
                };

                DepartmentDBHelper db = new DepartmentDBHelper();
                db.InsertDepartment(d);
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Exemplo n.º 4
0
        public ActionResult Edit()
        {
            if (ModelState.IsValid)
            {
                Department d = new Department();

                TryUpdateModel <Department>(d);
                try
                {
                    DepartmentDBHelper db = new DepartmentDBHelper();
                    db.UpdateDepartment(d);

                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
Exemplo n.º 5
0
        public ViewResult Index()
        {
            DepartmentDBHelper db = new DepartmentDBHelper();

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