예제 #1
0
        public ActionResult DeleteAssignment(int id)
        {
            var userId = User.Identity.GetUserId();
            var selectedAssignmentId = id;

            var context = HttpContext.GetOwinContext().Get <ApplicationDbContext>();

            AssignmentService.DeleteAssignmentService(selectedAssignmentId, context);

            return(RedirectToAction("Index", "Home"));
        }
예제 #2
0
        public void DeleteAssignment()
        {
            //Q: can we delete the assignment added from above?

            //prep
            var _context = new MackTechGroupProject.Models.ApplicationDbContext();
            //int courseId = 6;
            var selectedAssignment = _context.Assignments.Where(x => x.AssignmentTitle == "Unit Test").FirstOrDefault();

            //perform operations
            Boolean result = AssignmentService.DeleteAssignmentService(selectedAssignment.AssignmentId, _context);

            //verify and interpret results
            Assert.IsTrue(result);

            var y = _context.Assignments.Where(x => x.AssignmentTitle == selectedAssignment.AssignmentTitle);

            System.Diagnostics.Debug.WriteLine(y.Count());
            Assert.IsTrue(y.Count() == 0);
        }