コード例 #1
0
        //
        // GET: /Student/Create
        public ActionResult Edit(string id)
        {
            if (HttpContext != null)
            {
                UrlHelper url = new UrlHelper(HttpContext.Request.RequestContext);
                ViewBag.breadCrumbData  = "<a href='" + url.Action("Index", "Department") + "'>Department List</a>";
                ViewBag.breadCrumbData += " > Edit";
            }

            PLDepartment department = DepartmentClientService.GetDepartmentDetail(id);

            List <PLStaff>        st  = StaffClientService.GetStaffList();
            List <SelectListItem> res = new List <SelectListItem>();

            foreach (PLStaff tmp in st)
            {
                if (tmp.Department.deptName.Equals(id))
                {
                    res.Add(new SelectListItem {
                        Value = tmp.ID.ToString(), Text = tmp.FirstName + " " + tmp.LastName
                    });
                }
            }
            ViewBag.listStaff = res;

            return(View("Edit", department));
        }
コード例 #2
0
ファイル: StaffController.cs プロジェクト: ysugiant/cse136fe
        public ActionResult Create(FormCollection collection, string departmentFilter)
        {
            if (departmentFilter == null)
            {
                departmentFilter = "Computer Science and Engineering";
            }

            try
            {
                PLStaff staffMember = new PLStaff();
                //staffMember.ID = Convert.ToInt32(collection["ID"]);
                staffMember.FirstName    = collection["FirstName"];
                staffMember.LastName     = collection["LastName"];
                staffMember.EmailAddress = collection["EmailAddress"];
                staffMember.Password     = collection["Password"];
                //staffMember.Department = new PLDepartment();
                staffMember.Department = DepartmentClientService.GetDepartmentDetail(departmentFilter);//collection.Get(5).ToString());
                //staffMember.Department.deptName = collection.Get(6).ToString();//1;//new PLDepartment();//ViewBag.//DepartmentClientService.CreateDepartment((PLDepartment)(collection["Department"]));//Convert.ToInt32(collection["Department"]);
                staffMember.isInstructor = Convert.ToBoolean(collection["InstructorBit"]);
                StaffClientService.CreateStaff(staffMember);
                return(RedirectToAction("Index"));// this brings us to the staff List page
            }
            catch (Exception e)
            {
                Console.Write(e.ToString());
                return(View());
            }
        }
コード例 #3
0
ファイル: StaffController.cs プロジェクト: ysugiant/cse136fe
        //
        // GET: /Staff/
        public ActionResult Index()
        {
            List <PLStaff> staffList = StaffClientService.GetStaffList();

            ViewBag.breadCrumbData = "Staff List";

            return(View("List", staffList));
        }
コード例 #4
0
ファイル: StaffController.cs プロジェクト: ysugiant/cse136fe
        // GET: /Staff/Delete/5
        public ActionResult Delete(int id)
        {
            try
            {
                bool success = StaffClientService.DeleteStaff(id);

                if (success)
                {
                    return(RedirectToAction("Index"));
                }

                return(RedirectToAction("Error"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #5
0
ファイル: StaffController.cs プロジェクト: ysugiant/cse136fe
 // GET: /Staff/Edit
 public ActionResult Edit(int id, FormCollection collection)
 {
     try
     {
         PLStaff staffMember = new PLStaff();
         staffMember.ID           = id;
         staffMember.FirstName    = collection["FirstName"];
         staffMember.LastName     = collection["LastName"];
         staffMember.EmailAddress = collection["EmailAddress"];
         staffMember.Password     = collection["Password"];
         staffMember.Department   = DepartmentClientService.GetDepartmentDetail(collection["Department"]);
         staffMember.isInstructor = Convert.ToBoolean(collection["isInstructor"]);
         StaffClientService.UpdateStaff(staffMember);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }