using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Http; using BLL; using Model; using System.Collections; namespace Mvc.Controllers { public class DesignController : ApiController { // // GET: /Draw/ [HttpGet] public ResponseData> Index(string projectId, int index, int page, string name = null) { ResponseData> res = new ResponseData>(); if (name == null) name = ""; res.successful = true; res.resultValue = BLL.DesignService.getListDataForApi( projectId, name, index, page); return res; } // // GET: /Draw/ [HttpGet] public ResponseData> Search(string projectId, int index, int page,string carryUnitIds,string state, string mainItemId = null, string cNProfessionalCode = null, string designType = null, string designDateA = null, string designDateZ = null) { ResponseData> res = new ResponseData>(); res.successful = true; res.resultValue = BLL.DesignService.getListDataForApi(carryUnitIds, state,mainItemId, cNProfessionalCode , designType , designDateA, designDateZ ,projectId, index, page); return res; } // // GET: /Draw/ [HttpGet] public ResponseData GetDesignById(string id) { ResponseData res = new ResponseData(); Check_Design cd = BLL.DesignService.GetDesignByDesignIdForApi(id); res.successful = true; res.resultValue = BeanUtil.CopyOjbect(cd, true); res.resultValue.PlanDay = cd.PlanDay; return res; } [HttpGet] public ResponseData>GetApproveById(string id) { ResponseData> res = new ResponseData>(); res.successful = true; res.resultValue = BLL.DesignApproveService.getListDataByIdForApi(id); return res; } public ResponseData GetCurrApproveById(string id) { ResponseData res = new ResponseData(); res.successful = true; res.resultValue = BeanUtil.CopyOjbect(BLL.DesignApproveService.getCurrApproveForApi(id), true); return res; } [HttpPost] public ResponseData AddDesign([FromBody]Model.Check_Design CheckControl) { ResponseData res = new ResponseData(); try { if (string.IsNullOrEmpty(CheckControl.DesignId)) { CheckControl.DesignId = Guid.NewGuid().ToString(); BLL.DesignService.AddDesignForApi(CheckControl); //BLL.AttachFileService.updateAttachFile(CheckControl.AttachUrl, CheckControl.DesignId, Const.DesignMenuId); SaveAttachFile(CheckControl.DesignId, BLL.Const.DesignMenuId, CheckControl.AttachUrl); res.resultValue = CheckControl.DesignId; res.successful = true; } else { BLL.DesignService.UpdateDesignForApi(CheckControl); //BLL.AttachFileService.updateAttachFile(CheckControl.AttachUrl, CheckControl.DesignId, Const.DesignMenuId); SaveAttachFile(CheckControl.DesignId, BLL.Const.DesignMenuId, CheckControl.AttachUrl); res.resultValue = CheckControl.DesignId; res.successful = true; } } catch (Exception e) { res.successful = false; res.resultHint = e.StackTrace; } return res; } /// /// /// public static void SaveAttachFile(string dataId, string menuId, string url) { Model.ToDoItem toDoItem = new Model.ToDoItem { MenuId = menuId, DataId = dataId, UrlStr = url, }; APIUpLoadFileService.SaveAttachUrl(toDoItem); } [HttpPost] public ResponseData AddApprove([FromBody]Model.Check_DesignApprove approve) { ResponseData res = new ResponseData(); try { Model.Check_Design CheckControl = new Model.Check_Design(); CheckControl.DesignId = approve.DesignId; CheckControl.State = approve.ApproveType; BLL.DesignService.UpdateDesignForApi(CheckControl); res.resultValue = BLL.DesignApproveService.AddDesignApproveForApi(approve); res.successful = true; } catch (Exception e) { res.resultHint = e.StackTrace; res.successful = false; } return res; } [HttpPost] public ResponseData UpdateApprove([FromBody]Model.Check_DesignApprove approve) { ResponseData res = new ResponseData(); try { // Model.Check_DesignApprove approve1 = BLL.DesignApproveService.GetDesignApproveByDesignId(approve.DesignId); approve.ApproveDate = DateTime.Now; //approve1.ApproveIdea = approve.ApproveIdea; //approve1.IsAgree = approve.IsAgree; //approve1.AttachUrl = approve.AttachUrl; BLL.DesignApproveService.UpdateDesignApproveForApi(approve); res.successful = true; } catch (Exception e) { res.resultHint = e.StackTrace; res.successful = false; } return res; } } }