public ActionResult Review(RequestModel rModel) { using (var db = new HR_QueryEntities()) { Request selectedRequest = db.Requests.Select(x => x).Where(x => x.Request_ID == rModel.RequestID).First(); Employee associatedEmployee = db.Employees.Select(x => x).Where(x => x.Employee_ID == selectedRequest.Employee_ID).First(); if (selectedRequest.Request_Type_Index == 1) associatedEmployee.Available = true; if (selectedRequest.Request_Type_Index == 2) associatedEmployee.Available = false; selectedRequest.Request_Status = false; db.SaveChanges(); return RedirectToAction("Options", "Home"); } }
// // GET: /Review/ public ActionResult Review(int request_id = 0) { using (var db = new HR_QueryEntities()) { RequestModel model = new RequestModel(); Request selectedRequest = db.Requests.Select(x => x).Where(x => x.Request_ID == request_id).First(); Employee associatedEmployee = db.Employees.Select(x => x).Where(x => x.Employee_ID == selectedRequest.Employee_ID).First(); model.RequestID = selectedRequest.Request_ID; model.RequestorName = selectedRequest.Requestor_Name; model.TransactionType = (db.Request_Types.Select(x => x).Where(x => x.Request_Type_ID == selectedRequest.Request_Type_Index).First()).Request_Type_Name; model.EmployeeFirstName = associatedEmployee.First_Name; model.EmployeeLastName = associatedEmployee.Last_Name; model.DepartmentName = (db.Departments.Select(x => x).Where(x => x.Dept_ID == associatedEmployee.Department).First()).Dept_Name; model.LocationName = (db.Locations.Select(x => x).Where(x => x.Location_ID == associatedEmployee.Location).First()).Location_Name; model.PositionTypeName = (db.Position_Types.Select(x => x).Where(x => x.Position_Type_ID == associatedEmployee.Position_Type).First()).Position_Type_Name; return View(model); } }