using Learun.Application.OA.Schedule;
using Learun.Util;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Learun.Application.Web.Areas.LR_OAModule.Controllers
{
///
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创建人:陈彬彬
/// 日 期:2017.7.11
/// 描 述:日程管理
///
public class ScheduleController : MvcControllerBase
{
private ScheduleIBLL scheduleIBLL = new ScheduleBLL();
#region 视图功能
///
/// 管理页面
///
///
[HttpGet]
public ActionResult Index()
{
return View();
}
///
/// 表单页面
///
///
[HttpGet]
public ActionResult Form()
{
return View();
}
#endregion
#region 获取数据
///
/// 获取日程数据
///
///
[HttpGet]
public ActionResult GetList()
{
var userInfo = LoginUserInfo.Get();
List data = new List();
foreach (ScheduleEntity entity in scheduleIBLL.GetList().Where(x => x.F_CreateUserId == userInfo.userId).ToList())
{
Hashtable ht = new Hashtable();
ht["id"] = entity.F_ScheduleId;
ht["title"] = entity.F_ScheduleContent;
ht["end"] = (entity.F_EndDate.ToDate().ToString("yyyy-MM-dd") + " " + entity.F_EndTime.Substring(0, 2) + ":" + entity.F_EndTime.Substring(2, 2)).ToDate().ToString("yyyy-MM-dd HH:mm:ss");
ht["start"] = (entity.F_StartDate.ToDate().ToString("yyyy-MM-dd") + " " + entity.F_StartTime.Substring(0, 2) + ":" + entity.F_StartTime.Substring(2, 2)).ToDate().ToString("yyyy-MM-dd HH:mm:ss");
ht["allDay"] = false;
data.Add(ht);
}
return ToJsonResult(data);
}
///
/// 获取实体
///
/// 主键值
/// 返回对象Json
[HttpGet]
public ActionResult GetFormJson(string keyValue)
{
var data = scheduleIBLL.GetEntity(keyValue);
var jsonData = new
{
LR_OA_Schedule = data,
};
return Success(jsonData);
}
#endregion
#region 提交数据
///
/// 删除数据
///
/// 主键值
///
[HttpPost]
[AjaxOnly]
public ActionResult RemoveForm(string keyValue)
{
scheduleIBLL.RemoveForm(keyValue);
return Success("删除成功。");
}
///
/// 保存表单(新增、修改)
///
/// 主键值
/// 实体对象
///
[HttpPost]
[ValidateAntiForgeryToken]
[AjaxOnly]
public ActionResult SaveForm(string keyValue, ScheduleEntity entity)
{
var startTime = entity.F_StartDate.ToDate();
var endTime = entity.F_EndDate.ToDate();
if (startTime < DateTime.Now.Date)
{
return Fail("开始时间不能早于今天");
}
if (endTime < startTime)
{
return Fail("结束时间不能早与开始时间");
}
scheduleIBLL.SaveForm(keyValue, entity);
return Success("操作成功。");
}
#endregion
}
}