Пример #1
0
        public JsonResult CustomServerSideSearchAction(DataTableVM <PaymentSearch> model)
        {
            DataTableOutput <Payment>    payments    = new DataTableOutput <Payment>();
            DataTableOutput <PaymentDTO> paymentsDTO = new DataTableOutput <PaymentDTO>();

            try
            {
                payments    = _paymentService.GetByFilters(model.Filters.Employee ?? null, model.Filters.DepartamentId ?? null, model.dataTablesInput ?? null);
                paymentsDTO = AutoMapperConfiguration.Instance.Mapper.Map <DataTableOutput <PaymentDTO> >(payments);
            }
            catch (Exception e)
            {
                sb.Clear();
                sb.Append("An error has occurred when it try to retrieve payments");
                SeriLogHelper.WriteError(e, sb.ToString());
                return(new JsonHttpStatusResult(e.Message, HttpStatusCode.BadRequest));
            }
            return(Json(paymentsDTO, JsonRequestBehavior.DenyGet));
        }
Пример #2
0
        public JsonResult CustomServerSideSearchAction(DataTableVM <SearchEmployee> model)
        {
            DataTableOutput <Employee>    employees    = new DataTableOutput <Employee>();
            DataTableOutput <EmployeeDTO> employeesDTO = new DataTableOutput <EmployeeDTO>();

            try
            {
                employees = _employeeService.GetByFilters(model.Filters.KeyEmplooye ?? null,
                                                          model.Filters.Name ?? null, model.Filters.DepartamentId ?? null, model.Filters.SalaryTabulatorId ?? null, model.dataTablesInput ?? null);
                employeesDTO = AutoMapperConfiguration.Instance.Mapper.Map <DataTableOutput <EmployeeDTO> >(employees);
            }
            catch (Exception e)
            {
                sb.Clear();
                sb.Append("An error has occurred when it try to retrieve employees");
                SeriLogHelper.WriteError(e, sb.ToString());
                return(new JsonHttpStatusResult(e.Message, HttpStatusCode.BadRequest));
            }
            Debug.Write(JsonConvert.SerializeObject(employeesDTO));
            return(Json(employeesDTO, JsonRequestBehavior.DenyGet));
        }