public Boolean startSubTask(SubTask subtask, int UserId) { try { Activity ac = new Activity(); ac.Operation = "开始"; ac.Name = subtask.Name; ac.UserId = UserId; ac.SubTaskId = subtask.Id; ac.CreateTime = DateTime.Now; db.Set<Activity>().Add(ac); db.SaveChanges(); return true; } catch { return false; } }
public ActionResult AddSubTask(FormCollection form) { if (sprint.hasEnoughPower(Int32.Parse(Request["SprintId"]), (Session["User"] as LoginForm).Id)) { SubTask st = new SubTask(); st.Name = form["Name"]; st.UserId = (Session["User"] as LoginForm).Id; if (!string.IsNullOrEmpty(form["Assign"])) { st.Assign = Int32.Parse(form["Assign"]); } if (!string.IsNullOrEmpty(form["Desc"])) { st.Desc = form["Desc"]; } st.CreateTime = st.UpdateTime = DateTime.Now; if (!string.IsNullOrEmpty(form["StartTime"])) { st.StartTime = DateTime.Parse(form["StartTime"]); } if (!string.IsNullOrEmpty(form["Estimate"])) { st.Estimate = Int32.Parse(form["Estimate"]); } st.Sprint_Id = Int32.Parse(form["SprintId"]); st.Status = 0; if (sprint.addSubTask(st)) { return RedirectToAction("TaskBoard", new { Id = Int32.Parse(form["TaskId"]) }); } else { return RedirectToAction("ErrorPage", "Error", new { Message = "出错了,请与管理员联系" }); } } else { return RedirectToAction("ForbidPage", "Error"); } }