Ejemplo n.º 1
0
 public ActionResult List(Models.MoralItem.List vm)
 {
     return(Code.MvcHelper.Post(null, Url.Action("List", new
     {
         moralId = vm.MoralId,
         moralGroupId = vm.MoralGroupId,
         searchText = vm.SearchText,
         moralKindId = vm.MoralKindId
     })));
 }
Ejemplo n.º 2
0
        public ActionResult List()
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm    = new Models.MoralItem.List();
                var moral = db.Table <Moral.Entity.tbMoral>().FirstOrDefault(d => d.Id == vm.MoralId);
                if (moral == null)
                {
                    moral = (from p in db.Table <Moral.Entity.tbMoral>() select p).FirstOrDefault();
                }
                if (moral == null)
                {
                    return(RedirectToAction("List", "Moral"));
                }
                vm.MoralId   = moral.Id;
                vm.MoralName = moral.MoralName;
                vm.MoralType = moral.MoralType;

                var tb = from p in db.Table <Moral.Entity.tbMoralItem>()
                         where p.tbMoralGroup.tbMoral.Id == vm.MoralId
                         select p;
                if (!string.IsNullOrWhiteSpace(vm.SearchText))
                {
                    tb = tb.Where(p => p.MoralItemName.Contains(vm.SearchText));
                }
                if (vm.MoralGroupId.HasValue && vm.MoralGroupId.Value > 0)
                {
                    tb = tb.Where(p => p.tbMoralGroup.Id == vm.MoralGroupId.Value);
                }

                if (vm.MoralKindId.HasValue && vm.MoralKindId.Value > -1)
                {
                    tb = tb.Where(p => (int)p.MoralItemKind == vm.MoralKindId);
                }

                vm.MoralItemList = (from p in tb
                                    orderby p.tbMoralGroup.Id, p.MoralItemName
                                    select new Dto.MoralItem.List()
                {
                    Id = p.Id,
                    No = p.No,
                    MoralItemName = p.MoralItemName,
                    InitScore = p.InitScore,
                    MaxScore = p.MaxScore,
                    MinScore = p.MinScore,
                    DefaultValue = p.DefaultValue,
                    MoralExpress = p.MoralExpress,
                    MoralItemKind = p.MoralItemKind,
                    MoralGroupName = p.tbMoralGroup.MoralGroupName,
                    MoralItemOperateType = p.MoralItemOperateType,
                    MoralItemType = p.MoralItemType,
                    AutoCheck = p.AutoCheck
                }).ToList();
                vm.MoralGroupList = MoralGroupController.SelectList(vm.MoralId);

                vm.MoralKindList = typeof(Code.EnumHelper.MoralItemKind).ToItemList();
                vm.MoralKindList.Insert(0, new SelectListItem()
                {
                    Text = "评价对象", Value = "-1"
                });
                return(View(vm));
            }
        }