public void ShouldAddTodoItem()
 {
     var todo = new Todo {Title = "Learn more about ASP.NET MVC Controllers"};
     var redirectToRouteresult = (RedirectToRouteResult) new TodoController().Create(todo);
     Assert.Contains(todo, Todo.ThingsToBeDone);
     Assert.AreEqual("Index", redirectToRouteresult.RouteValues["action"]);
 }
        public void ShouldEditTodoItem()
        {
            var editedTodo = new Todo {Title = "Get a LOT more milk"};

            var redirectToRouteResult = (RedirectToRouteResult) new TodoController().Edit("Get Milk", editedTodo);

            Assert.Contains(editedTodo, Todo.ThingsToBeDone);
            Assert.AreEqual("Index", redirectToRouteResult.RouteValues["action"]);
        }
 public ActionResult Create(Todo todo)
 {
     try
     {
         // TODO: Add insert logic here
         Todo.ThingsToBeDone.Add(todo);
         return RedirectToAction("Index");
     }
     catch (Exception e)
     {
         //throw e; //needs to be handled properly
         return View();
     }
 }
        public ActionResult Convert(Thought thought, string outcome)
        {
            var newTodo = new Todo
                              {
                                  Title = thought.Name,
                                  Outcome = outcome,
                                  Topic = Topic.Topics.Find(topic => topic.Id == thought.Topic.Id)
                              };

            CreateTodo(newTodo);

            Thought.Thoughts.RemoveAll(thoughtToRemove => thoughtToRemove.Name == thought.Name);

            return RedirectToAction("Process", "Thought");
        }
        public void ShouldConvertAThoughtToATodo()
        {
            var expectedTodo = new Todo
                                   {
                                       Title = "Build a killer web site",
                                       Outcome = "Site has 100 visitors per day",
                                       Topic = Topic.Topics[0]
                                   };

            var thought = new Thought {Name = "Build a killer web site", Topic = Topic.Topics[0]};

            var result = (RedirectToRouteResult)new TodoController().Convert(thought, "Site has 100 visitors per day");

            //Assert.Contains(expectedTodo, Todo.ThingsToBeDone); //can't see why this wouldn't work!!?
            Assert.IsFalse(Thought.Thoughts.Contains(thought));
            Assert.AreEqual("Process", result.RouteValues["action"]);
            Assert.AreEqual("Thought", result.RouteValues["controller"]);
        }
        public async Task<ActionResult> CreateReview([Bind(Include = "Id,TodoTypeId,Subject,Body,CreatedById,Slide,Resource,ScoId, AssignedToId")] CreateReviewViewModel form)
        {
            if (ModelState.IsValid)
            {
                var sco = _context.Scos.Find(form.ScoId);
                var todo = new Todo()
                {
                    TodoTypeId = form.TodoTypeId,
                    Subject = form.Subject,
                    Body = form.Body,
                    CreatedById = form.CreatedById,
                    Slide = form.Slide,
                    ScoId = form.ScoId,
                    CreateDate = DateTime.UtcNow,
                    AssignedToId = form.AssignedToId,
                    ScoTitle = sco.Title
                };
                _context.Todos.Add(todo);
                await _context.SaveChangesAsync();
                return RedirectToAction("Index", new { id = form.ScoId });
            }

            ViewBag.AssignedToId = new SelectList(_userManager.Users.OrderBy(u => u.LfName), "Id", "LfName");
            ViewBag.CourseScoId = new SelectList(_context.CourseScos, "Id", "Title", form.ScoId);
            ViewBag.CreatedById = new SelectList(_context.Users, "Id", "FirstName", form.CreatedById);
            ViewBag.TodoTypeId = new SelectList(_context.TodoTypes, "Id", "Subject", form.TodoTypeId);
            return View(form);
        }
 public ActionResult Edit(string oldTitle, Todo editedTodo)
 {
     try
     {
         // TODO: Add update logic here
         Todo.ThingsToBeDone.RemoveAll(aTodo => aTodo.Title == oldTitle);
         Todo.ThingsToBeDone.Add(editedTodo);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
 private static void CreateTodo(Todo todo)
 {
     Todo.ThingsToBeDone.Add(todo);
 }
Example #9
0
        // GET: Admin/Todoes/Create
        public ActionResult Create()
        {
            var assignedToList = _context.Users.ToList().Select(u => new UserLfNameDto
            {
                Id=u.Id,
                Name= u.LfName

            });
            ViewBag.AssignedToId = new SelectList(assignedToList, "Id", "Name");
            ViewBag.CourseScoId = new SelectList(_context.CourseScos, "Id", "Title");
            ViewBag.CreatedById = new SelectList(_context.Users.OrderBy(u => u.FullName), "Id", "FullName");
            ViewBag.TodoTypeId = new SelectList(_context.TodoTypes, "Id", "Subject");
            var vm = new Todo();
            {
                //Todo Remove Magic string
                vm.TodoTypeId = 1;
            };
            return View(vm);
        }