using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.Logging; using IServices; using DTO; using Newtonsoft.Json; using zhengcaioa.Models; using Microsoft.AspNetCore.Http; using zhengcaioa.IService; using System.IO; using Microsoft.Extensions.Configuration; namespace zhengcaioa.Controllers.Expert { public class ExpertsApplyController : Controller { private readonly ILogger _logger; private readonly IExpertService _expertService; private readonly ILiaotianService _liaotianService; private readonly IProjectService _projectService; private readonly IUserService _userService; public ExpertsApplyController(ILogger logger, IExpertService expertService, IProjectService projectService, ILiaotianService liaotianService, IUserService userService) { _logger = logger; _expertService = expertService; _projectService = projectService; _liaotianService = liaotianService; _userService = userService; } #region 专家申请,评审 public ActionResult ExpertsApply(string id = null) { //var curentuser = JsonConvert.DeserializeObject(HttpContext.Session.GetString("User")); //ViewData["curentuser"] = curentuser; List actionlist = new List(); ActionEntity actionEntity = new ActionEntity(); actionEntity.OpenType = 0; actionEntity.ActionUrl = ""; actionEntity.ActionFun = "Save"; actionEntity.PageIco = "glyphicon glyphicon-ok"; actionEntity.ActionName = "保存"; actionlist.Add(actionEntity); ViewData["ActionInfo"] = actionlist; ExpertDTO expertDTO = new ExpertDTO(); if (!string.IsNullOrEmpty(id)) { expertDTO = _expertService.Get(id); } else { expertDTO.Province = "510000"; expertDTO.City = "510100"; } // var sheng = _projectService.Getsheng(); // ViewBag.InfoSource = _liaotianService.GetSYScode("CooperatecustomCustomer", "khly");//.Select(x => new { code = x.CodeSn, label = x.Comments }).ToList(); ViewBag.sex = _liaotianService.GetSYScode("plt_user", "sex");//.Select(x => new { code = x.CodeSn, label = x.Comments }).ToList(); // ViewBag.expertType = _liaotianService.GetSYScode("experts", "expertType");//.Select(x => new { code = x.CodeSn, label = x.Comments }).ToList(); // ViewBag.level = _liaotianService.GetSYScode("experts", "level");//.Select(x => new { code = x.CodeSn, label = x.Comments }).ToList(); ViewBag.ReviewItem = _liaotianService.GetSYScode("experts", "ReviewItem");//.Select(x => new { code = x.CodeSn, label = x.Comments }).ToList(); ViewBag.Province = _projectService.Getsheng();//.Select(x => new { code = x.CodeId, label = x.Name }).ToList(); ViewBag.City = _projectService.Getshi(expertDTO.Province);//.Select(x => new { code = x.CodeId, label = x.Name }).ToList(); ViewData.Model = expertDTO; return View(); } //public string Get(string id = null) //{ // ExpertDTO expertDTO = new ExpertDTO(); // if (!String.IsNullOrEmpty(id)) // { // expertDTO = _expertService.Get(id); // } // return JsonConvert.SerializeObject(expertDTO); //} /// /// 保存 /// /// 岗位实体类对象 /// [HttpPost] public string ExpertsApplySave(ExpertDTO data) { //var curentuser = JsonConvert.DeserializeObject(HttpContext.Session.GetString("User")); //ViewData["curentuser"] = curentuser; data.ReviewItem = data.ReviewItemSelect; data.InfoSource = "00"; data.ExpertType = "0"; data.Level = "0"; data.RecStatus = "A"; data.ShenheStatus = "D"; if (String.IsNullOrEmpty(data.Id)) { data.Creater = "1"; data.Createtime = DateTime.Now; } data.Modifier = "1"; data.Modifytime = DateTime.Now; ResultEntity resultEntity = _expertService.save(data); return JsonConvert.SerializeObject(resultEntity); } #endregion public IActionResult Index() { var curentuser = JsonConvert.DeserializeObject(HttpContext.Session.GetString("User")); ViewData["curentuser"] = curentuser; List actionlist = new List(); ActionEntity actionEntity = new ActionEntity(); actionEntity.OpenType = 0; actionEntity.ActionUrl = ""; actionEntity.ActionFun = "Search"; actionEntity.PageIco = "fa fa-search"; actionEntity.ActionName = "查询"; actionlist.Add(actionEntity); ViewData["ActionInfo"] = actionlist; ViewBag.expertType = _liaotianService.GetSYScode("experts", "expertType").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList(); ViewBag.level = _liaotianService.GetSYScode("experts", "level").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList(); ViewBag.Province = _projectService.Getsheng().Select(x => new { code = x.CodeId, label = x.Name }).ToList(); // ViewBag.City = _projectService.Getshi( ).Select(x => new { code = x.CodeId, label = x.Name }).ToList(); ViewBag.ReviewItem = _liaotianService.GetSYScode("experts", "ReviewItem").Select(x => new { code = x.CodeSn, label = x.Comments }).ToList(); return View(); } #region 查询 [CheckLogin] public string GetList(ExpertDTOSearch search) { var curentuser = JsonConvert.DeserializeObject(HttpContext.Session.GetString("User")); search.ShenheStatus = "D"; ViewData["curentuser"] = curentuser; return JsonConvert.SerializeObject(_expertService.SearchByPaging(search)); } #endregion } }