如何做一个基于ASP.NET MVC 网站(六)

最后,我们讲一下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.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值