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

            return(View(dept));
        }
Exemple #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"));
        }
Exemple #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());
            }
        }
Exemple #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());
            }
        }
Exemple #5
0
        public ActionResult Index()
        {
            DeparmentDBHelper db = new DeparmentDBHelper();

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