コード例 #1
0
        public void DeleteTest()
        {
            AgileWorksWebAppealsDBEntities agileWorksWebAppealsDBEntities = new AgileWorksWebAppealsDBEntities();
            Appeals appeals = new Appeals();

            appeals.deadlineDatetime = new DateTime(2019, 1, 19);
            appeals.entryDatetime    = DateTime.Now;
            appeals.description      = "Test123456Delete";

            AppealsController appealsController = new AppealsController();

            agileWorksWebAppealsDBEntities.Appeals.Add(appeals);
            agileWorksWebAppealsDBEntities.SaveChanges();

            var ifExists = agileWorksWebAppealsDBEntities.Appeals.Where(x => x.appealId == appeals.appealId).FirstOrDefault();

            Assert.IsNotNull(ifExists);

            var result2 = appealsController.Delete(ifExists.appealId, new FormCollection());


            var isDeleted = agileWorksWebAppealsDBEntities.Appeals.Where(x => x.appealId == ifExists.appealId).FirstOrDefault();

            Assert.IsNull(isDeleted);
        }
コード例 #2
0
        // GET: Appeals
        public ActionResult Index(int?page)
        {
            using (AgileWorksWebAppealsDBEntities entities = new AgileWorksWebAppealsDBEntities())
            {
                appealsList = entities.Appeals.ToList();
            }

            return(View(appealsList.OrderByDescending(x => x.deadlineDatetime).ToList().ToPagedList(page ?? 1, 50)));
        }
コード例 #3
0
        public void TestIfPastAppealCanBeAdded()
        {
            AgileWorksWebAppealsDBEntities agileWorksWebAppealsDBEntities = new AgileWorksWebAppealsDBEntities();

            Appeals appeals = new Appeals();

            appeals.deadlineDatetime = new DateTime(1996, 1, 19);
            appeals.entryDatetime    = DateTime.Now;
            appeals.description      = "Test123456123456789";

            AppealsController appealsController = new AppealsController();

            var result = appealsController.Create(appeals);
        }
コード例 #4
0
        // GET: Appeals/Delete/5
        public ActionResult Delete(int id)
        {
            using (AgileWorksWebAppealsDBEntities agileWorksDatabaseEntities = new AgileWorksWebAppealsDBEntities())
            {
                Appeals appeals = agileWorksDatabaseEntities.Appeals.Where(x => x.appealId == id).First();

                if (appeals != null)
                {
                    return(View(appeals));
                }
                else
                {
                    return(new HttpNotFoundResult("Appeal not found!"));
                }
            }
        }
コード例 #5
0
        public void TestIfFutureAppealExists()
        {
            AgileWorksWebAppealsDBEntities agileWorksWebAppealsDBEntities = new AgileWorksWebAppealsDBEntities();

            Appeals appeals = new Appeals();

            appeals.deadlineDatetime = new DateTime(2020, 1, 19);
            appeals.entryDatetime    = DateTime.Now;
            appeals.description      = "Test123456123456789";

            AppealsController appealsController = new AppealsController();
            var result   = appealsController.Create(appeals);
            var ifExists = agileWorksWebAppealsDBEntities.Appeals.Where(x => x.appealId == appeals.appealId).FirstOrDefault();


            Assert.IsNotNull(ifExists);
            Assert.AreEqual(appeals.description, ifExists.description);
        }
コード例 #6
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            using (AgileWorksWebAppealsDBEntities agileWorksDatabaseEntities = new AgileWorksWebAppealsDBEntities())
            {
                Appeals appeal = agileWorksDatabaseEntities.Appeals.Where(x => x.appealId == id).FirstOrDefault();

                if (appeal != null)
                {
                    agileWorksDatabaseEntities.Appeals.Remove(appeal);
                    agileWorksDatabaseEntities.SaveChanges();
                }
                else
                {
                    return(new HttpNotFoundResult("Appeal not found!"));
                }
            }

            return(RedirectToAction("Index"));
        }
コード例 #7
0
        public ActionResult Create(Appeals appeals)
        {
            var now = DateTime.Now;

            using (AgileWorksWebAppealsDBEntities agileWorksDatabaseEntities = new AgileWorksWebAppealsDBEntities())
            {
                if (ModelState.IsValid)
                {
                    agileWorksDatabaseEntities.Appeals.Add(appeals);
                    agileWorksDatabaseEntities.SaveChanges();
                }
                else if (!ModelState.IsValid)
                {
                    return(View(appeals));
                }
            }

            return(RedirectToAction("Index"));
        }