Esempio n. 1
0
        public HttpResponseMessage Post(TissueBankAdd_DTO tissueBankAdd_DTO)
        {
            //Initialisation
            TransactionalInformation transaction = new TransactionalInformation();
            TissueBankApiModel       tbApiModel  = new TissueBankApiModel();
            Status status = new Status();

            TissueBankBusinessService  tissueBankBusinessService  = new TissueBankBusinessService(tbDataService);
            TransactionBusinessService transactionBusinessService = new TransactionBusinessService(transactionDataService);
            ErrorBusinessService       errorBusinessService       = new ErrorBusinessService(errorDataService);
            StatusBusinessService      statusBusinessService      = new StatusBusinessService(statusDataService);

            //check TB registration request
            if (tissueBankBusinessService.CheckTissueBank_Add(tissueBankAdd_DTO.TissueBankName, tissueBankAdd_DTO.ContactPersonFirstName, tissueBankAdd_DTO.ContactPersonLastName, tissueBankAdd_DTO.ContactPersonNumber, tissueBankAdd_DTO.ContactPersonEmailId, tissueBankAdd_DTO.FaxNumber, tissueBankAdd_DTO.TissueBankEmailId, tissueBankAdd_DTO.BusinessURL, tissueBankAdd_DTO.TissueBankAddress, tissueBankAdd_DTO.CityId, tissueBankAdd_DTO.ZipCode, tissueBankAdd_DTO.TissueBankStateLicense, tissueBankAdd_DTO.AATBLicenseNumber, tissueBankAdd_DTO.AATBExpirationDate, tissueBankAdd_DTO.AATBAccredationDate, tissueBankAdd_DTO.CreditCardNumber, tissueBankAdd_DTO.CreditCardType, tissueBankAdd_DTO.ExpiryDate, tissueBankAdd_DTO.CardCode, tissueBankAdd_DTO.CustomerProfileId, tissueBankAdd_DTO.CustomerPaymentProfileIds, tissueBankAdd_DTO.BillingAddress, tissueBankAdd_DTO.BillingCityId, tissueBankAdd_DTO.BillingZipCode, tissueBankAdd_DTO.BillingFaxNumber, tissueBankAdd_DTO.BillingEmailId, tissueBankAdd_DTO.BillingContactNumber, tissueBankAdd_DTO.BillingCity, tissueBankAdd_DTO.BillingState, tissueBankAdd_DTO.State, tissueBankAdd_DTO.City, tissueBankAdd_DTO.UserId, tissueBankAdd_DTO.TissueBankId, tissueBankAdd_DTO.TransactionId, tissueBankAdd_DTO.AuthTransactionId, tissueBankAdd_DTO.AuthCode, tissueBankAdd_DTO.StatusId, tissueBankAdd_DTO.TransactionCompleteDate, tissueBankAdd_DTO.ResponseBody, out transaction))
            {
                //storing for authorize.net
                string CreditCardNumber = tissueBankAdd_DTO.CreditCardNumber;
                int    CreditCardType   = tissueBankAdd_DTO.CreditCardType;
                string CardCode         = tissueBankAdd_DTO.CardCode;
                string ExpiryDate       = tissueBankAdd_DTO.ExpiryDate;

                //removing card detail from object and then storing request detail in transaction table
                tissueBankAdd_DTO.CreditCardNumber = tissueBankAdd_DTO.CreditCardNumber.Substring(tissueBankAdd_DTO.CreditCardNumber.Length - 4);
                tissueBankAdd_DTO.CreditCardType   = 0;
                tissueBankAdd_DTO.CardCode         = "";
                tissueBankAdd_DTO.ExpiryDate       = "";

                //Convert object to string to send as requestBody
                string objToPass = Utility.Utilities.SerializeObject <TissueBankAdd_DTO>(tissueBankAdd_DTO);

                //create transaction
                int TransactionId = transactionBusinessService.Transaction_Create(DateTime.Now, 25, tissueBankAdd_DTO.UserId, objToPass, out transaction);

                //again restoring card details for authorize.net
                tissueBankAdd_DTO.CreditCardNumber = CreditCardNumber;
                tissueBankAdd_DTO.CreditCardType   = CreditCardType;
                tissueBankAdd_DTO.CardCode         = CardCode;
                tissueBankAdd_DTO.ExpiryDate       = ExpiryDate;

                //Cutting $25 for registration
                var response = CreateCustomerProfileAndCharge(tissueBankAdd_DTO);

                // if response is not null then only save tissue bank detail in database and update transaction too.
                if (response.CustomerProfileId != null)
                {
                    tissueBankAdd_DTO.CreditCardNumber = tissueBankAdd_DTO.CreditCardNumber.Substring(tissueBankAdd_DTO.CreditCardNumber.Length - 4);

                    //get status from database for Success
                    status = statusBusinessService.GetStatusByStatusName("Success");

                    #region static data of response from authorize .net
                    //tissueBankAdd_DTO.AuthTransactionId = "123454613";
                    //tissueBankAdd_DTO.CustomerProfileId = "56456123132";
                    //tissueBankAdd_DTO.CustomerPaymentProfileIds = "456123187";
                    //tissueBankAdd_DTO.AuthCode = "456456";
                    //tissueBankAdd_DTO.ResponseBody = "";
                    #endregion

                    tissueBankAdd_DTO.AuthTransactionId         = response.Transaction.TransactionId;
                    tissueBankAdd_DTO.CustomerProfileId         = response.CustomerProfileId;
                    tissueBankAdd_DTO.CustomerPaymentProfileIds = response.CustomerPaymentProfileIds[0];
                    tissueBankAdd_DTO.AuthCode = response.Transaction.AuthCode;

                    tissueBankAdd_DTO.StatusId = status.StatusId;
                    tissueBankAdd_DTO.TransactionCompleteDate = DateTime.Now;
                    tissueBankAdd_DTO.TransactionId           = TransactionId;

                    //converting response into xml format
                    tissueBankAdd_DTO.ResponseBody = Utility.Utilities.SerializeObject <ResCustomerProfile>(response);

                    //add tissue bank
                    tissueBankBusinessService.TissueBank_Add(tissueBankAdd_DTO.TissueBankName, tissueBankAdd_DTO.ContactPersonFirstName, tissueBankAdd_DTO.ContactPersonLastName, tissueBankAdd_DTO.ContactPersonNumber, tissueBankAdd_DTO.ContactPersonEmailId, tissueBankAdd_DTO.FaxNumber, tissueBankAdd_DTO.TissueBankEmailId, tissueBankAdd_DTO.BusinessURL, tissueBankAdd_DTO.TissueBankAddress, tissueBankAdd_DTO.CityId, tissueBankAdd_DTO.ZipCode, tissueBankAdd_DTO.TissueBankStateLicense, tissueBankAdd_DTO.AATBLicenseNumber, tissueBankAdd_DTO.AATBExpirationDate, tissueBankAdd_DTO.AATBAccredationDate, tissueBankAdd_DTO.CreditCardNumber, tissueBankAdd_DTO.CreditCardType, tissueBankAdd_DTO.ExpiryDate, tissueBankAdd_DTO.CardCode, tissueBankAdd_DTO.CustomerProfileId, tissueBankAdd_DTO.CustomerPaymentProfileIds, tissueBankAdd_DTO.BillingAddress, tissueBankAdd_DTO.BillingCityId, tissueBankAdd_DTO.BillingZipCode, tissueBankAdd_DTO.BillingFaxNumber, tissueBankAdd_DTO.BillingEmailId, tissueBankAdd_DTO.BillingContactNumber, tissueBankAdd_DTO.BillingCity, tissueBankAdd_DTO.BillingState, tissueBankAdd_DTO.State, tissueBankAdd_DTO.City, tissueBankAdd_DTO.UserId, tissueBankAdd_DTO.TissueBankId, tissueBankAdd_DTO.TransactionId, tissueBankAdd_DTO.AuthTransactionId, tissueBankAdd_DTO.AuthCode, tissueBankAdd_DTO.StatusId, tissueBankAdd_DTO.TransactionCompleteDate, tissueBankAdd_DTO.ResponseBody, out transaction);

                    tbApiModel.ReturnMessage = transaction.ReturnMessage;
                    tbApiModel.ReturnStatus  = transaction.ReturnStatus;
                }
                else
                {
                    //get status from database for Success
                    status = statusBusinessService.GetStatusByStatusName("Error");

                    if (response.MessageCode == null)
                    {
                        response.MessageCode = "Error Code from authorize.net is null.";
                    }

                    if (response.Message == null)
                    {
                        response.Message = "Response from authorize.net is null.";
                    }

                    //if response is null then log error and update transaction too.
                    string errorMessage = errorBusinessService.Error_Create(status.StatusId, response.Message, "", TransactionId, tissueBankAdd_DTO.UserId, response.MessageCode);

                    if (response.MessageCode == "E00039")
                    {
                        tbApiModel.ReturnMessage.Add("Information that you have entered is already exist. Please contact Administrator.");
                    }
                    else
                    {
                        tbApiModel.ReturnMessage.Add(response.Message);
                    }
                    tbApiModel.ReturnStatus = transaction.ReturnStatus = false;
                }
            }
            else
            {
                tbApiModel.ReturnStatus  = transaction.ReturnStatus = false;
                tbApiModel.ReturnMessage = transaction.ReturnMessage;
            }

            if (transaction.ReturnStatus == false)
            {
                tbApiModel.ValidationErrors = transaction.ValidationErrors;
                return(Request.CreateResponse <TissueBankApiModel>(HttpStatusCode.BadRequest, tbApiModel));
            }
            else
            {
                return(Request.CreateResponse <TissueBankApiModel>(HttpStatusCode.OK, tbApiModel));
            }
        }
