Beispiel #1
0
        public ActionResult Edit(Models.PeriodType.Edit vm)
        {
            var error = new List <string>();

            if (error.Count == decimal.Zero)
            {
                using (var db = new XkSystem.Models.DbContext())
                {
                    if (vm.PeriodTypeEdit.Id > 0)
                    {
                        var tb = db.Set <Basis.Entity.tbPeriodType>().Find(vm.PeriodTypeEdit.Id);
                        tb.Color          = vm.PeriodTypeEdit.Color;
                        tb.No             = vm.PeriodTypeEdit.No > 0 ? vm.PeriodTypeEdit.No : db.Table <Basis.Entity.tbPeriodType>().Where(d => d.Id == vm.PeriodTypeEdit.Id).OrderByDescending(d => d.No).FirstOrDefault().No + 1;
                        tb.PeriodTypeName = vm.PeriodTypeEdit.PeriodTypeName;
                    }
                    else
                    {
                        var tb = new Basis.Entity.tbPeriodType()
                        {
                            Color          = vm.PeriodTypeEdit.Color,
                            No             = vm.PeriodTypeEdit.No,
                            PeriodTypeName = vm.PeriodTypeEdit.PeriodTypeName
                        };
                        db.Set <Basis.Entity.tbPeriodType>().Add(tb);
                    }

                    if (db.SaveChanges() > 0)
                    {
                        XkSystem.Areas.Sys.Controllers.SysUserLogController.Insert("添加/修改了节次类型");
                    }
                }
            }

            return(Code.MvcHelper.Post(error));
        }
Beispiel #2
0
        public ActionResult Edit(int id = 0)
        {
            var vm = new Models.PeriodType.Edit();

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

            return(View(vm));
        }