コード例 #1
0
        public ActionResult TechnicianList(DataSourceRequest command, string searchValues, IEnumerable <Sort> sort = null)
        {
            var model = BuildTechnicianSearchModel();

            if (ModelState.IsValid)
            {
                model.Update(searchValues);

                PagedResult <Technician> data = _technicianService.GetTechnicians(model.ToExpression(), model.ToParameters(), command.Page - 1, command.PageSize, sort);
                var result = data.Result.Select(x => x.ToModel()).ToList();

                var gridModel = new DataSourceResult
                {
                    Data  = result,
                    Total = data.TotalCount
                };
                return(new JsonResult
                {
                    Data = gridModel
                });
            }
            else
            {
                return(Json(new { Errors = ModelState.SerializeErrors() }));
            }
        }
コード例 #2
0
        public ActionResult List(DataSourceRequest command, string searchValues, IEnumerable<Sort> sort = null)
        {
            var model = _httpContext.Session[SessionKey.TechnicianSearchModel] as SearchModel;
            if (model == null)
                model = BuildSearchModel();
            else
                model.ClearValues();
            //validate
            var errorFilters = model.Validate(searchValues);
            foreach (var filter in errorFilters)
            {
                ModelState.AddModelError(filter.Name, _localizationService.GetResource(filter.ResourceKey + ".Required"));
            }
            if (ModelState.IsValid)
            {
                //session update
                model.Update(searchValues);
                _httpContext.Session[SessionKey.TechnicianSearchModel] = model;

                PagedResult<Technician> data = _technicianService.GetTechnicians(model.ToExpression(), model.ToParameters(), command.Page - 1, command.PageSize, sort);

                var gridModel = new DataSourceResult
                {
                    Data = data.Result.Select(x => x.ToModel()),
                    Total = data.TotalCount
                };
                return new JsonResult
                {
                    Data = gridModel
                };
            }

            return Json(new { Errors = ModelState.SerializeErrors() });
        }
コード例 #3
0
        public JsonResult Technicians(long parentValue, int?additionalValue, DateTime?optionalValue, string param)
        {
            if (optionalValue.HasValue)
            {
                // we need to convert to UTC
                // because the BaseEamModelBinder not handle for single param: DateTime? optionalValue
                optionalValue = _dateTimeHelper.ConvertToUtcTime(optionalValue.Value, _dateTimeHelper.CurrentTimeZone);
            }

            var technicians = _technicianService.GetTechnicians(parentValue, additionalValue, optionalValue, param)
                              .Select(t => new SelectListItem {
                Text = t.User.Name, Value = t.Id.ToString()
            })
                              .ToList();

            if (technicians.Count > 0)
            {
                technicians.Insert(0, new SelectListItem {
                    Value = "", Text = ""
                });
            }
            return(Json(technicians));
        }
コード例 #4
0
 public IAsyncEnumerable <TechnicianDto> GetTechnicians() => _service.GetTechnicians();