Example #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);
        }
Example #2
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"));
        }
Example #3
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"));
        }