public void Create(LeaveProcess model)
 {
     model.Adddate = DateTime.Now;
     model.Owner = db.Users.Single(u => u.ID == model.Owner.ID);
     db.LeaveProcesses.Add(model);
     db.SaveChanges();
 }
 public void Update(LeaveProcess model)
 {
     var old = db.LeaveProcesses.Single(l => l.InstanceID == model.InstanceID);
     old.Bookmark = model.Bookmark;
     old.NextProcessAuthority = model.NextProcessAuthority;
     old.Result = model.Result;
     old.Finished = model.Finished;
     old.Passed = model.Passed;
     db.SaveChanges();
 }
        public ActionResult CreateLeaveProcess(LeaveProcess leaveProcess)
        {
            if (leaveProcess.StartDate.Value > leaveProcess.EndDate.Value)
            {
                ModelState.AddModelError("StartDate", "开始时间不能晚于结束时间!");
            }

            if (ModelState.IsValid)
            {
                WorkFlowContext.CreateAndRun_LeaveProcess(leaveProcess, UserService.GetUserByCookie());
                return RedirectToAction("Index");
            }
            return View(leaveProcess);
        }