Esempio n. 1
0
 public Boolean addSprint(int UserId,Sprint sp)
 {
     try {
         db.Set<User>().Find(UserId).Sprint.Add(sp);
     }
     catch
     {
         return false;
     }
     return true;
 }
Esempio n. 2
0
        public ActionResult CreateSprint(FormCollection form)
        {
            if (task.hasEnoughPower(Int32.Parse(form["TaskId"]), (Session["User"] as LoginForm).Id))
            {
                Sprint sp = new Sprint();
                sp.Name = form["SprintName"];
                sp.Desc = form["SprintDesc"];
                sp.Task_Id = Int32.Parse(form["TaskId"]);
                sp.Status = 0;
                sp.UserId = (Session["User"] as LoginForm).Id;
                sp.CreateTime = sp.UpdateTime = DateTime.Now;

                foreach (var assign in form["Assign"].Replace(@"""", "").Split(',').ToList())
                {
                    if (!user.addSprint(Int32.Parse(assign), sp))
                    {
                        return RedirectToAction("ErrorPage", "Error", new { Message = "出错了,请与管理员联系" });
                    }
                }
                try
                {
                    sprint.save();
                    Activity ac = new Activity();
                    ac.CreateTime = DateTime.Now;
                    ac.SprintId = sp.Id;
                    ac.Operation = "创建";
                    ac.Name = sp.Name;
                    ac.UserId = (Session["User"] as LoginForm).Id;
                    (new ActivityService()).AddActivity(ac);
                    task.save();
                }
                catch
                {
                    return RedirectToAction("ErrorPage", "Error", new { Messsage = "出错了,请与管理员联系!" });
                }
                return RedirectToAction("TaskBoard", new { Id = sp.Task_Id });

            }
            return RedirectToAction("ForbidPage", "Error");
        }