public IActionResult SaveSystemWorkTask([Bind("ID,IsNew,ParentItemID,Name,Description,SortCode,ControllerName,ControllerMethod,ControllerMethodParameter,BusinessEntityName,IsUsedInMenuString")] SystemWorkTaskVM boVM)
 {
     if (ModelState.IsValid)
     {
         var systemWorkSectionID = Guid.Parse(boVM.ParentItemID);
         var systemSection       = _WorkSectionRepository.GetSingle(systemWorkSectionID);
         var bo = _WorkSectionRepository.GetSingle(systemWorkSectionID, x => x.SystemWorkTasks).SystemWorkTasks.Where(x => x.ID == boVM.ID).FirstOrDefault();
         if (bo == null)
         {
             bo = new SystemWorkTask();
             boVM.MapToBo(bo);
             systemSection.SystemWorkTasks.Add(bo);
             _WorkSectionRepository.EditAndSave(systemSection);
         }
         else
         {
             boVM.MapToBo(bo);
             _WorkSectionRepository.EntitiesContext.SystemWorkTasks.Update(bo);
             _WorkSectionRepository.EntitiesContext.SaveChanges();
         }
         var saveStatus = new EditAndSaveStatus()
         {
             SaveOk = true, StatusMessage = "../../SystemConfig/Index"
         };
         return(Json(saveStatus));
     }
     else
     {
         return(PartialView("../../Views/ApplicationManagement/SystemConfig/_CreateOrEditForSystemWorkTask", boVM));
     }
 }
        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 CreateOrEditForSystemWorkTask(Guid id, Guid systemWorkSectionID)
        {
            var isNew = false;
            var bo    = _WorkSectionRepository.GetSingle(systemWorkSectionID, x => x.SystemWorkTasks).SystemWorkTasks.Where(x => x.ID == id).FirstOrDefault();

            if (bo == null)
            {
                bo             = new SystemWorkTask();
                bo.Name        = "";
                bo.Description = "";
                bo.SortCode    = "";
                isNew          = true;
            }
            var workSection = _WorkSectionRepository.GetSingle(systemWorkSectionID);
            var boVM        = new SystemWorkTaskVM(bo);

            boVM.ParentItemID = workSection.ID.ToString();
            boVM.ParentItem   = new Common.ViewModelComponents.PlainFacadeItem()
            {
                DisplayName = workSection.Name, Name = workSection.Name, ID = workSection.ID.ToString()
            };
            boVM.IsNew = isNew;
            return(PartialView("../../Views/ApplicationManagement/SystemConfig/_CreateOrEditSystemWorkTask", boVM));
        }