Exemple #1
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);
        }
Exemple #2
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));
        }
Exemple #3
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();
        }