Esempio n. 1
0
        public ResultBM GetDonation(int donationId)
        {
            try
            {
                VolunteerBLL      volunteerBll      = new VolunteerBLL();
                ResultBM          volunteerResult   = null;
                VolunteerBM       volunteerBm       = null;
                DonationStatusBLL donationStatusBll = new DonationStatusBLL();
                ResultBM          statusResult      = null;
                DonorBLL          donorBll          = new DonorBLL();
                ResultBM          donorResult       = null;

                DonationDAL donationDal = new DonationDAL();
                DonationBM  donationBm  = null;
                DonationDTO donationDto = donationDal.GetDonation(donationId);

                //Si la donación existe, debería existir el estado
                if (donationDto != null)
                {
                    statusResult = donationStatusBll.GetDonationStatus(donationDto.statusId);
                    if (!statusResult.IsValid())
                    {
                        return(statusResult);
                    }
                    if (statusResult.GetValue() == null)
                    {
                        throw new Exception(SessionHelper.GetTranslation("RETRIEVING_ERROR") + " statusId " + donationDto.statusId);
                    }

                    donorResult = donorBll.GetDonor(donationDto.donorId);
                    if (!donorResult.IsValid())
                    {
                        return(donorResult);
                    }
                    if (donorResult.GetValue() == null)
                    {
                        throw new Exception(SessionHelper.GetTranslation("RETRIEVING_ERROR") + " donorId " + donationDto.donorId);
                    }

                    //Podría no existir voluntario, sobre todo si se consulta una donación recién creada
                    volunteerResult = volunteerBll.GetVolunteer(donationDto.volunteerId);
                    if (volunteerResult.GetValue() != null)
                    {
                        volunteerBm = volunteerResult.GetValue <VolunteerBM>();
                    }

                    donationBm = new DonationBM(donationDto, donorResult.GetValue <DonorBM>(), statusResult.GetValue <DonationStatusBM>(), volunteerBm);
                }

                return(new ResultBM(ResultBM.Type.OK, "Operación exitosa.", donationBm));
            }
            catch (Exception exception)
            {
                return(new ResultBM(ResultBM.Type.EXCEPTION, SessionHelper.GetTranslation("RETRIEVING_ERROR") + " " + exception.Message, exception));
            }
        }
Esempio n. 2
0
        //No está bueno esto, pero me permite recuperar el estado. Poco performante... pero no hay tiempo.
        private DonationStatusBM GetStatus(DonationDTO donationDto)
        {
            ResultBM statusResult = new DonationStatusBLL().GetDonationStatus(donationDto.statusId);

            return(statusResult.GetValue <DonationStatusBM>());
        }