示例#1
0
        public IActionResult Index(int NewStatus, EditGoalViewModel model)
        {
            var goal = new Goal()
            {
                GoalId   = model.GoalId,
                UserId   = model.UserId,
                Title    = model.Title,
                Info     = model.Info,
                StartDT  = model.StartDT,
                EndDT    = model.EndDT,
                Progress = model.Progress,
                Status   = (GoalStatus)NewStatus,
                Strikes  = model.Strikes
            };

            var edited = logic.Edit(goal);

            if (!edited)
            {
                throw new Exception("Editing failed.");
            }

            return(RedirectToAction("Index"));
        }
示例#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);
        }