Exemplo n.º 1
0
        public void Test_TimeZoneDelete()
        {
            var value = new TimeZoneDelete(
                new TimeZone
                {
                    Id = 1,
                    Display = "test"
                }
            );

            Assert.AreEqual(1, value.Id, "Id");
            Assert.AreEqual("test", value.Title, "Title");
        }
Exemplo n.º 2
0
        public void Test_TimeZoneController_Delete_Post()
        {
            PrincipalHelper.Create();

            var value = new TimeZoneDelete { Id = 0 };
            var notFoundResult = this.TimeZoneController.Delete(value) as HttpNotFoundResult;

            Assert.IsNotNull(notFoundResult, "HttpNotFoundResult");

            value.Id = 1;

            var redirectToRouteResult = this.TimeZoneController.Delete(value) as RedirectToRouteResult;

            Assert.IsNotNull(redirectToRouteResult, "RedirectToRouteResult");
            Assert.AreEqual(AdministrationRoutes.TimeZoneIndex, redirectToRouteResult.RouteName, "RouteName");

            PrincipalHelper.Clear();

            var notAuthorizedResult = this.TimeZoneController.Delete(value) as NotAuthorizedResult;

            Assert.IsNotNull(notAuthorizedResult, "NotAuthorizedResult");
        }
Exemplo n.º 3
0
        public ActionResult Delete(TimeZoneDelete value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var timeZone = this.TimeZoneService.GetById(value.Id);

            if (timeZone == null)
            {
                return base.HttpNotFound();
            }

            var privilege = new TimeZonePrivilege();

            if (!privilege.CanDelete(timeZone))
            {
                return NotAuthorized();
            }

            this.TimeZoneService.Delete(timeZone);

            return base.RedirectToRoute(AdministrationRoutes.TimeZoneIndex);
        }