Ejemplo n.º 1
0
        public JsonResult EditJson(SalaryTabulatorDTO salaryTabulatorDTO)
        {
            if ((int)salaryTabulatorDTO.TabulatorLevel == 0)
            {
                sb.Clear();
                sb.Append("It needs a tabulator level to edit a salary tabulator");
                SeriLogHelper.WriteWarning(null, sb.ToString());
                var data = new ErrorByKey[1] {
                    new ErrorByKey {
                        key = "TabulatorLevel", errors = new string[1] {
                            "Requerido"
                        }
                    }
                };
                return(new JsonHttpStatusResult(data, HttpStatusCode.BadRequest));
            }
            var salaryTabulator = AutoMapperConfiguration.Instance.Mapper.Map <SalaryTabulator>(salaryTabulatorDTO);

            salaryTabuladorService.Update(salaryTabulator);
            return(Json(salaryTabulatorDTO, JsonRequestBehavior.DenyGet));
        }
Ejemplo n.º 2
0
        public JsonResult EditJson(EmployeeDTO employeeDTO)
        {
            if ((int)employeeDTO.Gender == 0)
            {
                sb.Clear();
                sb.Append("It needs a gender to edit a employee");
                SeriLogHelper.WriteWarning(null, sb.ToString());
                var data = new ErrorByKey[1] {
                    new ErrorByKey {
                        key = "Gender", errors = new string[1] {
                            "Requerido"
                        }
                    }
                };
                return(new JsonHttpStatusResult(data, HttpStatusCode.BadRequest));
            }

            var employee = AutoMapperConfiguration.Instance.Mapper.Map <Employee>(employeeDTO);

            _employeeService.Update(employee);
            return(Json(employeeDTO, JsonRequestBehavior.DenyGet));
        }