예제 #1
0
        public async Task <IActionResult> ProjectBlockFetch(string sidx, string sord, int page = 1, int rows = 10)
        {
            var jsonData = new
            {
                total = 0,
                page,
                records = 0,
                rows    = new List <ProjectModel>()
            };

            try
            {
                IEnumerable <ProjectBE> listFormDesignTemplate = FormLogic.BlockFetchProject(page, rows, out int totalRecords);

                if (listFormDesignTemplate == null)
                {
                    return(Json(jsonData));
                }
                else
                {
                    var resultFormTemplate = (from o in listFormDesignTemplate
                                              select new ProjectModel
                    {
                        ID = o.ID,
                        Project = o.Project,
                        ProjectName = o.ProjectName,
                        Description = o.Description,
                        Manager = o.Manager,
                        Client = o.GetCustomDataValue <string>("ClientName"),
                        SiteAddress = o.SiteAddress,
                        SitePostcode = o.SitePostcode,
                        CreationDate = o.CreatedDateTime.ToString()
                    }).ToList();

                    var totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows);

                    jsonData = new
                    {
                        total = totalPages,
                        page,
                        records = totalRecords,
                        rows    = resultFormTemplate
                    };
                }

                var jsonResult = Json(jsonData);
                return(jsonResult);
            }
            catch (Exception ex)
            {
                return(Json(jsonData));
            }
        }
        public IEnumerable <SelectListItem> GetProject()
        {
            IEnumerable <ProjectBE> list    = FormLogic.BlockFetchProject(1, Int32.MaxValue, out int totalRecords);
            List <SelectListItem>   project = new List <SelectListItem>();

            project = list.Select(m => new SelectListItem()
            {
                Text  = string.IsNullOrWhiteSpace(m.Project) ? m.ProjectName : m.Project + "-" + m.ProjectName,
                Value = m.ID.ToString()
            }).ToList();
            project.Insert(0, new SelectListItem {
                Text = "--Select Project--", Value = "-1"
            });
            return(project);
        }