Ejemplo n.º 1
0
        public ServiceResult <IEnumerable <IntegranteJdVDtoOut> > GetAllIntegrantesJdVByJuntaDeVecinosId(int juntaDeVecinosId)
        {
            try
            {
                if (!juntaDeVecinosValidationService.IsExistingJuntaDeVecinosId(juntaDeVecinosId))
                {
                    throw new ValidationException(JuntaDeVecinosMessageConstants.NotExistingJuntaDeVecinosId);
                }

                var listIntegrantesJdV = masterRepository.IntegranteJdV.FindByCondition(i =>
                                                                                        i.JuntaDeVecinosId == juntaDeVecinosId);

                if (listIntegrantesJdV.Count() == 0)
                {
                    throw new ValidationException(IntegranteJdVMessageConstants.NotExistingIntegranteJdVByCampos);
                }

                var listIntegrantesJdVDto = new List <IntegranteJdVDtoOut>();

                foreach (var integranteJdV in listIntegrantesJdV)
                {
                    var integranteJdVDto = MaptoDto(integranteJdV);
                    listIntegrantesJdVDto.Add(integranteJdVDto);
                }
                return(ServiceResult <IEnumerable <IntegranteJdVDtoOut> > .ResultOk(listIntegrantesJdVDto));
            }
            catch (ValidationException e)
            {
                return(ServiceResult <IEnumerable <IntegranteJdVDtoOut> > .ResultFailed(ResponseCode.Warning, e.Message));
            }
            catch (Exception e)
            {
                return(ServiceResult <IEnumerable <IntegranteJdVDtoOut> > .ResultFailed(ResponseCode.Error, e.Message));
            }
        }
Ejemplo n.º 2
0
        public ServiceResult <JuntaDeVecinosDtoOut> GetJuntaDeVecinosByJuntaDeVecinosId(int juntaDeVecinosId)
        {
            try
            {
                if (!juntaDeVecinosValidationService.IsExistingJuntaDeVecinosId(juntaDeVecinosId))
                {
                    throw new ValidationException(JuntaDeVecinosMessageConstants.NotExistingJuntaDeVecinosId);
                }

                var juntaDeVecinos = masterRepository.JuntaDeVecinos.FindByCondition(j =>
                                                                                     j.JuntaDeVecinosId == juntaDeVecinosId).FirstOrDefault();

                var juntaDeVecinosDto = mapper.Map <JuntaDeVecinosDtoOut>(juntaDeVecinos);

                return(ServiceResult <JuntaDeVecinosDtoOut> .ResultOk(juntaDeVecinosDto));
            }
            catch (ValidationException e)
            {
                return(ServiceResult <JuntaDeVecinosDtoOut> .ResultFailed(ResponseCode.Warning, e.Message));
            }
            catch (Exception e)
            {
                return(ServiceResult <JuntaDeVecinosDtoOut> .ResultFailed(ResponseCode.Error, e.Message));
            }
        }