public ActionResult GetProjectCustomLists(string projectCode)
        {
            var projectCustomGroups = _projectCustomListService.Query(p => p.ProjectCode == projectCode).Select().ToList();
            var pcViewList          = new List <ProjectCustomListViewModel>();

            if (projectCustomGroups.Any())
            {
                projectCustomGroups.ForEach(c =>
                {
                    var pclView = new ProjectCustomListViewModel
                    {
                        TableId      = c.TableId,
                        ProjectCode  = c.ProjectCode,
                        CustomListId = c.CustomListId
                    };

                    var groups = _customListService.Query(l => l.CustomListId == c.CustomListId).Select().ToList();

                    if (groups.Any())
                    {
                        pclView.CustomListName = groups[0].CustomListName;
                        pcViewList.Add(pclView);
                    }
                });
            }

            return(Json(pcViewList, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        // GET: Project/EditProject/5
        public ActionResult GetProject(int?id)
        {
            if (id == null)
            {
                return(Json(new Project(), JsonRequestBehavior.AllowGet));
            }

            var project = _projectService.Find(id);

            //

            if (project == null)
            {
                return(Json(new ProjectViewModel(), JsonRequestBehavior.AllowGet));
            }

            var pViewModel = new ProjectViewModel
            {
                TableId                         = project.TableId,
                ProjectName                     = project.ProjectName,
                ProjectDescription              = project.ProjectDescription,
                ProjectCode                     = project.ProjectCode,
                DateCreated                     = project.DateCreated,
                LicenceCode                     = project.LicenceCode,
                ActivationCode                  = project.ActivationCode,
                OnlineMode                      = project.OnlineMode,
                LicenseExpiryDate               = project.LicenseExpiryDate,
                ProjectCustomFieldViewModels    = new List <ProjectCustomFieldViewModel>(),
                ProjectCustomListDataViewModels = new List <ProjectCustomListDataViewModel>(),
                ProjectCustomListViewModels     = new List <ProjectCustomListViewModel>()
            };
            //CustomFields CustomLists CustomListDatas
            var cLists = _projectCustomListService.Query(f => f.ProjectCode == pViewModel.ProjectCode).Select().ToList();

            if (cLists.Any())
            {
                cLists.ForEach(f =>
                {
                    pViewModel.ProjectCustomListViewModels.Add(new ProjectCustomListViewModel
                    {
                        TableId        = f.TableId,
                        CustomListId   = f.CustomListId,
                        ProjectCode    = f.ProjectCode,
                        CustomListName = ""
                    });
                });
            }

            var cFields = _projectCustomFieldService.Query(f => f.ProjectCode == pViewModel.ProjectCode).Select().ToList();

            if (cFields.Any())
            {
                cFields.ForEach(f =>
                {
                    pViewModel.ProjectCustomFieldViewModels.Add(new ProjectCustomFieldViewModel
                    {
                        TableId         = f.TableId,
                        CustomFieldId   = f.CustomFieldId,
                        ProjectCode     = f.ProjectCode,
                        CustomFieldName = ""
                    });
                });
            }

            var cListDatas = _projectCustomListDataService.Query(f => f.ProjectCode == pViewModel.ProjectCode).Select().ToList();

            if (cListDatas.Any())
            {
                cListDatas.ForEach(f =>
                {
                    pViewModel.ProjectCustomListDataViewModels.Add(new ProjectCustomListDataViewModel
                    {
                        TableId            = f.TableId,
                        CustomListDataId   = f.CustomListDataId,
                        ProjectCode        = f.ProjectCode,
                        CustomListDataName = ""
                    });
                });
            }

            return(Json(pViewModel, JsonRequestBehavior.AllowGet));
        }