/// <summary> /// For GetAllSection /// </summary> /// <param name="section"></param> /// <returns></returns> public SectionListViewModel GetAllsection(SectionListViewModel section) { SectionListViewModel sectionList = new SectionListViewModel(); try { var sectionAll = this.context?.Sections.Where(x => x.TenantId == section.TenantId && x.SchoolId == section.SchoolId).OrderBy(x => x.SortOrder).ToList(); sectionList.tableSectionsList = sectionAll; sectionList._tenantName = section._tenantName; sectionList._token = section._token; if (sectionAll.Count > 0) { sectionList._failure = false; } else { sectionList._failure = true; sectionList._message = NORECORDFOUND; } } catch (Exception es) { sectionList._message = es.Message; sectionList._failure = true; sectionList._tenantName = section._tenantName; sectionList._token = section._token; } return(sectionList); }
public ActionResult <SectionListViewModel> GetAllsection(SectionListViewModel section) { SectionListViewModel sectionList = new SectionListViewModel(); try { if (section.SchoolId > 0) { sectionList = _sectionService.GetAllsection(section); } else { sectionList._token = section._token; sectionList._tenantName = section._tenantName; sectionList._failure = true; sectionList._message = "Please enter valid scholl id"; } } catch (Exception es) { sectionList._failure = true; sectionList._message = es.Message; } return(sectionList); }
public async Task <IActionResult> Create(SectionListViewModel model) { if (!string.IsNullOrEmpty(model.SectionName) && model.HallID != null) { _sectionService.AddSection(model.SectionName, model.HallID); } return(RedirectToAction(nameof(List), "Section")); }
public PartialViewResult GetSections() { var viewModel = new SectionListViewModel { Sections = _categoryService.GetAllSections() }; return(PartialView(viewModel)); }
public IActionResult List() { SectionListViewModel model = new SectionListViewModel { Sections = _sectionService.GetAllRouteSections(), Halls = _sectionService.GetAllRouteHalls() }; return(View(model)); }
public async Task Create_SectionNameEmpty_SectionNotAddedAndRedirectsToListAction() { // Arrange var mockService = new Mock <ISectionService>(); SectionController controller = new SectionController(mockService.Object); var sectionListViewModel = new SectionListViewModel { HallID = 1, SectionName = "" }; // Act var result = await controller.Create(sectionListViewModel); // Assert var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result); Assert.Equal("Section", redirectToActionResult.ControllerName); Assert.Equal("List", redirectToActionResult.ActionName); mockService.Verify(service => service.AddSection(It.IsAny <string>(), It.IsAny <int?>()), Times.Never); // checks that the sectionService.AddSection is never called. }
public async Task Clear_SectionIdValid_ArchiveAllRoutesInSectionCalledAndRedirectsToListAction() { // Arrange var mockService = new Mock <ISectionService>(); SectionController controller = new SectionController(mockService.Object); var sectionListViewModel = new SectionListViewModel { SectionID = 1 }; // Act var result = await controller.Clear(sectionListViewModel); // Assert var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result); Assert.Equal("Section", redirectToActionResult.ControllerName); Assert.Equal("List", redirectToActionResult.ActionName); mockService.Verify(service => service.ArchiveAllRoutesInSection(It.IsAny <int?>()), Times.Once); }
public ActionResult Details(int?id) { ViewBag.SectionState = new SelectList(Utils.Tools.LeerEstados(), "IdState", "StateDescription", ""); var oSection = new SectionListViewModel(); using (BD_EvaluacionEntities Db = new BD_EvaluacionEntities()) { oSection = (from secc in Db.Secciones join ecom in Db.Estado_Componentes on secc.IdState equals ecom.IdState where secc.Id == id select new SectionListViewModel { Codigo_Seccion = secc.Codigo_Seccion, Nombre_Seccion = secc.Nombre_Seccion, Ponderacion_S = secc.Ponderacion_S ?? 0, IdState = ecom.StateDescription }).FirstOrDefault(); } return(View(oSection)); }
/// <summary> /// Service layer For GetAll Section /// </summary> /// <param name="pageResult"></param> /// <returns></returns> public SectionListViewModel GetAllsection(SectionListViewModel section) { SectionListViewModel sectionList = new SectionListViewModel(); try { if (TokenManager.CheckToken(section._tenantName, section._token)) { sectionList = this.sectionRepository.GetAllsection(section); } else { sectionList._failure = true; sectionList._message = TOKENINVALID; } } catch (Exception es) { sectionList._failure = true; sectionList._message = es.Message; } return(sectionList); }
public async Task <IActionResult> Clear(SectionListViewModel model) { _sectionService.ArchiveAllRoutesInSection(model.SectionID); return(RedirectToAction(nameof(List), "Section")); }
public async Task <IActionResult> Delete(SectionListViewModel model) { _sectionService.ArchiveSection(model.SectionID); return(RedirectToAction(nameof(List), "Section")); }