using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Threading.Tasks;
|
using System.Transactions;
|
using DTO;
|
using IServices;
|
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.Extensions.Logging;
|
using Newtonsoft.Json;
|
using zhengcaioa.IService;
|
using zhengcaioa.Models;
|
|
namespace zhengcaioa.Controllers.admin
|
{
|
[CheckLogin]
|
public class SimCostController : Controller
|
{
|
private readonly ILogger<SimController> _logger;
|
private readonly ILiaotianService _liaotianService;
|
private readonly IUserService _userService;
|
private readonly ISimService _simService;
|
|
public SimCostController(ILogger<SimController> logger, IUserService userService, ILiaotianService liaotianService, ISimService simService)
|
{
|
_logger = logger;
|
_liaotianService = liaotianService;
|
_userService = userService;
|
_simService = simService;
|
}
|
|
/// <summary>
|
/// 列表页
|
/// </summary>
|
/// <returns></returns>
|
public IActionResult Index()
|
{
|
List<ActionEntity> actionlist = new List<ActionEntity>();
|
ActionEntity actionEntity = new ActionEntity();
|
actionEntity.OpenType = 0;
|
actionEntity.ActionUrl = "";
|
actionEntity.ActionFun = "Search";
|
actionEntity.PageIco = "fa fa-search";
|
actionEntity.ActionName = "查询";
|
actionlist.Add(actionEntity);
|
|
ActionEntity actionEntity1 = new ActionEntity();
|
actionEntity1.OpenType = 0;
|
actionEntity1.ActionUrl = "";
|
actionEntity1.ActionFun = "Add";
|
actionEntity1.PageIco = "fa fa-plus";
|
actionEntity1.ActionName = "新增";
|
actionlist.Add(actionEntity1);
|
|
|
//ActionEntity actionEntity4 = new ActionEntity();
|
//actionEntity4.OpenType = 0;
|
//actionEntity4.ActionUrl = "";
|
//actionEntity4.ActionFun = "UnBind";
|
//actionEntity4.PageIco = "fa fa-remove";
|
//actionEntity4.ActionName = "批量删除";
|
//actionlist.Add(actionEntity4);
|
|
ViewData["ActionInfo"] = actionlist;
|
return View();
|
}
|
|
/// <summary>
|
/// 列表内容
|
/// </summary>
|
/// <param name="search"></param>
|
/// <returns></returns>
|
public IActionResult GetList(SimCostDTOSearch search)
|
{
|
return new JsonResult(_simService.SearchSimCostByPage(search));
|
}
|
|
/// <summary>
|
/// 编辑页
|
/// </summary>
|
/// <param name="id"></param>
|
/// <returns></returns>
|
public IActionResult Edit(string id=null)
|
{
|
ViewBag.SimCard = _simService.GetBindSim();
|
SimCost dto = new SimCost();
|
dto.accounted_time = DateTime.Now;
|
if (!string.IsNullOrEmpty(id))
|
{
|
dto = _simService.GetSimCost(int.Parse(id));
|
}
|
ViewData.Model = dto;
|
return View();
|
}
|
|
/// <summary>
|
/// 保存
|
/// </summary>
|
/// <param name="data"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public IActionResult SaveSimCost(SimCost data)
|
{
|
var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
ResultEntity resultEntity = new ResultEntity();
|
using (TransactionScope scope = new TransactionScope())
|
{
|
data.sub_userid = curentuser.Id;
|
resultEntity = _simService.SaveCost(data);
|
scope.Complete();
|
}
|
return new JsonResult(resultEntity);
|
}
|
|
///// <summary>
|
///// 解绑
|
///// </summary>
|
///// <param name="id"></param>
|
///// <returns></returns>
|
//[HttpPost]
|
//public JsonResult UnBindSim(string id)
|
//{
|
// var curentuser = JsonConvert.DeserializeObject<PltUser>(HttpContext.Session.GetString("User"));
|
// ResultEntity resultEntity = new ResultEntity();
|
// using (TransactionScope scope = new TransactionScope())
|
// {
|
// resultEntity = _simService.UnBind(id, curentuser.Id);
|
// scope.Complete();
|
// }
|
// return new JsonResult(resultEntity);
|
//}
|
}
|
}
|