TimeSegmentController.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.CommonLogic.ExaminationManage;
  7. using EMIS.ViewModel;
  8. using EMIS.Web.Controls;
  9. using EMIS.ViewModel.ExaminationManage;
  10. using Bowin.Web.Controls.Mvc;
  11. using Bowin.Common.JSON;
  12. namespace EMIS.Web.Controllers.ExaminationManage
  13. {
  14. [Authorization]
  15. public class TimeSegmentController : Controller
  16. {
  17. public ITimeSegmentServices TimeSegmentServices { get; set; }
  18. /// <summary>
  19. /// 考试时间页面
  20. /// </summary>
  21. /// <returns></returns>
  22. public ActionResult List()
  23. {
  24. return View();
  25. }
  26. public ActionResult Edit(Guid? TimeSegmentID)
  27. {
  28. TimeSegmentView timeSegmentView = new TimeSegmentView();
  29. if (TimeSegmentID.HasValue)
  30. {
  31. timeSegmentView = TimeSegmentServices.GetTimeSegmentView(TimeSegmentID);
  32. }
  33. else
  34. {
  35. timeSegmentView.IsForResit = true;
  36. timeSegmentView.ExaminationDate = DateTime.Today;
  37. }
  38. return View(timeSegmentView);
  39. }
  40. [HttpPost]
  41. public ActionResult List(QueryParamsModel pararms)
  42. {
  43. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  44. if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
  45. return base.Json(TimeSegmentServices.GetTimeSegmentViewList(configuretView, (int)pararms.page, (int)pararms.rows));
  46. }
  47. [HttpPost]
  48. public ActionResult Dropdown(DropdownListBindType? bindType, bool? isForResit)
  49. {
  50. List<DropdownListItem> list = TimeSegmentServices.GetTimeSegmentViewList(isForResit).Select(x => new DropdownListItem { Text = x.TimeSegmentName, Value = x.ToJson() }).ToList();
  51. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  52. DropdownList.FormatDropdownItemList(dbt, list);
  53. return base.Json(list);
  54. }
  55. [HttpPost]
  56. public ActionResult Edit(TimeSegmentView timeSegmentView)
  57. {
  58. try
  59. {
  60. TimeSegmentServices.SaveTimeSegment(timeSegmentView);
  61. return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" });
  62. }
  63. catch (Exception ex)
  64. {
  65. return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message });
  66. }
  67. }
  68. [HttpPost]
  69. public ActionResult Delete(string timeSegmentIDs)
  70. {
  71. try
  72. {
  73. List<Guid?> list = timeSegmentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
  74. TimeSegmentServices.Delete(list);
  75. return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功" });
  76. }
  77. catch (Exception ex)
  78. {
  79. return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + ex.Message });
  80. }
  81. }
  82. }
  83. }