Exemple #1
0
        /// <summary>
        /// To activate or inactivate client payer
        /// </summary>
        /// <param name="clientPayer"></param>
        public void ActivateOrDeactivateClientPayer(BusinessModel.BusinessModels.ClientPayer clientPayerDTO)
        {
            try
            {
                UserContext userContext = UserHelper.getUserContext();
                ClientPayer clientPayer = _m3pactContext.ClientPayer.FirstOrDefault(x => x.ClientPayerId == clientPayerDTO.ID);
                if (clientPayer != null)
                {
                    if (clientPayer.RecordStatus == DomainConstants.RecordStatusActive && clientPayerDTO.RecordStatus == DomainConstants.RecordStatusInactive)
                    {
                        clientPayer.EndDate = DateTime.Now.Date;
                    }
                    else if (clientPayer.RecordStatus == DomainConstants.RecordStatusInactive && clientPayerDTO.RecordStatus == DomainConstants.RecordStatusActive)
                    {
                        clientPayer.EndDate = DateTime.MaxValue.Date;
                    }
                    clientPayer.RecordStatus = clientPayerDTO.RecordStatus;
                    clientPayer.ModifiedDate = DateTime.Now;
                    clientPayer.ModifiedBy   = userContext.UserId;

                    _m3pactContext.ClientPayer.Update(clientPayer);
                    _m3pactContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
 /// <summary>
 /// To get ClientPayer DTO & also frame edit permission for a client payer
 /// </summary>
 /// <param name="clientPayers"></param>
 /// <returns></returns>
 public List <BusinessModel.BusinessModels.ClientPayer> ConstructClientPayerDTO(List <ClientPayer> clientPayers)
 {
     try
     {
         List <BusinessModel.BusinessModels.ClientPayer> clientPayersDTO = new List <BusinessModel.BusinessModels.ClientPayer>();
         foreach (ClientPayer item in clientPayers)
         {
             BusinessModel.BusinessModels.ClientPayer clientPayer = new BusinessModel.BusinessModels.ClientPayer();
             clientPayer.Payer           = new BusinessModel.BusinessModels.Payer();
             clientPayer.Payer.PayerName = item.Payer.PayerName;
             clientPayer.Payer.PayerCode = item.Payer.PayerCode;
             clientPayer.ID            = item.ClientPayerId;
             clientPayer.IsM3feeExempt = item.IsM3feeExempt;
             clientPayer.RecordStatus  = item.RecordStatus;
             clientPayer.IsEditable    = item.Payer.RecordStatus == DomainConstants.RecordStatusActive ? true : false;
             clientPayer.CanDelete     = _m3pactContext.DepositLog.Where(dl => dl.ClientPayerId == item.ClientPayerId).Count() > 0 ? false : true;
             clientPayersDTO.Add(clientPayer);
         }
         return(clientPayersDTO);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #3
0
        /// <summary>
        /// Save the Client Payers
        /// </summary>
        /// <param name="clientPayers"></param>
        /// <returns></returns>
        public ValidationViewModel SaveClientPayers(List <ClientPayerViewModel> clientPayers)
        {
            ValidationViewModel validationViewModel = new ValidationViewModel();

            try
            {
                if (clientPayers != null && clientPayers.Count > 0)
                {
                    List <BusinessModel.BusinessModels.ClientPayer> clientPayersDTO = new List <BusinessModel.BusinessModels.ClientPayer>();
                    BusinessModel.BusinessModels.ClientPayer        clientPayerDTO;
                    foreach (ClientPayerViewModel clientPayer in clientPayers)
                    {
                        clientPayerDTO                 = new BusinessModel.BusinessModels.ClientPayer();
                        clientPayerDTO.ID              = clientPayer.ID;
                        clientPayerDTO.IsM3feeExempt   = clientPayer.IsM3FeeExempt;
                        clientPayerDTO.Payer.PayerCode = clientPayer.PayerCode;
                        clientPayerDTO.RecordStatus    = clientPayer.RecordStatus;
                        clientPayerDTO.ClientCode      = clientPayer.ClientCode;
                        clientPayersDTO.Add(clientPayerDTO);
                    }
                    validationViewModel.Success = _payerRepository.SaveClientPayers(clientPayersDTO);
                }
                else
                {
                    validationViewModel.Success = false;
                }
            }
            catch (Exception ex)
            {
                _logger.Log(ex, LogLevel.Error, ex.Message);
                validationViewModel.Success            = false;
                validationViewModel.IsExceptionOccured = true;
                validationViewModel.ErrorMessages.Add(BusinessConstants.ERROR_SAVE_DETAILS);
            }
            return(validationViewModel);
        }