Exemplo 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));
            }
        }
Exemplo n.º 2
0
        public HttpResponseMessage Post(Order_Ack_Decline_DTO order_Ack_Decline_DTO)
        {
            Order_TissueBankApiModel   order_TissueBankApiModel = new Order_TissueBankApiModel();
            TransactionalInformation   transaction = new TransactionalInformation();
            TransactionBusinessService transactionBusinessService = new TransactionBusinessService(transactionDataService);
            Status status = new Status();

            ErrorBusinessService  errorBusinessService  = new ErrorBusinessService(errorDataService);
            StatusBusinessService statusBusinessService = new StatusBusinessService(statusDataService);
            OrderBusinessService  orderBusinessService  = new OrderBusinessService(orderDataService);

            //Get  OrderCommisionDetail
            OrderCommisionDetail_TissueBank orderCommisionDetail = orderBusinessService.GetOrderCommisionDetail(order_Ack_Decline_DTO.OrderId, out transaction);

            if (order_Ack_Decline_DTO.StatusId == 1008)
            {
                //static values
                orderCommisionDetail.CustomerProfileId         = "1810434404";
                orderCommisionDetail.CustomerPaymentProfileIds = "1805183086";

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

                //create transaction
                int TransactionId = transactionBusinessService.Transaction_Create(DateTime.Now, (float)orderCommisionDetail.AlloCATFees, order_Ack_Decline_DTO.LastModifiedBy, objToPass, out transaction);

                //cut commision
                var response = ChargeCustomerProfile(orderCommisionDetail);

                // if response is not null then only save info in db.
                if (response.AuthCode != null)
                {
                    //converting response into xml format
                    string ResponseBody = Utility.Utilities.SerializeObject <ResTransaction>(response);

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

                    orderBusinessService.Order_Ack_Decline(order_Ack_Decline_DTO.OrderId, order_Ack_Decline_DTO.StatusId, order_Ack_Decline_DTO.DeclineRemark, order_Ack_Decline_DTO.ShippingMethod, order_Ack_Decline_DTO.TissueBankSendByDate, order_Ack_Decline_DTO.LastModifiedBy, TransactionId, response.AuthCode, ResponseBody, response.TransactionId, status.StatusId, orderCommisionDetail.TissueBankId, out transaction);

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

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

                    if (response.MessageDescription == null)
                    {
                        response.MessageDescription = "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.MessageDescription, "", TransactionId, order_Ack_Decline_DTO.LastModifiedBy, response.MessageCode);

                    order_TissueBankApiModel.ReturnStatus = transaction.ReturnStatus = false;
                    order_TissueBankApiModel.ReturnMessage.Add(response.MessageDescription);
                }
            }
            else
            {
                orderBusinessService.Order_Ack_Decline(order_Ack_Decline_DTO.OrderId, order_Ack_Decline_DTO.StatusId, order_Ack_Decline_DTO.DeclineRemark, order_Ack_Decline_DTO.ShippingMethod, order_Ack_Decline_DTO.TissueBankSendByDate, order_Ack_Decline_DTO.LastModifiedBy, 0, "", "", "", 0, orderCommisionDetail.TissueBankId, out transaction);
            }


            if (transaction.ReturnStatus == false)
            {
                order_TissueBankApiModel.ValidationErrors = transaction.ValidationErrors;
                return(Request.CreateResponse <Order_TissueBankApiModel>(HttpStatusCode.BadRequest, order_TissueBankApiModel));
            }
            else
            {
                return(Request.CreateResponse <Order_TissueBankApiModel>(HttpStatusCode.OK, order_TissueBankApiModel));
            }
        }
Exemplo n.º 3
0
        public HttpResponseMessage Put(TissueBankUpdate_DTO tissueBankUpdate_DTO)
        {
            //return Request.CreateResponse(HttpStatusCode.OK, 1);

            // Initialisation
            bool AuthResponse = false;
            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);
            StateBusinessService       stateBusinessService       = new StateBusinessService(stateDataService);
            CityBusinessService        cityBusinessService        = new CityBusinessService(cityDataService);

            //get state
            TransactionalInformation TempTransaction = new TransactionalInformation();
            State BillingState = stateBusinessService.GetStateById(tissueBankUpdate_DTO.BillingStateId, out TempTransaction);
            City  BillingCity  = cityBusinessService.GetCityById(tissueBankUpdate_DTO.BillingCityId, out TempTransaction);

            tissueBankUpdate_DTO.BillingCity  = BillingCity.CityName;
            tissueBankUpdate_DTO.BillingState = BillingState.StateName;

            //check TB registration request
            if (tissueBankBusinessService.CheckTissueBank_Update(tissueBankUpdate_DTO.TissueBankName, tissueBankUpdate_DTO.ContactPersonFirstName, tissueBankUpdate_DTO.ContactPersonLastName, tissueBankUpdate_DTO.ContactPersonNumber, tissueBankUpdate_DTO.ContactPersonEmailId, tissueBankUpdate_DTO.FaxNumber, tissueBankUpdate_DTO.TissueBankEmailId, tissueBankUpdate_DTO.BusinessURL, tissueBankUpdate_DTO.TissueBankAddress, tissueBankUpdate_DTO.CityId, tissueBankUpdate_DTO.ZipCode, tissueBankUpdate_DTO.CustomerServiceLandLineNumber, tissueBankUpdate_DTO.TaxPayerId, tissueBankUpdate_DTO.TissueBankStateLicense, tissueBankUpdate_DTO.AATBLicenseNumber, tissueBankUpdate_DTO.AATBExpirationDate, tissueBankUpdate_DTO.AATBAccredationDate, tissueBankUpdate_DTO.CreditCardNumber, tissueBankUpdate_DTO.CustomerProfileId, tissueBankUpdate_DTO.CustomerPaymentProfileIds, tissueBankUpdate_DTO.BillingAddress, tissueBankUpdate_DTO.BillingCityId, tissueBankUpdate_DTO.BillingZipCode, tissueBankUpdate_DTO.BillingFaxNumber, tissueBankUpdate_DTO.BillingEmailId, tissueBankUpdate_DTO.BillingContactNumber, tissueBankUpdate_DTO.UserId, tissueBankUpdate_DTO.TissueBankId, tissueBankUpdate_DTO.TransactionId, tissueBankUpdate_DTO.AuthTransactionId, tissueBankUpdate_DTO.AuthCode, tissueBankUpdate_DTO.StatusId, tissueBankUpdate_DTO.TransactionCompleteDate, tissueBankUpdate_DTO.ResponseBody, tissueBankUpdate_DTO.OperationType, out transaction))
            {
                // if response is not null then only save tissue bank detail in database and update transaction too.
                if (tissueBankUpdate_DTO.OperationType == "UpdateTissueBankDetail")
                {
                    AuthResponse = UpdateCustomerProfile(tissueBankUpdate_DTO);
                }
                else
                {
                    AuthResponse = UpdateCustomerPaymentProfile(tissueBankUpdate_DTO);
                }

                if (AuthResponse == true)
                {
                    //get status from database for Success
                    status = statusBusinessService.GetStatusByStatusName("Success");

                    tissueBankUpdate_DTO.CreditCardNumber = tissueBankUpdate_DTO.CreditCardNumber.Substring(tissueBankUpdate_DTO.CreditCardNumber.Length - 4);
                    tissueBankUpdate_DTO.CreditCardType   = 0;
                    tissueBankUpdate_DTO.CardCode         = "";
                    tissueBankUpdate_DTO.ExpiryDate       = "";

                    //update tissue bank
                    tissueBankBusinessService.TissueBank_Update(tissueBankUpdate_DTO.TissueBankName, tissueBankUpdate_DTO.ContactPersonFirstName, tissueBankUpdate_DTO.ContactPersonLastName, tissueBankUpdate_DTO.ContactPersonNumber, tissueBankUpdate_DTO.ContactPersonEmailId, tissueBankUpdate_DTO.FaxNumber, tissueBankUpdate_DTO.TissueBankEmailId, tissueBankUpdate_DTO.BusinessURL, tissueBankUpdate_DTO.TissueBankAddress, tissueBankUpdate_DTO.CityId, tissueBankUpdate_DTO.ZipCode, tissueBankUpdate_DTO.CustomerServiceLandLineNumber, tissueBankUpdate_DTO.TaxPayerId, tissueBankUpdate_DTO.TissueBankStateLicense, tissueBankUpdate_DTO.AATBLicenseNumber, tissueBankUpdate_DTO.AATBExpirationDate, tissueBankUpdate_DTO.AATBAccredationDate, tissueBankUpdate_DTO.CreditCardNumber, tissueBankUpdate_DTO.CustomerProfileId, tissueBankUpdate_DTO.CustomerPaymentProfileIds, tissueBankUpdate_DTO.BillingAddress, tissueBankUpdate_DTO.BillingCityId, tissueBankUpdate_DTO.BillingZipCode, tissueBankUpdate_DTO.BillingFaxNumber, tissueBankUpdate_DTO.BillingEmailId, tissueBankUpdate_DTO.BillingContactNumber, tissueBankUpdate_DTO.UserId, tissueBankUpdate_DTO.TissueBankId, tissueBankUpdate_DTO.TransactionId, tissueBankUpdate_DTO.AuthTransactionId, tissueBankUpdate_DTO.AuthCode, tissueBankUpdate_DTO.StatusId, tissueBankUpdate_DTO.TransactionCompleteDate, tissueBankUpdate_DTO.ResponseBody, tissueBankUpdate_DTO.OperationType, out transaction);

                    tbApiModel.ReturnMessage = transaction.ReturnMessage;
                    tbApiModel.ReturnStatus  = transaction.ReturnStatus;
                }
                else
                {
                    tbApiModel.ReturnStatus = transaction.ReturnStatus = false;
                    tbApiModel.ReturnMessage.Add("Authorize .Net operation failed.");
                }
            }
            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));
            }
        }