using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EMIS.CommonLogic.ExaminationManage;
using EMIS.ViewModel;
using EMIS.Web.Controls;
using EMIS.ViewModel.ExaminationManage;
using Bowin.Web.Controls.Mvc;
using Bowin.Common.JSON;
namespace EMIS.Web.Controllers.ExaminationManage
{
[Authorization]
public class TimeSegmentController : Controller
{
public ITimeSegmentServices TimeSegmentServices { get; set; }
///
/// 考试时间页面
///
///
public ActionResult List()
{
return View();
}
public ActionResult Edit(Guid? TimeSegmentID)
{
TimeSegmentView timeSegmentView = new TimeSegmentView();
if (TimeSegmentID.HasValue)
{
timeSegmentView = TimeSegmentServices.GetTimeSegmentView(TimeSegmentID);
}
else
{
timeSegmentView.IsForResit = true;
timeSegmentView.ExaminationDate = DateTime.Today;
}
return View(timeSegmentView);
}
[HttpPost]
public ActionResult List(QueryParamsModel pararms)
{
ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
if (configuretView.Attribute == Bowin.Web.Controls.Mvc.DropdownList.SELECT_ALL.ToString()) configuretView.Attribute = "";
return base.Json(TimeSegmentServices.GetTimeSegmentViewList(configuretView, (int)pararms.page, (int)pararms.rows));
}
[HttpPost]
public ActionResult Dropdown(DropdownListBindType? bindType, bool? isForResit)
{
List list = TimeSegmentServices.GetTimeSegmentViewList(isForResit).Select(x => new DropdownListItem { Text = x.TimeSegmentName, Value = x.ToJson() }).ToList();
DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
DropdownList.FormatDropdownItemList(dbt, list);
return base.Json(list);
}
[HttpPost]
public ActionResult Edit(TimeSegmentView timeSegmentView)
{
try
{
TimeSegmentServices.SaveTimeSegment(timeSegmentView);
return Json(new ReturnMessage { IsSuccess = true, Message = "保存成功。" });
}
catch (Exception ex)
{
return Json(new ReturnMessage { IsSuccess = false, Message = "保存失败:" + ex.Message });
}
}
[HttpPost]
public ActionResult Delete(string timeSegmentIDs)
{
try
{
List list = timeSegmentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList();
TimeSegmentServices.Delete(list);
return base.Json(new ReturnMessage { IsSuccess = true, Message = "删除成功" });
}
catch (Exception ex)
{
return base.Json(new ReturnMessage { IsSuccess = false, Message = "删除失败:" + ex.Message });
}
}
}
}