Ejemplo n.º 1
0
        public ActionResult Edit(Models.DictCensus.Edit vm)
        {
            var error = new List <string>();

            if (error.Count == decimal.Zero)
            {
                using (var db = new XkSystem.Models.DbContext())
                {
                    if (vm.DataEdit.Id > 0)
                    {
                        var tb = db.Set <Dict.Entity.tbDictCensus>().Find(vm.DataEdit.Id);
                        tb.DictCensusName = vm.DataEdit.DictCensusName;
                        tb.No             = vm.DataEdit.No == null?db.Table <Dict.Entity.tbDictCensus>().Select(d => d.No).DefaultIfEmpty(0).Max() + 1 : (int)vm.DataEdit.No;
                    }
                    else
                    {
                        var tb = new Dict.Entity.tbDictCensus()
                        {
                            DictCensusName = vm.DataEdit.DictCensusName,
                            No             = vm.DataEdit.No == null?db.Table <Dict.Entity.tbDictCensus>().Select(d => d.No).DefaultIfEmpty(0).Max() + 1 : (int)vm.DataEdit.No
                        };
                        db.Set <Dict.Entity.tbDictCensus>().Add(tb);
                    }
                    if (db.SaveChanges() > 0)
                    {
                        XkSystem.Areas.Sys.Controllers.SysUserLogController.Insert("新增/修改了户口类型");
                    }
                }
            }
            return(Code.MvcHelper.Post(error));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(int id = 0)
        {
            var vm = new Models.DictCensus.Edit();

            if (id > 0)
            {
                using (var db = new XkSystem.Models.DbContext())
                {
                    vm.DataEdit = (from p in db.Table <Dict.Entity.tbDictCensus>()
                                   where p.Id == id
                                   select p).FirstOrDefault();
                }
            }

            return(View(vm));
        }