예제 #1
0
        public ActionResult Edit(int id = 0)
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var vm = new Models.ExamPower.Edit();

                if (id != 0)
                {
                    var tb = (from p in db.Table <Exam.Entity.tbExamCourse>()
                              where p.Id == id
                              select new Dto.ExamPower.Edit
                    {
                        Id = p.Id,
                        FromDate = p.FromDate,
                        ToDate = p.ToDate
                    }).FirstOrDefault();
                    if (tb != null)
                    {
                        vm.ExamPowerEdit = tb;
                        vm.FromDate      = tb.FromDate.ConvertDateTimeToString(Code.Common.StringToDateTime);
                        vm.ToDate        = tb.ToDate.ConvertDateTimeToString(Code.Common.StringToDateTime);
                    }
                }
                return(View(vm));
            }
        }
예제 #2
0
        public ActionResult Edit(Models.ExamPower.Edit vm)
        {
            using (var db = new XkSystem.Models.DbContext())
            {
                var error = new List <string>();
                if (error.Count == decimal.Zero)
                {
                    if (vm.ExamPowerEdit.Id == 0)
                    {
                        //var tb = new Exam.Entity.tbExamCourse();
                        //tb.FromDate = vm.ExamPowerEdit.FromDate;
                        //tb.ToDate = vm.ExamPowerEdit.ToDate;

                        //db.Set<Exam.Entity.tbExamCourse>().Add(tb);
                        //if (db.SaveChanges() > 0)
                        //{
                        //    XkSystem.Areas.Sys.Controllers.SysUserLogController.Insert("添加课程录入时间");
                        //}
                    }
                    else
                    {
                        var tb = (from p in db.Table <Exam.Entity.tbExamCourse>()
                                  where p.Id == vm.ExamPowerEdit.Id
                                  select p).FirstOrDefault();
                        if (tb != null)
                        {
                            tb.FromDate = vm.FromDate.ConvertToDateTime();
                            tb.ToDate   = vm.ToDate.ConvertToDateTime();
                            if (db.SaveChanges() > 0)
                            {
                                XkSystem.Areas.Sys.Controllers.SysUserLogController.Insert("修改课程录入时间");
                            }
                        }
                        else
                        {
                            error.AddError(Resources.LocalizedText.MsgNotFound);
                        }
                    }
                }

                return(Code.MvcHelper.Post(error));
            }
        }