Exemplo n.º 1
0
        public async Task <RSV_Global <Employee> > Update(Employee employee)
        {
            EmployeeValidatioResult employeeValidatioResult = null;
            RSV_Global <Employee>   infoResult = new RSV_Global <Employee>();


            try
            {
                employeeValidatioResult = Validate(employee);
                if (!employeeValidatioResult.ISValid)
                {
                    infoResult.Error = employeeValidatioResult.Error;
                    return(infoResult);
                }

                infoResult = await _employeeDAC.Update(employee);
            }
            catch (Exception ex)
            {
                infoResult.Error   = new Error(ex, $"Se presentó un error en el método {((MethodInfo)MethodBase.GetCurrentMethod()).Name.ToString()}. {ex.ToString()}");
                infoResult.Success = false;
            }

            finally
            {
                employeeValidatioResult = null;
            }

            return(infoResult);
        }
Exemplo n.º 2
0
        public async Task <RSV_Global <Employee> > Create(Employee employee)
        {
            RSV_Global <Employee> infoResult = new RSV_Global <Employee>();

            try
            {
                EmployeeValidatioResult validation = EmployeeValidator.Validate(employee);

                if (!validation.ISValid)
                {
                    infoResult.Error = validation.Error;
                    return(infoResult);
                }

                infoResult = await _employeeDAC.Create(employee);
            }
            catch (SqlException ex)
            {
                infoResult.Error   = new Error(ex, SqlMessageErrorGenerator.GetMessageError(ex.Number));
                infoResult.Success = false;
            }
            catch (Exception ex)
            {
                infoResult.Error   = new Error(ex, $"Se presentó un error en el método {((MethodInfo)MethodBase.GetCurrentMethod()).Name.ToString()}. {ex.ToString()}");
                infoResult.Success = false;
            }

            return(infoResult);
        }
Exemplo n.º 3
0
        public static EmployeeValidatioResult ValidateAutoComplete(Employee employee)
        {
            EmployeeValidatioResult validation = new EmployeeValidatioResult();
            string message = string.Empty;

            if (employee == default(Employee))
            {
                validation.ErrorMessage.Add("El Empleado no es valido");
            }


            if (employee != null &&
                (string.IsNullOrEmpty(employee.FullName) && string.IsNullOrEmpty(employee.DocumentNumber)))
            {
                validation.ErrorMessage.Add($"para realizar la búsqueda por Autocomplete se requiere Nombre y/o Número de documento");
            }

            return(validation);
        }
Exemplo n.º 4
0
        public static EmployeeValidatioResult Validate(Employee employee)
        {
            EmployeeValidatioResult validation = new EmployeeValidatioResult();
            string message = string.Empty;

            if (employee.IDDocumentType <= 0)
            {
                validation.ErrorMessage.Add($"El tipo de documento de identidad es un valor requerido.");
            }

            if (string.IsNullOrEmpty(employee.DocumentNumber))
            {
                validation.ErrorMessage.Add($"El número de documento de identidad es un valor requerido.");
            }

            if (employee == default(Employee))
            {
                validation.ErrorMessage.Add("El Empleado no es valido");
            }

            if (string.IsNullOrEmpty(employee.Name))
            {
                validation.ErrorMessage.Add($"El nombre del Empleado es requerido.");
            }

            if (string.IsNullOrEmpty(employee.Surname))
            {
                validation.ErrorMessage.Add($"El primer apellido del Empleado es requerido.");
            }

            if (employee.IDSubArea <= 0)
            {
                validation.ErrorMessage.Add($"El valor de SubArea es requerido.");
            }

            return(validation);
        }
Exemplo n.º 5
0
        private EmployeeValidatioResult ValidateAutoComplete(Employee employee)
        {
            EmployeeValidatioResult validation = EmployeeValidator.ValidateAutoComplete(employee);

            return(validation);
        }