示例#1
0
        public IActionResult CustomerIndex()
        {
            var user = _userService.GetById(Convert.ToInt32(UserIdentityInfo.Id));

            if (user.CustomerId != null)
            {
                CustomerIndexViewModel model = new CustomerIndexViewModel();
                model.DataSheetDtos = _dataSheetService.GetAllDataSheets(k => k.CustomerId == user.CustomerId, take: 1000);
                return(View(model));
            }
            return(View());
        }
        public JsonResult DataSheetListDataTable([FromBody] DataTableAjaxPostModel model)
        {
            var expression = _dataSheetHelper.CreateSearchExpression(model);

            if (UserIdentityInfo.Roles.Contains(Roles.Customer))
            {
                var user = _userService.GetById(Convert.ToInt32(UserIdentityInfo.Id));
                if (user.CustomerId != null)
                {
                    if (expression == null)
                    {
                        expression = PredicateBuilder.True <DataSheetDto>();
                    }
                    expression = expression.And(k => k.CustomerId == user.CustomerId);
                }
            }

            var dataSheetList = _dataSheetService.GetAllDataSheets(
                expression,
                _dataSheetHelper.CreateOrderExpression(model),
                model.start,
                model.length + model.start);

            var result = from a in dataSheetList
                         select new[] {
                a.Id.ToString(),
                a.DataSheetNumber,
                a.CustomerName,
                a.SampleNumber,
                a.Department,
                a.YKKProductCode1,
                a.Status,
                a.StartDate != null?a.StartDate.DateStringWithoutTime() : "",
                a.EndDate != null?a.EndDate.DateStringWithoutTime() : "",
                a.FTSUserName,
                a.MainCustomer,
                a.TestResult
            };

            return(Json(new
            {
                Draw = model.draw,
                recordsTotal = _dataSheetService.DataSheetCount(),
                recordsFiltered = _dataSheetService.DataSheetCount(expression),
                data = result
            }));
        }