Ejemplo n.º 1
0
        public void DashboardActiveItemCounts()
        {
            // Arrange

            //dashboard (active) counts
            LayoutController lc = new LayoutController();

            lc.TestUser = user;
            DashboardViewModel dashboard = (DashboardViewModel)lc.Dashboard().ViewData.Model;

            int lProjectCount = dashboard.ActiveProjects.Count();
            int lTaskCount    = dashboard.ActiveTasks.Count();
            int lActionCount  = dashboard.ActiveActions.Count();

            //////////////////////////////////////////

            // Act

            //create project
            project = CreateProject();

            //create task
            task = CreateTask(project.ID);

            //create action
            action = CreateAction(task.ID);

            //////////////////////////////////////////

            //Assert

            Assert.AreEqual <int>(db.GetMyProjects(user).Count(), lProjectCount + 1);
            Assert.AreEqual <int>(db.GetMyTasks(user).Count(), lTaskCount + 1);
            Assert.AreEqual <int>(db.GetMyActions(user).Count(), lActionCount + 1);
        }
Ejemplo n.º 2
0
        // GET: /Pomodoro/ChangeAction/5?parent=1
        public ActionResult ChangeAction(int?id, int?parent)
        {
            if (id == null || parent.HasValue == false)
            {
                return(Redirect(Request.GetReferrerUrlOrCurrent()));
            }
            Pomodoro pomo = db.GetPomodoroById(User, id.Value);

            if (pomo == null)
            {
                return(HttpNotFound());
            }
            if (pomo.Status == PomodoroStatus.Working || pomo.Status == PomodoroStatus.Unconfirmed)
            {
                //cannot perform change
                TempData["UpdateError"] = Settings.MSG_UNSUCCESSFUL_BECAUSE_WORKING;
                return(Redirect(Request.GetReferrerUrlOrCurrent()));
            }
            Action action = db.GetActionById(User, parent.Value);

            if (action == null)
            {
                return(HttpNotFound());
            }

            pomo.ActionID        = parent.Value;
            db.Entry(pomo).State = EntityState.Modified;
            db.SaveChanges();

            TempData["UpdateInfo"] = Settings.MSG_SUCCESSFUL_UPDATE;
            return(Redirect(Request.GetReferrerUrlOrCurrent()));
        }
Ejemplo n.º 3
0
        public ActionResult CreateActionOld(int?id, int?ct, string text)
        {
            if (id == null)
            {
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                return(Redirect(Request.GetReferrerUrlOrCurrent()));
            }
            Task task = db.GetTaskById(User, id.Value);

            if (task == null)
            {
                return(HttpNotFound());
            }

            Action newAction = new Action();

            newAction.TaskID = id.Value;
            if (ct.HasValue)
            {
                CollectedThing collectedthing = db.GetCollectedThingById(User, ct.Value);
                if (collectedthing != null)
                {
                    newAction.SetName(collectedthing.Name);
                    ViewBag.collectedThingID = ct.Value;
                }
            }
            else if (string.IsNullOrWhiteSpace(text) == false)
            {
                newAction.SetName(text);
            }
            ViewBag.NewAction = newAction;
            return(View(task));
        }
Ejemplo n.º 4
0
        public void DbItemCounts()
        {
            // Arrange

            int dbProjectCount = db.GetMyProjects(user).Count();
            int dbTaskCount    = db.GetMyTasks(user).Count();
            int dbActionCount  = db.GetMyActions(user).Count();

            //////////////////////////////////////////

            // Act

            //create project
            project = CreateProject();

            //create task
            task = CreateTask(project.ID);

            //create action
            action = CreateAction(task.ID);

            //////////////////////////////////////////

            // Assert

            Assert.AreEqual <int>(db.GetMyProjects(user).Count(), dbProjectCount + 1);
            Assert.AreEqual <int>(db.GetMyTasks(user).Count(), dbTaskCount + 1);
            Assert.AreEqual <int>(db.GetMyActions(user).Count(), dbActionCount + 1);
        }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "ID,Name,Description,EndDate,Estimate,TaskID,Deadline,Status")] Action newAction) //var name cannot be action
        {
            int collectedThingID = 0;

            if (Request != null)
            {
                Int32.TryParse(Request.Params["collectedThingID"], out collectedThingID);
            }

            newAction.Task = db.GetTaskById(User, newAction.TaskID);
            if (ModelState.IsValid)
            {
                //create action
                db.Actions.Add(newAction);
                //set creation date
                newAction.CreationDate = DateTime.UtcNow;
                if (collectedThingID > 0)
                {
                    //delete associated collected thing
                    CollectedThing collectedThing = db.GetCollectedThingById(User, collectedThingID);
                    db.CollectedThings.Remove(collectedThing);
                }

                db.SaveChanges();
                return(RedirectToAction("ActionList", "Task", new { id = newAction.TaskID }));
            }

            ViewBag.TaskID = new SelectList(db.GetMyTasks(User), "ID", "Code", newAction.TaskID);
            return(View(newAction));
        }
