Exemplo n.º 1
0
        public static string DoMandateCancellation(string requestStr)
        {
            Serializer            ser           = new Serializer();
            string                xmlOutputData = string.Empty;
            string                responseCode  = string.Empty;
            DateTime              requestTime   = DateTime.Now;
            CancelMandateResponse objResp       = new CancelMandateResponse();

            try
            {
                CancelMandateRequest obj = ser.Deserialize <CancelMandateRequest>(requestStr);
                if (obj != null)
                {
                    bool isSaved = MandateRepo.CancelMandate(obj.MandateCode, obj.BillerID);

                    responseCode = isSaved ? ResponseCodeMap.Successful : ResponseCodeMap.UnknownError;

                    objResp = new CancelMandateResponse
                    {
                        BankCode      = obj.BankCode,
                        BillerID      = obj.BillerID,
                        BillerName    = obj.BillerName,
                        BillerTransId = obj.BillerTransId,
                        MandateCode   = obj.MandateCode,
                        TransType     = obj.TransType,
                        ResponseCode  = responseCode,
                        HashValue     = obj.HashValue
                    };
                }
                else
                {
                    objResp = new CancelMandateResponse {
                        ResponseCode = ResponseCodeMap.InvalidXml
                    };
                }
                xmlOutputData = ser.Serialize <CancelMandateResponse>(objResp);
            }
            catch (Exception e) {
                ExceptionLogRepo.SaveExceptionLog(e);
                xmlOutputData = ser.Serialize <CancelMandateResponse>(new CancelMandateResponse {
                    ResponseCode = ResponseCodeMap.InvalidXml
                });
            }
            DateTime responseTime = DateTime.Now;

            RequestResponseRepository.SaveRequestResponse("ASMX", requestStr, requestTime, "", xmlOutputData, responseTime);
            return(xmlOutputData);
        }