Пример #1
0
        public IActionResult Index()
        {
            int id = Convert.ToInt32(User.Claims.Where(c => c.Type == "Id")
                                     .Select(c => c.Value).SingleOrDefault());

            var goalList = logic.GetAllByUserId(id);

            var model = new UserGoalsViewModel();

            model.Goals = goalList;

            return(View(model));
        }
Пример #2
0
        public void TestGoals()
        {
            var userId = 99;

            // Goal aanmaken
            var goal = new Goal()
            {
                Title   = "I am going to write a book!",
                Info    = "it is going to be great!",
                StartDT = Convert.ToDateTime("05-05-2018"),
                EndDT   = Convert.ToDateTime("12-12-2018")
            };

            Assert.IsTrue(gLogic.Add(userId, goal.Title, goal.Info, goal.StartDT, goal.EndDT));

            var get = gLogic.GetAllByUserId(userId)[0];

            Assert.AreEqual(goal.Title, get.Title);

            // Goal aanpassen
            var edit = new Goal()
            {
                GoalId   = get.GoalId,
                Title    = "I am going to write a book!",
                Info     = "",
                StartDT  = null,
                EndDT    = Convert.ToDateTime("12-12-2018"),
                Progress = 34,
                UserId   = userId
            };

            Assert.IsTrue(gLogic.Edit(edit));

            // Goal afronden
            get = gLogic.GetAllByUserId(userId)[0];

            Assert.AreEqual(edit.Info, get.Info);

            Assert.IsTrue(gLogic.FinishGoal(get.GoalId));

            get = gLogic.GetAllByUserId(userId)[0];

            Assert.AreEqual(100, get.Progress);
            Assert.AreEqual(GoalStatus.Finished, get.Status);
        }