Ejemplo n.º 6
0
        public ActionResult Work(int?id)
        {
            //(first) pomodoro with status = working(if exists)
            Pomodoro pomodoro = db.GetMyPomodoros(User).FirstOrDefault(p => p.Status == PomodoroStatus.Working);

            if (pomodoro != null)
            {
                if (id.HasValue && id.Value == pomodoro.ActionID)
                {
                    return(RedirectToAction("Working", "Pomodoro"));
                }
                else
                {
                    return(RedirectToAction("CancelWorking", "Pomodoro", new { id = id }));
                }
            }

            Action action = null;

            //ToDo: Check conflicts
            if (id.HasValue)
            {
                action = db.Actions.Find(id);
                if (action != null)
                {
                    UserManager <ApplicationUser> manager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db));
                    var currentUser = manager.FindById(User.Identity.GetUserId());
                    currentUser.ActionID        = id.Value;
                    db.Entry(currentUser).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }
            return(View(action));
        }
Ejemplo n.º 7
0
        public void TestStatusNew()
        {
            // Arrange

            //////////////////////////////////////////

            // Act

            //create project
            project = CreateProject();
            //create task
            task = CreateTask(project.ID);
            //create action
            action = CreateAction(task.ID);

            //////////////////////////////////////////

            // Assert

            //project status
            Assert.IsTrue(project.Status == Status.Active);
            //task status
            Assert.IsTrue(task.Status == Status.Active);
            //action status
            Assert.IsTrue(action.Status == Status.Active);
        }
Ejemplo n.º 8
0
        // GET: /Task/CreateAction/5
        public ActionResult CreateAction(string op, int?id, int?ct, string text)
        {
            ActionResult result = loadView(id, Operation.CreateAction);

            if ((result is HttpStatusCodeResult || result is HttpNotFoundResult) == false)
            {
                Action newAction = (Action)ViewBag.NewAction;

                newAction.TaskID = id.Value;
                if (ct.HasValue)
                {
                    CollectedThing collectedthing = db.GetCollectedThingById(User, ct.Value);
                    if (collectedthing != null)
                    {
                        newAction.SetName(collectedthing.Name);
                        ViewBag.collectedThingID = ct.Value;
                    }
                }
                else if (string.IsNullOrWhiteSpace(text) == false)
                {
                    newAction.SetName(text);
                }
            }
            return(result);
        }
Ejemplo n.º 9
0
        private void checkPlanification(Action action, DateTime dateFrom, int startTimePeriod, int endTimePeriod)
        {
            DateTime start = dateFrom.AddMinutes(startTimePeriod * Settings.POMOCYCLE);
            DateTime end   = dateFrom.AddMinutes(endTimePeriod * Settings.POMOCYCLE);

            if (start.AddMinutes(Settings.POMOCYCLE) > end)
            {
                throw new CalendarException(CalendarWarning.NonPositiveInterval, "Planification must have a minimum of one pomodoro");
            }
            if (start < DateTime.UtcNow.ToUserLocalTime(action.Owner.TimeZoneId))
            {
                throw new CalendarException(CalendarWarning.PastTime, "Planification datetime must be in the future");
            }
            if (action == null || action.Status != Status.Active)
            {
                throw new CalendarException(CalendarWarning.InvalidAction, "Invalid or inactive action (ID: " + action.ID + ")");
            }
            List <Pomodoro> conflictingPomodoros = db.GetMyPomodoros(User).Where(p => p.Start.HasValue).AsEnumerable().Where(p =>
                                                                                                                             ((p.StartLocal.Value <= start && DbFunctions.AddMinutes(p.StartLocal.Value, Settings.POMOCYCLE) > start) ||
                                                                                                                              (p.StartLocal.Value < end && DbFunctions.AddMinutes(p.StartLocal.Value, Settings.POMOCYCLE) >= end))).ToList();

            if (conflictingPomodoros.Count > 0)
            {
                throw new ConflictCalendarException(CalendarWarning.Conflict, conflictingPomodoros);
            }
        }
