Exemple #1
0
 /// <summary>
 /// 前端model转后端entity
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public void modelToEntity(FirstLevelDirModel model, ref FirstLevel entity)
 {
     if (model != null)
     {
         if (model.id.HasValue)
         {
             entity.id = model.id.Value;
         }
         if (model.orderId.HasValue)
         {
             entity.orderId = model.orderId.Value;
         }
         if (model.createdDate.HasValue)
         {
             entity.createdDate = model.createdDate.Value;
         }
         if (model.lastUpdatedDate.HasValue)
         {
             entity.lastUpdatedDate = model.lastUpdatedDate ?? null;
         }
         if (!string.IsNullOrEmpty(model.createdBy))
         {
             entity.createdBy = model.createdBy?.ToString();
         }
         if (!string.IsNullOrEmpty(model.lastUpdatedBy))
         {
             entity.lastUpdatedBy = model.lastUpdatedBy?.ToString();
         }
         if (!string.IsNullOrEmpty(model.content))
         {
             entity.midContent = model.content?.ToString();
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// 修改或者增加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult changeFirstLevelDir(FirstLevelDirModel condition, FirstLevelDirModel_update model_upd)
        {
            FirstLevelDirModel          model = new FirstLevelDirModel(model_upd);
            Result <FirstLevelDirModel> result;
            StringBuilder sb = new StringBuilder("");

            if (model.id.HasValue)
            {
                model.lastUpdatedBy   = User.Identity.Name;
                model.lastUpdatedDate = DateTime.Now;
                result = layer.updateFirstLevelDir(model);
                sb.Append("修改");
            }
            else
            {
                model.createdBy   = User.Identity.Name;
                model.createdDate = DateTime.Now;
                result            = layer.addFirstLevelDir(model);
                sb.Append("增加");
            }

            if (result.success)
            {
                TempData["Msg"] = new Message(sb.Append("成功").ToString());
            }
            else
            {
                TempData["Msg"] = new Message(sb.Append("失败").ToString());
            }
            return(RedirectToAction("searchFirstLevelDir", condition));
        }
Exemple #3
0
        public ActionResult Index(FirstLevelDirModel model)
        {
            Pager <List <FirstLevelDirModel> > pager = new Pager <List <FirstLevelDirModel> >();

            ViewBag.condition = model;
            return(View(pager));
        }
Exemple #4
0
        /// <summary>
        /// search
        /// </summary>
        /// <param name="model"></param>
        /// <param name="pager"></param>
        /// <returns></returns>
        public ActionResult searchFirstLevelDir(FirstLevelDirModel model, Pager <FirstLevelDirModel> pager)
        {
            if (model != null)
            {
                pager.data = model;
            }
            Pager <List <FirstLevelDirModel> > result = layer.getFirstLevelDir(pager);

            ViewBag.condition = model;
            return(View("Index", result));
        }
Exemple #5
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Result <FirstLevelDirModel> updateFirstLevelDir(FirstLevelDirModel model)
        {
            FirstLevelDirDAO            dao    = new FirstLevelDirDAO();
            Result <FirstLevelDirModel> result = new Result <FirstLevelDirModel>();

            if (dao.updateFirstLevelDir(model) != 1)
            {
                result.success = false;
            }
            return(result);
        }
Exemple #6
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int updateFirstLevelDir(FirstLevelDirModel model)
        {
            DirDbContext context = new DirDbContext();
            var          result  = context.firstLevels.Where(x => x.id > 0 && x.activityFlag == 1);

            result = model.id.HasValue ? result.Where(x => x.id == model.id.Value) : null;
            if (result != null)
            {
                FirstLevel entity = result.First();
                modelToEntity(model, ref entity);
            }
            return(context.SaveChanges());
        }
Exemple #7
0
        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int addFirstLevelDir(FirstLevelDirModel model)
        {
            DirDbContext context = new DirDbContext();

            if (model != null)
            {
                FirstLevel entity = new FirstLevel();
                modelToEntity(model, ref entity);
                DirTools tools = new DirTools();
                entity.afterContent = tools.afterContent;
                entity.beforContent = tools.beforContent;
                entity.activityFlag = 1;
                var result = context.firstLevels.Add(entity);
            }
            return(context.SaveChanges());
        }
Exemple #8
0
        /// <summary>
        /// 后端entity转前端model
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public FirstLevelDirModel entityToModel(FirstLevel model)
        {
            FirstLevelDirModel entity = new FirstLevelDirModel();

            if (model != null)
            {
                entity.id              = model.id;
                entity.orderId         = model.orderId;
                entity.createdBy       = model.createdBy;
                entity.createdDate     = model.createdDate;
                entity.lastUpdatedBy   = model.lastUpdatedBy;
                entity.lastUpdatedDate = model.lastUpdatedDate;
                entity.content         = model.midContent;
            }
            return(entity);
        }
Exemple #9
0
 /// <summary>
 /// delete
 /// </summary>
 /// <param name="condition"></param>
 /// <param name="model_upd"></param>
 /// <returns></returns>
 public ActionResult deleteFirstLevelDir(FirstLevelDirModel condition, FirstLevelDirModel_update model_upd)
 {
     if (model_upd.id_upd.HasValue)
     {
         StringBuilder sb = new StringBuilder("删除");
         Result <FirstLevelDirModel> result = layer.deleteFirstLevelDir(model_upd.id_upd.Value);
         if (result.success)
         {
             TempData["Msg"] = new Message(sb.Append("成功").ToString());
         }
         else
         {
             TempData["Msg"] = new Message(sb.Append("失败").ToString());
         }
     }
     return(RedirectToAction("searchFirstLevelDir", condition));
 }
Exemple #10
0
        /// <summary>
        /// 获取总条数
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int getFirstLevelDirCount(FirstLevelDirModel model)
        {
            DirDbContext context = new DirDbContext();
            var          result  = context.firstLevels.Where(x => x.id > 0 && x.activityFlag == 1);

            if (model.id.HasValue)
            {
                result = result.Where(x => x.id == model.id.Value);
            }
            else
            {
                result = model.orderId.HasValue ? result : result.Where(x => x.orderId == model.orderId);
                result = string.IsNullOrEmpty(model.content) ? result : result.Where(x => x.midContent == model.content);
                result = string.IsNullOrEmpty(model.createdBy) ? result : result.Where(x => x.createdBy == model.createdBy);
                result = string.IsNullOrEmpty(model.lastUpdatedBy) ? result : result.Where(x => x.lastUpdatedBy == model.lastUpdatedBy);
                result = model.createdDate.HasValue ? result : result.Where(x => x.createdDate == model.createdDate);
                result = model.lastUpdatedDate.HasValue ? result : result.Where(x => x.lastUpdatedDate == model.lastUpdatedDate);
            }
            return(result.Count());
        }
Exemple #11
0
        /// <summary>
        /// 通过条件进行查询
        /// </summary>
        /// <param name="pager"></param>
        /// <returns></returns>
        public Pager <List <FirstLevelDirModel> > getFirstLevelDir(Pager <FirstLevelDirModel> pager)
        {
            FirstLevelDirDAO dao = new FirstLevelDirDAO();

            Pager <List <FirstLevelDirModel> > resultPager = new Pager <List <FirstLevelDirModel> >();
            List <FirstLevelDirModel>          resultList  = new List <FirstLevelDirModel>();
            List <FirstLevel> firstLevelList = new List <FirstLevel>();

            firstLevelList = dao.getFirstLevelDir(pager);
            foreach (var item in firstLevelList)
            {
                FirstLevelDirModel demo = entityToModel(item);
                resultList.Add(demo);
            }
            resultPager.data = resultList;
            resultPager.page = pager.page;
            //resultPager.recTotal = 89;
            resultPager.recTotal = dao.getFirstLevelDirCount(pager.data);
            return(resultPager);
        }