public IHttpActionResult DeleteChuanJia([FromUri]long id)
        {
            var result = false;
            var chuanJia = new Zs_ChuanJia();
            var dic = new Dictionary<string, string>();

            chuanJia = bChuanJia.Find(id);
            if (chuanJia == null) return NotFound();

            //删除传家
            result = bChuanJia.Delete(chuanJia);
            //实体列表
            var ganWuAttList = bChuanJiaAtt.Entities.Where(f => f.CJID == chuanJia.CJID);
            //遍历删除本地资源
            foreach (var item in ganWuAttList) sysFun.DeleteFile(item.AttType, item.AttUrl);
            //批量删除
            if (ganWuAttList.Count() > 0) bChuanJiaAtt.Delete(ganWuAttList);

            if (result)
            {
                dic.Add("result", "1");
                return Ok(dic);
            }
            else
            {
                dic.Add("result", "0");
                return Ok(dic);
            }
        }
        public IHttpActionResult AddChuanJia(AddChuanJiaModel model)
        {
            var chuanJia = new Zs_ChuanJia();
            var result = new ChuanJiaViewModel();

            //初始化实体
            chuanJia = sysFun.InitialEntity<AddChuanJiaModel, Zs_ChuanJia>(model, chuanJia);
            //添加传家有道
            chuanJia = bChuanJia.Add(chuanJia);
            //更新附件列表
            result = UpdateAttList(chuanJia);

            if (chuanJia.CJID > 0)
            {
                return Ok(result);
            }
            else
            {
                return Ok("添加失败");
            }
        }
        /// <summary>
        /// 更新附件列表
        /// </summary>
        /// <param name="chuanjia">传家信息</param>
        private ChuanJiaViewModel UpdateAttList(Zs_ChuanJia chuanjia)
        {
            var result = new ChuanJiaViewModel();

            //实体列表
            var chuanJiaAttList = bChuanJiaAtt.Entities.Where(f => f.CreateDate < chuanjia.UpdateDate && f.CJID == 0);
            //遍历删除本地资源
            foreach (var item in chuanJiaAttList) sysFun.DeleteFile(item.AttType, item.AttUrl);
            //批量删除
            if (chuanJiaAttList.Count() > 0) bChuanJiaAtt.Delete(chuanJiaAttList);
            //批量更新
            bChuanJiaAtt.Update(f => f.MID == chuanjia.MID, f => new Zs_ChuanJiaAtt { CJID = chuanjia.CJID });
            //实体列表
            chuanJiaAttList = bChuanJiaAtt.Entities.Where(f => f.MID == chuanjia.MID);

            result.ChuanJia = chuanjia;
            result.ChuanJiaAtt = chuanJiaAttList.ToList();
            return result;
        }
        public IHttpActionResult UpdateChuanJia(UpdateChuanJiaModel model)
        {
            var chuanJia = new Zs_ChuanJia();
            var result = new ChuanJiaViewModel();

            //初始化实体
            chuanJia = bChuanJia.Find(model.CJID);
            chuanJia = sysFun.InitialEntity<UpdateChuanJiaModel, Zs_ChuanJia>(model, chuanJia);
            //更新传家有道
            chuanJia = bChuanJia.UpdateEntity(chuanJia);
            //更新附件列表
            result = UpdateAttList(chuanJia);

            return Ok(result);
        }
        public IHttpActionResult GetChuanJiaById([FromUri]long id)
        {
            var chuanJia = new Zs_ChuanJia();
            var chuanJiaAtt = new List<Zs_ChuanJiaAtt>();
            var result = new List<ChuanJiaViewModel>();

            chuanJia = bChuanJia.Find(id);
            chuanJiaAtt = bChuanJiaAtt.Entities.Where(f => f.CJID == chuanJia.CJID).ToList();
            result.Add(new ChuanJiaViewModel() { ChuanJia = chuanJia, ChuanJiaAtt = chuanJiaAtt });

            return Ok(result);
        }
        public ActionResult ChuanJiaCreate(ChuanJiaCreate model)
        {
            if (!ModelState.IsValid) return View(model);

            var item = new Zs_ChuanJia();
            item = SysFun.Instance.InitialEntity<ChuanJiaCreate, Zs_ChuanJia>(model, item);
            item.UpdateDate = DateTime.Now;
            item = bChuanJia.Add(item);

            if (item.CJID > 0) return RedirectToAction("ChuanJiaList");

            return View(model);
        }