Esempio n. 2
0
        private ResCustomerProfile CreateCustomerProfileAndCharge(TissueBankAdd_DTO tissueBankAdd_DTO)
        {
            CustomService.AllocatCustomServiceClient obj = new AllocatCustomServiceClient();
            Customer           objCustomer = new Customer();
            ResCustomerProfile response    = new ResCustomerProfile();
            CreditCard         credit      = new CreditCard();
            AddressInfo        address     = new AddressInfo();

            // Setting input data

            credit.CreditCardNumber = tissueBankAdd_DTO.CreditCardNumber;
            credit.CreditCardType   = tissueBankAdd_DTO.CreditCardType;
            credit.CardCode         = tissueBankAdd_DTO.CardCode;
            credit.ExpiryDate       = tissueBankAdd_DTO.ExpiryDate;
            objCustomer.CardInfo    = credit;

            objCustomer.EmailId   = tissueBankAdd_DTO.ContactPersonEmailId;
            objCustomer.LastName  = tissueBankAdd_DTO.ContactPersonLastName;
            objCustomer.FirstName = tissueBankAdd_DTO.ContactPersonFirstName;

            address.Address         = tissueBankAdd_DTO.TissueBankAddress;
            address.City            = tissueBankAdd_DTO.City;
            address.Company         = tissueBankAdd_DTO.TissueBankName;
            address.Country         = "US";
            address.ZipCode         = tissueBankAdd_DTO.ZipCode;
            address.Email           = tissueBankAdd_DTO.TissueBankEmailId;
            address.FaxNumber       = tissueBankAdd_DTO.FaxNumber;
            address.FirstName       = tissueBankAdd_DTO.ContactPersonFirstName;
            address.LastName        = tissueBankAdd_DTO.ContactPersonLastName;
            address.PhoneNumber     = tissueBankAdd_DTO.ContactPersonNumber;
            address.State           = tissueBankAdd_DTO.State;
            objCustomer.HomeAddress = address;

            address = null;
            address = new AddressInfo();

            address.Address           = tissueBankAdd_DTO.BillingAddress;
            address.City              = tissueBankAdd_DTO.BillingCity;
            address.Company           = tissueBankAdd_DTO.TissueBankName;
            address.Country           = "US";
            address.ZipCode           = tissueBankAdd_DTO.BillingZipCode;
            address.Email             = tissueBankAdd_DTO.BillingEmailId;
            address.FaxNumber         = tissueBankAdd_DTO.BillingFaxNumber;
            address.FirstName         = tissueBankAdd_DTO.ContactPersonFirstName;
            address.LastName          = tissueBankAdd_DTO.ContactPersonLastName;
            address.PhoneNumber       = tissueBankAdd_DTO.BillingContactNumber;
            address.State             = tissueBankAdd_DTO.BillingState;
            objCustomer.OfficeAddress = address;

            objCustomer.PaymentType = PaymentType.CreditCard;

            //credit.CreditCardNumber = "2223000010309711";
            //credit.CreditCardType = 0;
            //credit.CardCode = "845";
            //credit.ExpiryDate = "0527";
            //objCustomer.CardInfo = credit;

            //objCustomer.EmailId = "*****@*****.**";
            //objCustomer.LastName = "Rao22";
            //objCustomer.FirstName = "umesh rao22";

            //address.Address = "1812";
            //address.City = "dewas2";
            //address.Company = "ROW2";
            //address.Country = "US";
            //address.ZipCode = "48596";
            //address.Email = "*****@*****.**";
            //address.FaxNumber = "84952615482";
            //address.FirstName = "Umesh2";
            //address.LastName = "Rao2";
            //address.PhoneNumber = "8085203453";
            //address.State = "Utah";
            //objCustomer.HomeAddress = address;

            //address = null;
            //address = new AddressInfo();

            //address.Address = "Ujjain22";
            //address.City = "Ujjain22";
            //address.Company = "Row22";
            //address.Country = "US";
            //address.ZipCode = "87459";
            //address.Email = "*****@*****.**";
            //address.FaxNumber = "8495668742345";
            //address.FirstName = "Umesh245";
            //address.LastName = "RAO25";
            //address.PhoneNumber = "3454354354353";
            //address.State = "Utah";
            //objCustomer.OfficeAddress = address;


            objCustomer.PaymentType = PaymentType.CreditCard;

            // calling service method
            response = obj.RegisterCustomerAndChargeProfile(objCustomer, 25);
            return(response);
        }