public IActionResult Index() { var boCollection = _BoRepository.GetAllIncluding(x => x.SystemWorkSections); var boVMCollection = new List <SystemWorkPlaceVM>(); foreach (var item in boCollection.OrderBy(x => x.SortCode)) { var boVM = new SystemWorkPlaceVM(item); boVM.SystemWorkSectionVMCollection = new List <SystemWorkSectionVM>(); foreach (var sItem in item.SystemWorkSections.OrderBy(y => y.SortCode)) { var workSectionVM = new SystemWorkSectionVM(sItem); workSectionVM.SystemWorkTaskVMCollection = new List <SystemWorkTaskVM>(); var workSectionBo = _WorkSectionRepository.GetSingle(sItem.ID, x => x.SystemWorkTasks); var wtCounter = 0; foreach (var tItem in workSectionBo.SystemWorkTasks) { var worktaskVM = new SystemWorkTaskVM(tItem); worktaskVM.OrderNumber = (++wtCounter).ToString(); workSectionVM.SystemWorkTaskVMCollection.Add(worktaskVM); } boVM.SystemWorkSectionVMCollection.Add(workSectionVM); } boVMCollection.Add(boVM); } return(View("../../Views/ApplicationManagement/SystemConfig/Index", boVMCollection)); }
public IActionResult CreateOrEditForSystemWorkSection(Guid id, Guid systemWorkPlaceID) { var isNew = false; var bo = _BoRepository.GetSingle(systemWorkPlaceID, x => x.SystemWorkSections).SystemWorkSections.Where(x => x.ID == id).FirstOrDefault(); if (bo == null) { bo = new SystemWorkSection(); bo.Name = ""; bo.Description = ""; bo.SortCode = ""; isNew = true; } var workPlace = _BoRepository.GetSingle(systemWorkPlaceID); var boVM = new SystemWorkSectionVM(bo); boVM.ParentItemID = workPlace.ID.ToString(); boVM.ParentItem = new Common.ViewModelComponents.PlainFacadeItem() { DisplayName = workPlace.Name, Name = workPlace.Name, ID = workPlace.ID.ToString() }; boVM.IsNew = isNew; return(PartialView("../../Views/ApplicationManagement/SystemConfig/_CreateOrEditForSystemWorkSection", boVM)); }
public IActionResult SaveSystemWorkSection([Bind("ID,IsNew,ParentItemID,Name,Description,SortCode")] SystemWorkSectionVM boVM) { if (ModelState.IsValid) { var systemWorkPlaceID = Guid.Parse(boVM.ParentItemID); var workPlace = _BoRepository.GetSingle(systemWorkPlaceID); var bo = _BoRepository.GetSingle(systemWorkPlaceID, x => x.SystemWorkSections).SystemWorkSections.Where(x => x.ID == boVM.ID).FirstOrDefault(); if (bo == null) { bo = new SystemWorkSection(); boVM.MapToBo(bo); workPlace.SystemWorkSections.Add(bo); _BoRepository.EditAndSave(workPlace); } else { boVM.MapToBo(bo); _BoRepository.EntitiesContext.SystemWorkSections.Update(bo); _BoRepository.EntitiesContext.SaveChanges(); } var saveStatus = new EditAndSaveStatus() { SaveOk = true, StatusMessage = "../../SystemConfig/Index" }; return(Json(saveStatus)); } else { return(PartialView("../../Views/ApplicationManagement/SystemConfig/_CreateOrEditForSystemWorkSection", boVM)); } }