Ejemplo n.º 1
0
        private BeneficiaryDTO Create(BeneficiaryViewModel viewModel)
        {
            try
            {
                log.Debug(BeneficiaryViewModel.FormatBeneficiaryViewModel(viewModel));

                BeneficiaryDTO beneficiary = new BeneficiaryDTO();

                // copy values
                viewModel.UpdateDTO(beneficiary, null); //RequestContext.Principal.Identity.GetUserId());

                // audit
                beneficiary.CreateBy = null; //RequestContext.Principal.Identity.GetUserId();
                beneficiary.CreateOn = DateTime.UtcNow;

                // add
                log.Debug("_beneficiaryService.AddBeneficiary - " + BeneficiaryDTO.FormatBeneficiaryDTO(beneficiary));

                int id = _beneficiaryService.AddBeneficiary(beneficiary);

                beneficiary.BeneficiaryId = id;

                log.Debug("result: 'success', id: " + id);

                return(beneficiary);
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Ejemplo n.º 2
0
        public BeneficiaryDTO GetBeneficiary(int beneficiaryId)
        {
            try
            {
                //Requires.NotNegative("beneficiaryId", beneficiaryId);

                log.Debug("beneficiaryId: " + beneficiaryId + " ");

                // get
                R_Beneficiary t = Repository.GetBeneficiary(beneficiaryId);

                BeneficiaryDTO dto = new BeneficiaryDTO(t);

                log.Debug(BeneficiaryDTO.FormatBeneficiaryDTO(dto));

                return(dto);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Ejemplo n.º 3
0
        public int AddBeneficiary(BeneficiaryDTO dto)
        {
            int id = 0;

            try
            {
                log.Debug(BeneficiaryDTO.FormatBeneficiaryDTO(dto));

                R_Beneficiary t = BeneficiaryDTO.ConvertDTOtoEntity(dto);

                // add
                id = Repository.AddBeneficiary(t);
                dto.BeneficiaryId = id;

                log.Debug("result: 'success', id: " + id);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }

            return(id);
        }
Ejemplo n.º 4
0
        private BeneficiaryDTO Update(BeneficiaryViewModel viewModel)
        {
            try
            {
                log.Debug(BeneficiaryViewModel.FormatBeneficiaryViewModel(viewModel));

                // get
                log.Debug("_beneficiaryService.GetBeneficiary - beneficiaryId: " + viewModel.BeneficiaryId + " ");

                var existingBeneficiary = _beneficiaryService.GetBeneficiary(viewModel.BeneficiaryId);

                log.Debug("_beneficiaryService.GetBeneficiary - " + BeneficiaryDTO.FormatBeneficiaryDTO(existingBeneficiary));

                if (existingBeneficiary != null)
                {
                    // copy values
                    viewModel.UpdateDTO(existingBeneficiary, null); //RequestContext.Principal.Identity.GetUserId());

                    // update
                    log.Debug("_beneficiaryService.UpdateBeneficiary - " + BeneficiaryDTO.FormatBeneficiaryDTO(existingBeneficiary));

                    _beneficiaryService.UpdateBeneficiary(existingBeneficiary);

                    log.Debug("result: 'success'");
                }
                else
                {
                    log.Error("existingBeneficiary: null, BeneficiaryId: " + viewModel.BeneficiaryId);
                }

                return(existingBeneficiary);
            }
            catch (Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Ejemplo n.º 5
0
        public void DeleteBeneficiary(BeneficiaryDTO dto)
        {
            try
            {
                log.Debug(BeneficiaryDTO.FormatBeneficiaryDTO(dto));

                R_Beneficiary t = BeneficiaryDTO.ConvertDTOtoEntity(dto);

                // delete
                Repository.DeleteBeneficiary(t);
                dto.IsDeleted = t.IsDeleted;

                log.Debug("result: 'success'");
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Ejemplo n.º 6
0
        public void UpdateBeneficiary(BeneficiaryDTO dto)
        {
            try
            {
                //Requires.NotNull(t);
                //Requires.PropertyNotNegative(t, "BeneficiaryId");

                log.Debug(BeneficiaryDTO.FormatBeneficiaryDTO(dto));

                R_Beneficiary t = BeneficiaryDTO.ConvertDTOtoEntity(dto);

                // update
                Repository.UpdateBeneficiary(t);

                log.Debug("result: 'success'");
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }