示例#1
0
        /// Method Name     : PostTransactionHistory
        /// Author          : Ranjana Singh
        /// Creation Date   : 23 Jan 2018
        /// Purpose         : Creates new records for transaction history based on given customer ID.
        /// Revision        : By Pratik Soni on 27 Jan 2018: Modified to send proper request body for CRM POST method and return validated serviceResponse
        /// </summary>
        public DTO.ServiceResponse <DTO.Payment> PostTransactionHistory(DTO.Payment dtoPayment)
        {
            Dictionary <string, string> crmResponse;
            string jsonFormattedData;
            string moveGUID, customerGUID;

            try
            {
                moveGUID              = General.GetSpecificAttributeFromCRMResponse(dalMoveDetails.GetMoveGUID(dtoPayment.MoveID), "jkmoving_moveid");
                customerGUID          = General.GetSpecificAttributeFromCRMResponse(dalCustomerDetails.GetCustomerGUID(dtoPayment.CustomerID), "contactid");
                dtoPayment.MoveID     = moveGUID;
                dtoPayment.CustomerID = customerGUID;

                jsonFormattedData = General.ConvertToJson <Payment>(dtoPayment);
                crmResponse       = crmUtilities.ExecutePostRequest(transactionEntityNamePlural, dtoToCRMMapper.MapPaymentDTOToCRM(jsonFormattedData));

                return(crmUtilities.GetFormattedResponseToDTO <Payment>(crmResponse));
            }
            catch (Exception ex)
            {
                logger.Error(resourceManager.GetString("msgServiceUnavailable"), ex);
                return(new ServiceResponse <Payment> {
                    Message = resourceManager.GetString("msgServiceUnavailable")
                });
            }
        }
示例#2
0
 /// <summary>
 /// Method Name      : IsInvalidRequestContentForTransaction
 /// Author           : Pratik Soni
 /// Creation Date    : 31 Jan 2018
 /// Purpose          : Validate request content.
 /// Revision         :
 /// </summary>
 /// <param name="transactionHistory"> contains list of transaction history</param>
 /// <returns>TRUE - if content is invalid, else FALSE</returns>
 private bool IsInvalidRequestContentForTransaction(DTO.Payment transactionHistory)
 {
     if (!Validations.IsValid(transactionHistory.CustomerID) ||
         !Validations.IsValid(transactionHistory.MoveID) ||
         !Validations.IsValid(transactionHistory.TransactionDate) ||
         !Validations.IsValid(transactionHistory.TransactionAmount) ||
         !Validations.IsValid(transactionHistory.TransactionNumber))
     {
         logger.Info(resourceManager.GetString("CRM_STATUS_400"));
         return(true);
     }
     return(false);
 }
示例#3
0
        /// <summary>
        /// Method Name      : ExecutePostForTransaction
        /// Author           : Pratik Soni
        /// Creation Date    : 30 Jan 2018
        /// Purpose          : To loop through Transaction history and to POST detail in CRM.
        /// Revision         :
        /// </summary>
        /// <param name="transactionHistory"> contains list of transaction history</param>
        /// <returns>response of type - ServiceResponse<DTO.Payment></returns>
        private ServiceResponse <DTO.Payment> ExecutePostForTransaction(DTO.Payment transactionHistory)
        {
            ServiceResponse <DTO.Payment> crmResponse, invalidResponse;

            crmResponse = crmPaymentDetails.PostTransactionHistory(transactionHistory);

            //Validates if the CRM execution is success or not
            invalidResponse = CheckForErrorOrBadRequest <DTO.Payment>(crmResponse);
            if (invalidResponse.Message != null || invalidResponse.BadRequest != null)
            {
                logger.Error(resourceManager.GetString("msgFailToSave") + " OR " + resourceManager.GetString("msgBadRequest"));
                return(invalidResponse);
            }

            logger.Info(resourceManager.GetString("msgSavedSuccessfully"));
            return(crmResponse);
        }
示例#4
0
        public override PlayerSeason Save(PlayerSeason itemToSave)
        {
            if (itemToSave != null && itemToSave.Programs != null)
            {
                DTO.PlayerSeason dtoItem = this.GetDTOById(itemToSave.Id);

                if (dtoItem != null)
                {
                    foreach (Program domainProgram in itemToSave.Programs)
                    {
                        if (dtoItem.Programs.FirstOrDefault(t => t.Id == domainProgram.Id) == null)
                        {
                            ICriteria criteria = this.UnitOfWork.CurrentSession.CreateCriteria <DTO.Program>();
                            criteria.Add(Expression.Eq("Id", domainProgram.Id));
                            DTO.Program existsTest = criteria.UniqueResult <DTO.Program>();

                            if (existsTest != null)
                            {
                                dtoItem.Programs.Add(existsTest);
                            }
                        }
                    }

                    foreach (Payment domainPayment in itemToSave.Payments)
                    {
                        if (dtoItem.Programs.FirstOrDefault(t => t.Id == domainPayment.Id) == null)
                        {
                            ICriteria criteria = this.UnitOfWork.CurrentSession.CreateCriteria <DTO.Payment>();
                            criteria.Add(Expression.Eq("Id", domainPayment.Id));
                            DTO.Payment existsTest = criteria.UniqueResult <DTO.Payment>();

                            if (existsTest != null)
                            {
                                dtoItem.Payments.Add(existsTest);
                            }
                        }
                    }
                }
            }

            return(base.Save(itemToSave));
        }
示例#5
0
 public static DAL.payment Convert(DTO.Payment dto)
 {
     return(_mapper.Map <DAL.payment>(dto));
 }