Beispiel #1
0
 /// <summary>
 /// Create a new Branch object.
 /// </summary>
 /// <param name="branchId">Initial value of the BranchId property.</param>
 /// <param name="deptId">Initial value of the DeptId property.</param>
 /// <param name="branchName">Initial value of the BranchName property.</param>
 /// <param name="classId">Initial value of the ClassId property.</param>
 /// <param name="isSupporting">Initial value of the IsSupporting property.</param>
 public static Branch CreateBranch(global::System.Int32 branchId, global::System.Int32 deptId, global::System.String branchName, global::System.Int32 classId, global::System.Boolean isSupporting)
 {
     Branch branch = new Branch();
     branch.BranchId = branchId;
     branch.DeptId = deptId;
     branch.BranchName = branchName;
     branch.ClassId = classId;
     branch.IsSupporting = isSupporting;
     return branch;
 }
Beispiel #2
0
        public ActionResult BranchNew(Branch branch, int deptId)
        {
            if (ModelState.IsValid)
            {
                branch.DeptId = deptId;
                db.Branches.AddObject(branch);
                db.SaveChanges();
                return RedirectToAction("BranchList", new { deptId = deptId });
            }
            //if (branch.ClassId == null)
            //    ModelState.AddModelError("", "Kelas cabang harus diisi");

            ViewBag.Dept = db.Depts.Single(p => p.DeptId == deptId);
            ViewBag.ClassId = new SelectList(db.BranchClasses, "ClassId", "ClassName");
            return View(branch);
        }
Beispiel #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Branches EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToBranches(Branch branch)
 {
     base.AddObject("Branches", branch);
 }
Beispiel #4
0
        public ActionResult BranchEdit(Branch branch)
        {
            if (ModelState.IsValid)
            {
                db.Branches.Attach(branch);
                db.ObjectStateManager.ChangeObjectState(branch, EntityState.Modified);
                db.SaveChanges();

                ViewBag.Dept = db.Depts.Single(p => p.DeptId == branch.DeptId);
                return RedirectToAction("BranchList", new { deptId = branch.DeptId });
            }
            return View(branch);
        }