最后,我们讲一下Web应用层。
这层主要还是包括以下两个部分:1.Controller控制台2.View层(其中包括js和css)
Controller控制台,对Servive中的取数据的方法调用。代码如下:
<span style="font-size:18px;"> public class CommonController : Controller
{
private readonly IGoodsService _iGoodsService;
private readonly IFormNumService _iFormNumService;
string _end;
public CommonController(IGoodsService goodsService, IFormNumService iFormNumService)
{
this._iGoodsService = goodsService;
this._iFormNumService = iFormNumService;
}
//
// GET: /Common/
public ActionResult Index()
{
return View();
}
/// <summary>
/// 后台插入数据
/// </summary>
/// <param name="details"></param>
/// <returns></returns>
[HttpPost]
public JsonResult AjaxPost(List<GoodsIn> details, AssetManageFill main)
{
try
{
_end = _iGoodsService.InsertGoods(details,main);
if (_end == "1")
{
return Json(new { Succeed = true });
}
else
{
return Json(new { Succeed = false });
}
}
catch (Exception ex)
{
return Json(new { Msg = ex.InnerException });
}
}
/// <summary>
/// 设定表单编号
/// </summary>
/// <param name="messageId"></param>
/// <param name="workType"></param>
/// <returns></returns>
[HttpPost]
public JsonResult AjaxSetFormNum(string messageId,string workType)
{
try
{
_iFormNumService.InsertNum(messageId,workType);
}
catch (Exception ex)
{
return Json(new { Msg = ex.InnerException });
}
return null;
}
/// <summary>
/// 资产录入
/// </summary>
/// <returns></returns>
[HttpPost]
public JsonResult AjaxAssetGoods(AllGoods details)
{
try
{
_iGoodsService.InsertAllGoods(details);
if (_end == "1")
{
return Json(new { Succeed = true });
}
else
{
return Json(new { Succeed = false });
}
}
catch (Exception ex)
{
return Json(new { Msg = ex.InnerException });
}
}
}</span>
View就是用户的操作界面,我们可以用js+css+控件的方法去构造这些界面。
基本上就是利用第三方框架根据需求去实现要达到的效果。在这里举几个常用的,面试中也会经常问到 比如 bootstrap , angualr, datatables ,booygrid.