//
 // GET: /UserProblems/Create
 public ActionResult Create()
 {
     string tid = "1";
     string cid = "1";
     UserProfileModel userprofile = GetMyProfile();
     ViewBag.showAssignTo = userprofile.Department;
     Department clsDepartment = new Department();
     Category clsCategory = new Category();
     ViewData["CategoryID"] = new SelectList(clsCategory.getFCategoryList(tid, "", " -- "), "CateId", "CateName", cid);
     Problems clsProblems = new Problems();
     ViewBag.UserNewQuestion = clsProblems.UserNewQuestion(User.Identity.Name);
     ViewBag.UserSolveQuestion = clsProblems.UserSolveQuestion(User.Identity.Name);
     return View();
 }
 /// <summary>
 /// 用户登录界面
 /// </summary>
 /// <param name="pageNo"></param>
 /// <param name="cid"></param>
 /// <param name="sort"></param>
 /// <param name="order"></param>
 /// <returns></returns>
 public ViewResult Index(int? pageNo, int? cid, string sort, string order)
 {
     Problems clsProblems = new Problems();
     Category clsCategory = new Category();
     Pager pager = new Pager();
     int cateid = cid ?? 0;
     pager.PageNo = pageNo ?? 1;
     pager.PageSize = 10;
     if (cateid > 0)
         pager = clsProblems.GetUserReplyPaging(pager, clsCategory.GetCategoryIds(cateid), sort, string.IsNullOrWhiteSpace(order) ? "desc" : order, User.Identity.Name);
     else
         pager = clsProblems.GetUserReplyPaging(pager, cateid, sort, string.IsNullOrWhiteSpace(order) ? "desc" : order, User.Identity.Name);
     ViewBag.PageNo = pageNo ?? 1;//页码
     ViewBag.PageCount = pager.PageCount;//总页数
     ViewBag.Cid = cateid;
     ViewBag.Sort = sort;
     ViewBag.Order = order;
     List<CategoryModel> catelist = clsCategory.getFCategoryList("1", "", " -- ");
     catelist.Insert(0, new CategoryModel
     {
         CateId = "0",
         CateName = res.SelectSubcategories
     });
     ViewBag.UserNewQuestion = clsProblems.UserNewQuestion(User.Identity.Name);
     ViewBag.UserSolveQuestion = clsProblems.UserSolveQuestion(User.Identity.Name);
     ViewData["CateId"] = new SelectList(catelist, "CateId", "CateName", cateid);
     return View(pager.Entity);
 }
 //
 // GET: /UserProblems/Details/5
 public ViewResult Details(Guid id)
 {
     var NewRecords = (from d in db.Pts_Records
                       where d.ProblemID == id
                       orderby d.CreateTime descending
                       select d).First();
     Category clsCategory = new Category();
     UserProfileModel userprofile = GetMyProfile();
     List<CategoryModel> catelist = clsCategory.getFCategoryList("1", "", " -- ");
     Pts_Problems clsPts_Problems = db.Pts_Problems.Find(id);
     ViewBag.CategoryID = catelist.Find(c => c.CateId.ToString() == clsPts_Problems.CategoryID.ToString()).CateName.ToString();
     Department clsDepartment = new Department();
     ViewBag.AssignTo = new SelectList(clsDepartment.GetDepartmentList(), "DeptID", "DeptName");
     ViewBag.Department = userprofile.Department;
     //显示修改按钮相关
     Problems clsProblems = new Problems();
     ViewBag.UserNewQuestion = clsProblems.UserNewQuestion(User.Identity.Name);
     ViewBag.UserSolveQuestion = clsProblems.UserSolveQuestion(User.Identity.Name);
     return View(clsPts_Problems);
 }