コード例 #1
0
        public IHttpActionResult GetEmployeeByDepartment(DepModel model)
        {
            List <DepartmentModel> data   = null;
            List <DepartmentModel> result = new List <DepartmentModel>();

            foreach (var dep in model.Id)
            {
                data = (from e in db.Employees
                        join m in db.EmpDep_Mapping on e.EmployeeId equals m.EmpId
                        join d in db.Departments on m.DepId equals d.DepartmentId
                        where d.DepartmentId == dep
                        select new DepartmentModel
                {
                    EmployeeId = e.EmployeeId,
                    EmployeeName = e.EmployeeName,
                    EmployeeAddress = e.EmployeeAddress,
                    EmployeeSalary = e.EmployeeSalary,
                    DepartmentId = d.DepartmentId,
                    DepartmentName = d.DepartmentName
                }).ToList();
                result.AddRange(data);
            }

            return(Ok(result));
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            DepModel depModel = db.Department.Find(id);

            db.Department.Remove(depModel);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "DepId,DepName")] DepModel depModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(depModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(depModel));
 }
コード例 #4
0
        public ActionResult Create([Bind(Include = "DepId,DepName")] DepModel depModel)
        {
            if (ModelState.IsValid)
            {
                db.Department.Add(depModel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(depModel));
        }
コード例 #5
0
        // GET: DepModels/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DepModel depModel = db.Department.Find(id);

            if (depModel == null)
            {
                return(HttpNotFound());
            }
            return(View(depModel));
        }