public ActionResult ManagerProfile(int userID, string SearchText, int?page) { UserProfileModel upModel = new UserProfileModel(); Database db = new Database(); UsersDAO uDAO = new UsersDAO(db); upModel.USERS = uDAO.FindById(userID); db.Close(); db = new Database(); RepairDAO rDAO = new RepairDAO(db); upModel.REPAIR = rDAO.FindByUserID(upModel.USERS.USER_NO); db.Close(); var data = from d in upModel.REPAIR select d; if (!String.IsNullOrEmpty(SearchText)) { if (!SearchText.Equals("0")) { data = data.Where( d => d.STATUS.STATUS_ID.ToString().Contains(SearchText) ); } } db = new Database(); rDAO = new RepairDAO(db); upModel.TOTAL_WORK = rDAO.CountByUserID(userID); db.Close(); db = new Database(); rDAO = new RepairDAO(db); upModel.WAIT_WORK = rDAO.CountByUserIDWait(userID); db.Close(); db = new Database(); rDAO = new RepairDAO(db); upModel.NOW_WORK = rDAO.CountByUserIDNowWorking(userID); db.Close(); db = new Database(); rDAO = new RepairDAO(db); upModel.SUCCESS_WORK = rDAO.CountByUserIDSuccess(userID); db.Close(); db = new Database(); rDAO = new RepairDAO(db); upModel.FAIL_WORK = rDAO.CountByUserIDFail(userID); db.Close(); var numpage = page ?? 1; ViewBag.REPAIR = data.ToPagedList(numpage, 20); ViewBag.PROFILE = upModel; return(View()); }
public ActionResult UserEditing(string who, int userID) { ViewBag.WHO = who; Database db = new Database(); UsersDAO uDAO = new UsersDAO(db); UsersModel uModel = uDAO.FindById(userID); db.Close(); ViewBag.USER = uModel; return(View()); }