public bool InsertPurchase(PurchaseEN pPurchase, PersonEN pPerson, string pDepositor, string pBankReference, string pDepositDate) { bool result = false; try { DateTime date = Convert.ToDateTime(pDepositDate); var bank = bankDAL.GetBanks(pPerson.CountryID).Where(b => b.BankID == pPurchase.BankID).FirstOrDefault(); string amount = Convert.ToString(pPurchase.Amount); string fullName = pPerson.Firstname + " " + pPerson.Lastname; string depositDate = date.ToString("dd-MMM-yyyy", CultureInfo.CreateSpecificCulture("es-MX")).ToUpper(); result = purchaseDAL.InsertPurchase(pPerson.PersonID, pPurchase.BankID, pPurchase.Amount, pPerson.CountryID, pDepositor, pBankReference, date); if (result) { emailSender.EmailTransferConfirmationReceived(pPerson.Email, pDepositor, pBankReference, bank.BankName, amount, fullName, depositDate); } } catch (Exception ex) { result = false; Console.WriteLine(ex.InnerException); EventViewerLoggerBL.LogError("PurchaseBL " + ex.Message); } return(result); }
public HttpResponseMessage InsertBankDeposit(HttpRequestMessage pRequest, [FromBody] BankDepositoReqBody pDepositData) { IEnumerable <string> token = null; pRequest.Headers.TryGetValues("Token-autorization", out token); //TODO: Corregir error ortográfico PersonEN personVerified = personBL.VerifyPersonAuthentication(token); if (token != null) { if (personVerified != null) { if (personVerified.IsValidToken) { PurchaseEN purchase = new PurchaseEN(); purchase.Amount = pDepositData.monto; purchase.BankID = Convert.ToInt32(pDepositData.banco); var result = purchaseBL.InsertPurchase(purchase, personVerified, pDepositData.nombre, pDepositData.comprobante, pDepositData.fecha); if (result) { string newToken = personBL.RenewAuthToken(personVerified); var depositResponse = interactor.CreatorDepositResponse(result, newToken); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, depositResponse)); } else { response.HttpCode = 500; response.Message = "Something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } } else { response.HttpCode = 401; response.Message = "Authentication token has expired."; return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response)); } } else { response.HttpCode = 401; response.Message = "Credentials are not valid."; return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response)); } } else { response.HttpCode = 400; response.Message = "Authorization token must be provided"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } }
public PurchaseEN BankDeposit(int pPersonID, int pBankID, decimal pAmount, DateTime pRegDate, int pCountryID, string pName, string pNumber, string pImgReference, DateTime pDepositDate, decimal pComissionClient, decimal pITBM, decimal pComission, int pBankReferenceID, decimal pTax, decimal pTaxFree, decimal pAirTime) { PurchaseEN bankDeposit = new PurchaseEN(); try { bankDeposit = cnn.Cnn.Query <PurchaseEN>("SpBankDeposit", new { PersonID = pPersonID, BankID = pBankID, Amount = pAmount, RegDate = pRegDate, CountryID = pCountryID, Name = pName, Number = pNumber, ImgReference = pImgReference, DepositDate = pDepositDate, comision_cliente = pComissionClient, itbm = pITBM, Comisssion = pComission, BankReferenceID = pBankReferenceID, Tax = pTax, TaxFree = pTaxFree, AirTime = pAirTime }, commandType: CommandType.StoredProcedure).SingleOrDefault(); } catch (Exception ex) { Console.WriteLine("Error BankDepositDAL: " + ex.Message); EventViewerLoggerDAL.LogError(ex.Message); } finally { cnn.Cnn.Close(); } return(bankDeposit); }