Ejemplo n.º 10
0
        // GET: /Action/Select/5
        public ActionResult Select(int?id)
        {
            if (id == null)
            {
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                return(Redirect(Request.GetReferrerUrlOrCurrent()));
            }
            Action action = db.GetActionById(User, id.Value);

            if (action == null)
            {
                return(HttpNotFound());
            }
            UserManager <ApplicationUser> manager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db));
            ApplicationUser currentUser           = manager.FindById(User.Identity.GetUserId());

            if (currentUser.WorkingPanelAvailable && action.IsSelectable)
            {
                currentUser.ActionID        = id.Value;
                db.Entry(currentUser).State = EntityState.Modified;
                db.SaveChanges();
            }
            else
            {
                TempData["UpdateError"] = Settings.MSG_UNSUCCESSFUL_BECAUSE_WORKING;
            }

            return(Redirect(Request.GetReferrerUrlOrCurrent()));
        }
Ejemplo n.º 11
0
        public ActionResult DeleteConfirmed(int id, String UrlReferrer)
        {
            Action action = db.GetActionById(User, id);

            if (action == null)
            {
                return(HttpNotFound());
            }
            //check if it's the selected action
            if (action.ContainsSelectedAction)
            {
                //neither working nor pending confirmation
                if (action.Owner.WorkingPanelAvailable)
                {
                    //clear selected action
                    action.Owner.ActionID        = null;
                    db.Entry(action.Owner).State = EntityState.Modified;
                }
                else
                {
                    //cannot perform change
                    return(RedirectToAction("Delete", new { id = id }));
                }
            }
            int taskID = action.TaskID;

            db.Actions.Remove(action);
            db.SaveChanges();

            TempData["UpdateInfo"] = Settings.MSG_SUCCESSFUL_DELETE;
            return(RedirectToAction("Details", "Task", new { id = taskID }));
        }
