private void buttonDelete_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete " + section.SectionName + "? Student list, classes and attendance data of this section will be permanently deleted", "Confirmation", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                SectionController        scontroller  = new SectionController();
                SectionTimeController    stcontroller = new SectionTimeController();
                SectionStudentController sscontroller = new SectionStudentController();
                try
                {
                    ClassController      ccontroller = new ClassController();
                    List <ClassModel>    classList   = ccontroller.GetBySectionId(section.Id);
                    AttendanceController acontroller = new AttendanceController();

                    foreach (ClassModel Class in classList)
                    {
                        acontroller.DeleteAllByClass(Class.Id);
                    }

                    ccontroller.DeleteAllBySection(section.Id);
                    sscontroller.RemoveAllBySection(section.Id);
                    stcontroller.RemoveAllBySection(section.Id);
                    scontroller.Delete(section);
                    MessageBox.Show("Deleted!");
                    buttonBack.PerformClick();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemple #2
0
        public void Delete([Values(889)] int id)
        {
            _controller.Request.Method = HttpMethod.Delete;

            var actual = _controller.Delete(id, 0, new UserProfile()
            {
                StoreIds = new int[] { 19 }
            }) as OkNegotiatedContentResult <string>;

            Assert.IsNotNull(actual);
        }
Exemple #3
0
        public async Task Delete_SectionIdValid_ArchiveSectionCalledAndRedirectsToListAction()
        {
            // Arrange
            var mockService = new Mock <ISectionService>();
            SectionController controller = new SectionController(mockService.Object);

            var sectionListViewModel = new SectionListViewModel {
                SectionID = 1
            };

            // Act
            var result = await controller.Delete(sectionListViewModel);

            // Assert
            var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result);

            Assert.Equal("Section", redirectToActionResult.ControllerName);
            Assert.Equal("List", redirectToActionResult.ActionName);
            mockService.Verify(service => service.ArchiveSection(It.IsAny <int?>()), Times.Once);
        }