using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace LC.UI.Controllers
{
using BLL;
using Entity;
using Newtonsoft.Json;
public class UsersController : Controller
{
VIPUsersBLL bll = new VIPUsersBLL();
// GET: Users
public ActionResult Index()
{
return View();
}
public ActionResult Add()
{
return View();
}
[HttpPost]
public int Add(VIPUsers t)
{
var result = bll.Add(t);
return result;
}
[HttpPost]
public int Delete(int Id)
{
var result = bll.Delete(Id);
return result;
}
[HttpPost]
public string Query(DateTime? startDate,DateTime? endDate, int pageIndex=1,string Name="")
{
var list = bll.Query();
if (!string.IsNullOrWhiteSpace(startDate.ToString()))
list = list.Where(m => m.CreateDate >= startDate).ToList();
if (!string.IsNullOrWhiteSpace(endDate.ToString()))
list = list.Where(m => m.CreateDate <= endDate).ToList();
if (!string.IsNullOrWhiteSpace(Name))
list = list.Where(m => m.Name.Contains(Name)).ToList();
PageBox page = new PageBox();
page.PageIndex = pageIndex;
page.PageCount = list.Count / 3 + (list.Count% 3>0?1:0);
page.Data = list.Skip((pageIndex - 1) * 3).Take(3);
return JsonConvert.SerializeObject(page);
}
[HttpPost]
public string QueryById(int Id)
{
var result = bll.QueryById(Id);
return JsonConvert.SerializeObject(result);
}
[HttpPost]
public int Update(VIPUsers t)
{
var result = bll.Update(t);
return result;
}
[HttpPost]
public int Execl()
{
HttpPostedFileBase file = Request.Files[0];
var result = Excel.ExcelAdd(file);
return result;
}
}
}