Exemplo n.º 1
0
        public HttpResponseMessage Get([FromUri] int TissueBankId)
        {
            TissueBankApiModel       tbApiModel  = new TissueBankApiModel();
            TransactionalInformation transaction = new TransactionalInformation();

            TissueBankBusinessService tissueBankBusinessService = new TissueBankBusinessService(tbDataService);

            usp_TissueBank_Get_Result tissueBank = tissueBankBusinessService.GetTissueBankById
                                                       (TissueBankId, out transaction);

            tbApiModel.tissueBank     = tissueBank;
            tbApiModel.ReturnStatus   = transaction.ReturnStatus;
            tbApiModel.ReturnMessage  = transaction.ReturnMessage;
            tbApiModel.IsAuthenicated = true;

            if (transaction.ReturnStatus == true)
            {
                var response = Request.CreateResponse <TissueBankApiModel>(HttpStatusCode.OK, tbApiModel);
                return(response);
            }

            var badResponse = Request.CreateResponse <TissueBankApiModel>(HttpStatusCode.BadRequest, tbApiModel);

            return(badResponse);
        }
Exemplo n.º 2
0
        public ActionResult TissueBankSignUp(SignUpViewModel model)
        {
            TransactionalInformation transaction = new TransactionalInformation();

            TissueBankApiModel        tbApiModel = new TissueBankApiModel();
            TissueBankBusinessService tissueBankBusinessService = new TissueBankBusinessService(tbDataService);

            if (ModelState.IsValid)
            {
                tissueBankBusinessService.TissueBank_User_Registration(model.FullName, model.UserName, model.EmailId, model.SecurityQuestion, model.SecurityAnswer, out transaction);

                tbApiModel.ReturnMessage = transaction.ReturnMessage;
                tbApiModel.ReturnStatus  = transaction.ReturnStatus;

                if (transaction.ReturnStatus == false)
                {
                    tbApiModel.ValidationErrors = transaction.ValidationErrors;
                    for (int i = 0; i < transaction.ReturnMessage.Count; ++i)
                    {
                        ModelState.AddModelError("", transaction.ReturnMessage[i]);
                    }

                    //filling up dropdown
                    KeyValueBusinessService keyValueBusinessService = new KeyValueBusinessService(keyValueDataService);
                    IEnumerable <KeyValue>  KeyValues = keyValueBusinessService.Get("Question", out transaction);

                    if (transaction.ReturnStatus == true)
                    {
                        ViewBag.SecurityQuestions = new SelectList(keyValueBusinessService.Get("Question", out transaction), "Key", "Value");
                    }

                    return(View());
                }
                else
                {
                    return(RedirectToAction("TissueBankUser_SignUp_Successful", "Response", new { area = "" }));
                }
            }
            else
            {
                //filling up dropdown
                KeyValueBusinessService keyValueBusinessService = new KeyValueBusinessService(keyValueDataService);
                IEnumerable <KeyValue>  KeyValues = keyValueBusinessService.Get("Question", out transaction);

                ViewBag.SecurityQuestions = new SelectList(keyValueBusinessService.Get("Question", out transaction), "Key", "Value");

                return(View(model));
            }
        }
Exemplo n.º 3
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.º 4
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));
            }
        }