Ejemplo n.º 12
0
        // GET: /Action/ChangeStatus/5?status=1
        public ActionResult ChangeStatus(int?id, Status?status)
        {
            if (id == null || status.HasValue == false || Request.UrlReferrer == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Action action = db.GetActionById(User, id.Value);

            if (action == null)
            {
                return(HttpNotFound());
            }
            if (status.Value != Status.Active)
            {
                //check if it's the selected action
                if (action.ContainsSelectedAction)
                {
                    //not working nor pending confirmation
                    if (action.Owner.WorkingPanelAvailable)
                    {
                        //clear selected action
                        action.Owner.ActionID        = null;
                        db.Entry(action.Owner).State = EntityState.Modified;
                    }
                    else
                    {
                        //cannot perform change
                        TempData["UpdateError"] = Settings.MSG_UNSUCCESSFUL_BECAUSE_WORKING;
                        return(Redirect(Request.UrlReferrer.AbsoluteUri));
                    }
                }
            }
            //update end date
            if (Action.IsFinishedStatus(status.Value))
            {
                //if no end date
                if (action.EndDate.HasValue == false)
                {
                    action.EndDate = DateTime.UtcNow;
                }
            }
            else
            {
                //remove end date
                action.EndDate = null;
            }

            action.Status          = status.Value;
            db.Entry(action).State = EntityState.Modified;
            db.SaveChanges();

            TempData["UpdateInfo"] = Settings.MSG_SUCCESSFUL_UPDATE;
            return(Redirect(Request.UrlReferrer.AbsoluteUri));
        }
Ejemplo n.º 13
0
        public ActionResult Edit([Bind(Include = "ID,Name,Description,EndDate,Estimate,TaskID,Deadline,Status,IsPersistent,Priority,CreationDate")] Action newAction) //var name cannot be action
        {
            if (ModelState.IsValid)
            {
                db.Entry(newAction).State = EntityState.Modified;
                db.SaveChanges();

                TempData["UpdateInfo"] = Settings.MSG_SUCCESSFUL_UPDATE;
                return(JavaScript("window.location = '" + Url.Action("Details", new { id = newAction.ID }) + "'"));
            }
            newAction = db.GetActionById(User, newAction.ID);
            return(PartialView(newAction));
        }
Ejemplo n.º 14
0
        public ActionResult WorkHistory(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Action action = db.GetActionById(User, id.Value);

            if (action == null)
            {
                return(HttpNotFound());
            }
            return(View("Containers/_PomodoroSetsList", action));
        }
Ejemplo n.º 15
0
        public ActionResult DetailsOld(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Action action = db.GetActionById(User, id.Value);

            if (action == null)
            {
                return(HttpNotFound());
            }
            return(View(action));
        }
Ejemplo n.º 16
0
        public ActionResult Charts(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Action action = db.GetActionById(User, id.Value);

            if (action == null)
            {
                return(HttpNotFound());
            }

            return(View("Containers/_WorkCharts", action));
        }
Ejemplo n.º 17
0
        public ActionResult Planify(int?id)
        {
            Action action = null;

            if (id.HasValue)
            {
                action = db.Actions.Find(id.Value);
            }

            ViewBag.dateFrom        = Settings.DefaultPlanifyDateTime.ToString("dd/MM/yyyy");
            ViewBag.startTimePeriod = startTimeSelectList;
            ViewBag.endTimePeriod   = endTimeSelectList;

            return(View(action));
        }
Ejemplo n.º 18
0
        public void CreationDateTime()
        {
            // Arrange

            DateTime dtBeforeCreatingProject = DateTime.Now;

            Thread.Sleep(500);

            //////////////////////////////////////////

            // Act

            //create project
            project = CreateProject();

            Thread.Sleep(500);
            DateTime dtAfterCreatingProject = DateTime.Now;

            Thread.Sleep(500);

            //create task
            task = CreateTask(project.ID);

            Thread.Sleep(500);
            DateTime dtAfterCreatingTask = DateTime.Now;

            Thread.Sleep(500);

            //create action
            action = CreateAction(task.ID);

            Thread.Sleep(500);
            DateTime dtAfterCreatingAction = DateTime.Now;

            //////////////////////////////////////////

            // Assert

            //project creation date
            Assert.IsTrue(project.CreationDate > dtBeforeCreatingProject);
            Assert.IsTrue(project.CreationDate < dtAfterCreatingProject);
            //task creation date
            Assert.IsTrue(task.CreationDate > dtAfterCreatingProject);
            Assert.IsTrue(task.CreationDate < dtAfterCreatingTask);
            //action creation date
            Assert.IsTrue(action.CreationDate > dtAfterCreatingTask);
            Assert.IsTrue(action.CreationDate < dtAfterCreatingAction);
        }
Ejemplo n.º 19
0
        private ActionResult loadView(int?id, Operation operation)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Action action = db.GetActionById(User, id.Value);

            if (action == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Operation       = operation;
            ViewBag.NotSelectedTags = action.GetNotSelectedTags(db.GetMyTags(User)).ToList();
            return(View("Action", action));
        }
Ejemplo n.º 20
0
        // GET: /Action/ChangeTask/5?parent=1
        public ActionResult ChangeTask(int?id, int?parent)
        {
            if (id == null || parent.HasValue == false)
            {
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                return(Redirect(Request.GetReferrerUrlOrCurrent()));
            }
            ;
            Action action = db.GetActionById(User, id.Value);

            if (action == null)
            {
                return(HttpNotFound());
            }
            Task task = db.GetTaskById(User, parent.Value);

            if (task == null)
            {
                return(HttpNotFound());
            }
            if (task.Status != Status.Active)
            {
                //check if contains the selected action
                if (action.ContainsSelectedAction)
                {
                    //not working nor pending confirmation
                    if (action.Owner.WorkingPanelAvailable)
                    {
                        //clear selected action
                        action.Owner.ActionID        = null;
                        db.Entry(action.Owner).State = EntityState.Modified;
                    }
                    else
                    {
                        //cannot perform change
                        TempData["UpdateError"] = Settings.MSG_UNSUCCESSFUL_BECAUSE_WORKING;
                        return(Redirect(Request.GetReferrerUrlOrCurrent()));
                    }
                }
            }
            action.TaskID          = parent.Value;
            db.Entry(action).State = EntityState.Modified;
            db.SaveChanges();

            TempData["UpdateInfo"] = Settings.MSG_SUCCESSFUL_UPDATE;
            return(RedirectToAction("Details", new { id = id.Value }));
        }
Ejemplo n.º 21
0
        public ActionResult Planify(int ActionID, DateTime dateFrom, int startTimePeriod, int endTimePeriod, string submitButton)
        {
            Action action = db.Actions.Find(ActionID);

            if (submitButton == "Check")
            {
                try
                {
                    checkPlanification(action, dateFrom, startTimePeriod, endTimePeriod);
                }
                catch (CalendarException cex)
                {
                    ModelState.AddModelError(string.Empty, cex.Message);
                }
            }
            if (ModelState.IsValid)
            {
                bool     save    = false;
                DateTime start   = dateFrom.AddMinutes(startTimePeriod * Settings.POMOCYCLE);
                DateTime end     = dateFrom.AddMinutes(endTimePeriod * Settings.POMOCYCLE);
                DateTime current = start;

                while (current < end)
                {
                    save = true;
                    var p = new Pomodoro();
                    p.ActionID = ActionID;
                    p.Status   = PomodoroStatus.Planified;
                    p.Start    = current;
                    db.Pomodoros.Add(p);
                    current = current.AddMinutes(Settings.POMOCYCLE);
                }
                if (save)
                {
                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.dateFrom        = Settings.DefaultPlanifyDateTime.ToString("dd/MM/yyyy");
            ViewBag.startTimePeriod = startTimeSelectList;
            ViewBag.endTimePeriod   = endTimeSelectList;
            return(View(action));
        }
Ejemplo n.º 22
0
        private void SetTagsToAction(string[] selectedTagCodes, Action actionToUpdate)
        {
            if (selectedTagCodes == null || selectedTagCodes.Length == 0)
            {
                return;
            }
            var selectedTagCodesHS = new HashSet <string>(selectedTagCodes);
            var actionTagCodes     = new HashSet <string>
                                         (actionToUpdate.OwnAndInheritedTags.Select(c => c.Code));

            foreach (var tag in db.Tags)
            {
                if (selectedTagCodesHS.Contains(tag.Code) &&
                    actionTagCodes.Contains(tag.Code) == false)
                {
                    actionToUpdate.Tags.Add(tag);
                }
            }
        }
Ejemplo n.º 23
0
        private ActionResult loadView(int?id, Operation operation)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var task = db.GetTaskById(User, id.Value);

            if (task == null)
            {
                return(HttpNotFound());
            }
            Action newAction = new Action();

            newAction.TaskID  = id.Value;
            ViewBag.NewAction = newAction;

            ViewBag.Operation       = operation;
            ViewBag.NotSelectedTags = task.GetNotSelectedTags(db.GetMyTags(User)).ToList();
            return(View("Task", task));
        }
Ejemplo n.º 24
0
        public ActionResult CreateAction([Bind(Include = "ID,Name,Description,EndDate,Estimate,TaskID,Deadline,Status,IsPersistent,Priority")] Action newAction) //var name cannot be action
        {
            if (ModelState.IsValid)
            {
                db.Actions.Add(newAction);
                //set creation date
                newAction.CreationDate = DateTime.UtcNow;

                //delete associated collected thing
                int collectedThingID = 0;
                if (Request != null)
                {
                    Int32.TryParse(Request.Params["collectedThingID"], out collectedThingID);
                    if (collectedThingID > 0)
                    {
                        CollectedThing collectedThing = db.GetCollectedThingById(User, collectedThingID);
                        if (collectedThing != null)
                        {
                            db.CollectedThings.Remove(collectedThing);
                        }
                    }
                }

                db.SaveChanges();
                TempData["UpdateInfo"] = Settings.MSG_SUCCESSFUL_CREATE;
                if (Request != null && Url != null) //avoid null reference exceptions when testing
                {
                    string button = Request.Form["submitButton"];
                    if (button == "1")
                    {
                        return(JavaScript("window.location = '" + Url.Action("CreateAction", new { id = newAction.TaskID }) + "'"));
                    }
                    return(JavaScript("window.location = '" + Url.Action("Details", "Action", new { id = newAction.ID }) + "'"));
                }
            }
            //load task for the view
            newAction.Task    = db.GetTaskById(User, newAction.TaskID);
            ViewBag.NewAction = newAction;
            return(PartialView(newAction.Task));
        }
Ejemplo n.º 25
0
        public Action CreateAction(int taskID)
        {
            // Arrange

            //////////////////////////////////////////

            // Act

            Action action = new Action()
            {
                Name   = "Test Action",
                TaskID = taskID
            };
            ActionResult actionResult = taskController.CreateAction(action);

            //////////////////////////////////////////

            // Assert
            Assert.IsNotNull(actionResult);

            return(action);
        }
Ejemplo n.º 26
0
        public RedirectResult AutoSelect()
        {
            ApplicationUser currentUser = manager.FindById(User.Identity.GetUserId());

            if (currentUser.ActionID.HasValue == false && currentUser.WorkingPanelAvailable)
            {
                Action autoSelectedAction = null;
                autoSelectedAction = db.GetMyActions(User).ToList()
                                     .Where(a => a.IsSelectable)
                                     .OrderByDescending(a => a.Priority)
                                     .ThenBy(a => a.Deadline ?? DateTime.MaxValue)
                                     .ThenByDescending(a => a.LastPomodoro != null ? a.LastPomodoro.Start.Value : DateTime.MinValue)
                                     .ThenByDescending(a => a.CreationDate ?? DateTime.MinValue)
                                     .FirstOrDefault();
                if (autoSelectedAction != null)
                {
                    currentUser.ActionID        = autoSelectedAction.ID;
                    db.Entry(currentUser).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }
            return(Redirect(Request.GetReferrerUrlOrCurrent()));
        }
Ejemplo n.º 27
0
        public ActionResult DeleteOld(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Action action = db.GetActionById(User, id.Value);

            if (action == null)
            {
                return(HttpNotFound());
            }

            if (action.ContainsSelectedAction)
            {
                //working or pending confirmation
                if (action.Owner.WorkingPanelAvailable == false)
                {
                    TempData["UpdateError"] = Settings.MSG_UNSUCCESSFUL_BECAUSE_WORKING;
                    return(RedirectToAction("Details", new { id = id.Value }));
                }
            }
            return(View(action));
        }
Ejemplo n.º 28
0
        ////
        //// GET: /Account/Register
        //[AllowAnonymous]
        //public ActionResult Register()
        //{
        //    return View();
        //}

        private void CreateDefaultItems(string userId)
        {
            //create default project
            Project project = new Project();
            //set owner
            UserManager <ApplicationUser> manager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(db));

            project.User = manager.FindById(userId);
            project.SetCode("Default");
            project.Name         = "Default Project";
            project.CreationDate = DateTime.UtcNow;
            db.Projects.Add(project);

            //create default task
            Task task = new Task();

            task.SetCode("Default");
            task.Name            = "Default Task";
            project.CreationDate = DateTime.UtcNow;
            db.Tasks.Add(task);

            //create default action
            Action action = new Action();

            action.SetName("Default Action");
            action.CreationDate = DateTime.UtcNow;
            action.Estimate     = 1;
            db.Actions.Add(action);

            db.SaveChanges();

            //set current action
            project.User.ActionID        = action.ID;
            db.Entry(project.User).State = EntityState.Modified;
            db.SaveChanges();
        }