public List <SaleEN> GetIntervalPersonSaleHistory(PersonEN pPerson, string pInterval) { List <SaleEN> salesHistory = new List <SaleEN>(); try { switch (pInterval) { case "today": salesHistory = saleDAL.GetPersonTodaySalesHistory(pPerson.PersonID, AssignTimeZone(pPerson.CountryID)); break; case "yesterday": salesHistory = saleDAL.GetPersonYesterdaySalesHistory(pPerson.PersonID, AssignTimeZone(pPerson.CountryID)); break; case "week": salesHistory = saleDAL.GetPersonIntervalSalesHistory(pPerson.PersonID, AssignTimeZone(pPerson.CountryID), Constants.Week); break; default: salesHistory = saleDAL.GetPersonIntervalSalesHistory(pPerson.PersonID, AssignTimeZone(pPerson.CountryID), Constants.Week); break; } } catch (Exception ex) { salesHistory = null; Console.WriteLine(ex.InnerException); EventViewerLoggerBL.LogError(ex.Message); } return(salesHistory); }
public HttpResponseMessage SetNotificationRead(HttpRequestMessage pRequest, NotificationTrackingReq pTracking) { IEnumerable <string> token = null; pRequest.Headers.TryGetValues("Token-autorization", out token); //TODO: Corregir error ortográfico if (token != null) { int notificationID = int.Parse(pTracking.trackingID); if (notificationID <= 0) { response.HttpCode = 400; response.Message = "Notification ID must be greater than zero"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } else { PersonEN personVerified = personBL.VerifyPersonAuthentication(token); if (personVerified != null) { if (personVerified.IsValidToken) { if (campaignBL.MarkNotificationAsRead(notificationID)) { SimpleTextResponse resultResponse = new SimpleTextResponse(); resultResponse.result = true; resultResponse.Message = "Success"; return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, resultResponse)); } else { response.HttpCode = 500; response.Message = "Something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } } else { response.HttpCode = 401; response.Message = "Expired token or not valid credentials."; 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 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 IResponse createSuccessResponse(PersonEN pPersonAuthenticated) { SigninResponse response = new SigninResponse(); try { response.token = pPersonAuthenticated.CurrentToken; response.AvailableAmount = Decimal.Round(pPersonAuthenticated.SingleBagValue, 2).ToString(); response.SesionID = pPersonAuthenticated.SessionID; response.VendorM = pPersonAuthenticated.VendorM; response.CountryID = pPersonAuthenticated.CountryID.ToString(); response.ISO3Code = pPersonAuthenticated.ISO3Code; response.PhoneCode = pPersonAuthenticated.PhoneCode; response.VendorCode = pPersonAuthenticated.VendorCode; response.ProfileCompleted = pPersonAuthenticated.ProfileCompleted; response.OperatorsBalance = new List <OperatorBalance>(); foreach (var item in pPersonAuthenticated.OperatorsBalance) { OperatorBalance balance = new OperatorBalance(); balance.mobileOperator = item.MobileOperatorName; balance.operatorId = item.MobileOperatorID; balance.balance = item.UserBalance; response.OperatorsBalance.Add(balance); } } catch (Exception ex) { Console.WriteLine(ex.InnerException); } return(response); }
public HttpResponseMessage TopupRequestResponse(HttpRequestMessage pRequest, [FromBody] PendingTopupReq data) { IEnumerable <string> token = null; pRequest.Headers.TryGetValues("Token-autorization", out token); if (token != null) { PersonEN person = personBL.VerifyPersonAuthentication(token); if (person != null) { if (person.IsValidToken) { if (data.PendingRequestID > 0) { SimpleTextResponse answer = new SimpleTextResponse(); if (topupBL.AnswerTopupRequest(person, data.PendingRequestID, data.ResponseToRequest)) { answer.result = true; answer.Message = "Operation completed succesfully"; return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, answer)); } else { answer.result = false; answer.Message = "Something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, answer)); } } else { response.HttpCode = 400; response.Message = "Topup Request ID must be greater than 0"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } } else { response.HttpCode = 401; response.Message = "Invalid token"; return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response)); } } else { response.HttpCode = 500; response.Message = "Something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } } else { response.HttpCode = 400; response.Message = "Authorization token must be provided"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } }
public ViewNeedClass CheckNeed(long personId) { if (PersonEN.GetService().GetCount(new FilterExpression(vPerson.ColumnNames.PersonID, personId)) < 1) { return(new ViewNeedClass("Basic Person information not found. Please fill it first", "Person-Form")); } return(null); }
public HttpResponseMessage Validate(HttpRequestMessage request, [FromBody] BuildValidationReqBody pBuildValidation) { IEnumerable <string> token = null; request.Headers.TryGetValues("Token-autorization", out token); if (token == null) { response.HttpCode = 400; response.Message = "Authorization token must be provided"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } else { if (!String.IsNullOrEmpty(pBuildValidation.appVersionName) && !String.IsNullOrEmpty(pBuildValidation.platformName)) { PersonEN personVerified = personBL.VerifyPersonAuthentication(token); if (personVerified != null) { if (!personVerified.IsValidToken) { response.HttpCode = 401; response.Message = "Authentication token has expired."; return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response)); } else { var build = buildBL.BuildVersion(pBuildValidation.appVersionName, pBuildValidation.platformName); BuildValidatorInteractor interactor = new BuildValidatorInteractor(); BuildResponse buildResponse = interactor.CreateBuildResponse(build); if (buildResponse.Valid) { return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, buildResponse)); } else { return(Request.CreateResponse <IResponse>(HttpStatusCode.UpgradeRequired, buildResponse)); } } } else { response.HttpCode = 401; response.Message = "Token authorization expired or not valid"; return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response)); } } else { response.HttpCode = 400; response.Message = "Client build version and platform name are required"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } } }
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 HttpResponseMessage GetActivePromotion(HttpRequestMessage pRequest) { IEnumerable <string> token = null; pRequest.Headers.TryGetValues("Token-autorization", out token); PersonEN personVerified = personBL.VerifyPersonAuthentication(token); if (token != null) { if (personVerified != null) { if (personVerified.IsValidToken) { var promotion = promoBL.GetActivePromotion(personVerified.CountryID); if (promotion != null) { PromotionInteractor interactor = new PromotionInteractor(); var promoResponse = interactor.CreatePromosResponse(promotion); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, promoResponse)); } 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 oken must be provided"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } }
public HttpResponseMessage GetNewUserNotifications(HttpRequestMessage pRequest) { IEnumerable <string> token = null; pRequest.Headers.TryGetValues("Token-autorization", out token); //TODO: Corregir error ortográfico if (token != null) { PersonEN personVerified = personBL.VerifyPersonAuthentication(token); if (personVerified != null) { if (personVerified.IsValidToken) { //Obtiene las notificaciones no leidas a partir de las ultimas 10 var notifications = campaignBL.GetUserNewNotifications(personVerified); if (notifications != null) { NotificationsInteractor interactor = new NotificationsInteractor(); var notifResponse = interactor.CreateNotificationsResponse(notifications); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, notifResponse)); } else { response.HttpCode = 500; response.Message = "Something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } } else { response.HttpCode = 401; response.Message = "Expired token or not valid credentials."; 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 HttpResponseMessage SalePayment(HttpRequestMessage request, [FromBody] SalePaymentReq pPayment) { IEnumerable <string> token = null; request.Headers.TryGetValues("Token-autorization", out token); //TODO: Corregir error ortográfico PersonEN personVerified = personBL.VerifyPersonAuthentication(token); if (token != null) { if (personVerified.IsValidToken) { if (!String.IsNullOrEmpty(pPayment.id)) { SalePaymentResponse payment = new SalePaymentResponse(); payment.Status = saleBL.UpdateSalePayment(Int32.Parse(pPayment.id), pPayment.paid); if (payment.Status) { return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, payment)); } else { response.HttpCode = 500; response.Message = "Something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } } else { response.HttpCode = 400; response.Message = "TransactionID is required"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } } else { response.HttpCode = 401; response.Message = "Authentication token has expired."; return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response)); } } else { response.HttpCode = 400; response.Message = "Authentication token is required"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } }
public HttpResponseMessage Get(HttpRequestMessage pRequest) { 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) { var userBags = bagBL.GetUserBags(personVerified.PersonID); if (userBags != null) { string newToken = personBL.RenewAuthToken(personVerified); var bagsResponse = interactor.CreateBagResponse(userBags, newToken, personVerified.PersonID); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, bagsResponse)); } 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)); } }
/// <summary> /// Inserts topup request into TopupRequests of a specific vendor and pushes notification to vendor /// </summary> /// <param name="pConsumerID">YCR user (consumer) ID as in database</param> /// <param name="pTargetPhone">Phone number where topup must be made</param> /// <param name="pVendorCode">Vendor code as in database</param> /// <param name="pAmount">Topup transaction amount</param> /// <param name="pOperatorID">Operator ID as in database</param> /// <returns>Boolean: Success or not</returns> public async Task <bool> RequestTopup(int pConsumerID, string pNickname, string pTargetPhone, int pVendorCode, decimal pAmount, int pOperatorID, int pCategoryID) { bool requested = false; try { PersonEN vendor = topupDAL.GetPersonByVendorCode(pVendorCode); if (vendor != null) { //Completes topup request data TopupRequestEN request = new TopupRequestEN(); request.ConsumerID = pConsumerID; request.ConsumerNickname = pNickname; request.TargetPhone = pTargetPhone; request.VendorCode = vendor.VendorCode; request.OperatorID = pOperatorID; request.Amount = pAmount; request.StatusCode = 0; request.RequestDate = DateTime.Now; request.ModDate = DateTime.Now; request.CategoryID = pCategoryID; //Inserts topup request int insertedRequest = topupDAL.InsertTopupRequest(request); if (insertedRequest > 0) { string phone = pTargetPhone.Insert(7, "-"); phone = phone.Substring(3); string nickname = pNickname; string amount = pAmount.ToString("C", new CultureInfo("en-US")); //Sends notification to Vendor var notificationResults = await campaignBL.SendTopupRequest(vendor.Email, nickname, phone, amount, vendor.Firstname); requested = notificationResults.Where(n => n.Result).FirstOrDefault().Result; } } } catch (Exception ex) { Console.WriteLine(ex.InnerException); EventViewerLogger.LogError("RequestTopup: " + ex.Message); } return(requested); }
public HttpResponseMessage GetSalesHistory(HttpRequestMessage request, string when) { IEnumerable <string> token = null; request.Headers.TryGetValues("Token-autorization", out token); //TODO: Corregir error ortográfico PersonEN personVerified = personBL.VerifyPersonAuthentication(token); if (personVerified != null) { if (!String.IsNullOrEmpty(when)) { if (personVerified.IsValidToken) { List <SaleEN> salesList = saleBL.GetIntervalPersonSaleHistory(personVerified, when); if (salesList != null) { var historyResult = interactor.createHistoryResultsResponse(salesList, personBL.RenewAuthToken(personVerified)); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, historyResult)); } 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 = 400; response.Message = "Time interval parameter must be not null."; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } } else { response.HttpCode = 401; response.Message = "Token authorization has expired or is not valid"; return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response)); } }
public HttpResponseMessage Get(HttpRequestMessage pRequest, string data) { 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) { List <ProductEN> products = productsBL.GetProductsByCountryID(personVerified); if (products != null) { ProductsResponse productsResponse = interactor.CreateProductsResponse(products); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, productsResponse)); } 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 HttpResponseMessage GetBanks(HttpRequestMessage request) { IEnumerable <string> token = null; request.Headers.TryGetValues("Token-autorization", out token); PersonEN personVerified = personBL.VerifyPersonAuthentication(token); if (token != null) { if (personVerified != null) { if (personVerified.IsValidToken) { List <BankEN> theBanksList = bankBL.GetBankList(personVerified.CountryID); if (theBanksList != null) { BankResponse bankResponse = interactor.CreateBankResponse(theBanksList); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, bankResponse)); } 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 String encode(PersonEN user) { byte[] secretKey = Encoding.ASCII.GetBytes(input); string token; try { token = Jose.JWT.Encode(createToken(user), secretKey, JwsAlgorithm.HS256); } catch (Exception) { throw; } return(token); }
/// <summary> /// Generates a new token with renewed expiration date. /// </summary> /// <param name="pPerson">Vendor data to encrypt</param> /// <returns>String: New generated token.</returns> public string RenewAuthToken(PersonEN pPerson) { try { pPerson.TokenExpiration = DateTime.Now.AddHours(Constants.TokenLifetime); pPerson.CurrentToken = jwt.encode(pPerson); } catch (Exception ex) { Console.WriteLine(ex.InnerException); EventViewerLoggerBL.LogError(ex.Message); } return(pPerson.CurrentToken); }
public PersonEN decode(String token) { PersonEN user = new PersonEN(); try { byte[] secretKey = Encoding.ASCII.GetBytes(input); var tokenDecoded = Jose.JWT.Decode <TokenEN>(token, secretKey); user = createPersonToken(tokenDecoded); } catch (Exception) { throw; } return(user); }
public IResponse createSuccessResponse(PersonEN person) { BalanceRequestResponse response = new BalanceRequestResponse(); try { response.MasterEmail = person.EmailMaster; response.MasterName = person.PersonMaster; response.Status = true; } catch (Exception ex) { Console.WriteLine(ex.InnerException); } return(response); }
public List <ProductEN> GetProductsByCountryID(PersonEN pPerson) { List <ProductEN> products = new List <ProductEN>(); try { products = productDAL.GetProductsByCountryID(pPerson.CountryID); } catch (Exception ex) { products = null; Console.WriteLine(ex.InnerException); EventViewerLoggerBL.LogError(ex.Message); } return(products); }
public List <CampaignEN> GetUserNotifications(PersonEN pPerson) { List <CampaignEN> notifications = new List <CampaignEN>(); try { notifications = campaignDAL.GetNotificationsByUserID(pPerson.PersonID); } catch (Exception ex) { notifications = null; Console.WriteLine(ex.InnerException); EventViewerLoggerBL.LogError("CampaignBL " + ex.Message); } return(notifications); }
public HttpResponseMessage GetSaleDetail(HttpRequestMessage request) { IEnumerable <string> token = null; request.Headers.TryGetValues("Token-autorization", out token); //TODO: Corregir error ortográfico PersonEN personVerified = personBL.VerifyPersonAuthentication(token); if (personVerified != null) { if (personVerified.IsValidToken) { personVerified.MasterID = 1019; RocketSaleDetailEN SaleDetail = saleBL.GetSaleDetail(personVerified.MasterID, personVerified.PersonID); if (SaleDetail != null) { var historyResult = interactor.createSaleDetailResponse(SaleDetail, personBL.RenewAuthToken(personVerified)); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, historyResult)); } 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 = "Token authorization has expired or is not valid"; return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response)); } }
public HttpResponseMessage Post(HttpRequestMessage request, [FromBody] BalanceRequest requestBody) { IEnumerable <string> token = null; request.Headers.TryGetValues("Token-autorization", out token); //TODO: Corregir error ortográfico PersonEN personVerified = personBL.VerifyPersonAuthentication(token); if (!string.IsNullOrEmpty(requestBody.VendorEmail)) { if (personVerified.IsValidToken) { var inf = balanceRequestBL.RequestBalance(requestBody.VendorEmail); if (inf != null) { var responseSucces = interactor.createSuccessResponse(inf); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, responseSucces)); } else { response.HttpCode = 404; response.Message = "Seller not found"; return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response)); } } else { response.HttpCode = 401; response.Message = "Authentication token has expired."; return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response)); } } else { response.HttpCode = 400; response.Message = "Email parameter must not be null."; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } }
public PersonEN VerifyPerson(PersonEN pPerson) { PersonEN person = new PersonEN(); try { connection.Cnn.Open(); person = connection.Cnn.Query <PersonEN>("SpVerifyVendorCredentials", new { email = pPerson.Email, passwordSalt = pPerson.Password }, commandType: CommandType.StoredProcedure).FirstOrDefault(); } catch (Exception ex) { Console.WriteLine("VerifyPerson : " + ex.Message); EventViewerLoggerDAL.LogError(ex.Message); } finally { connection.Cnn.Close(); } return(person); }
public HttpResponseMessage GetBalanceRocket(HttpRequestMessage request) { IEnumerable <string> token = null; request.Headers.TryGetValues("Token-autorization", out token); //TODO: Corregir error ortográfico PersonEN personVerified = personBL.VerifyPersonAuthentication(token); if (personVerified != null) { if (personVerified.IsValidToken) { RocketBalanceEN RocketBalance = saleBL.GetBalanceRocket(personVerified.PersonID); //Envía Entidad BalanceRocket if (RocketBalance != null) { var historyResult = interactor.CreateBalanceRocketResponse(RocketBalance); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, historyResult)); } 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 = "Token authorization has expired or is not valid"; return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response)); } }
public HttpResponseMessage GetPendingTopUps(HttpRequestMessage request) { IEnumerable <string> token = null; request.Headers.TryGetValues("Token-autorization", out token); if (token == null) { response.HttpCode = 400; response.Message = "Authorization token must be provided"; return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response)); } else { PersonEN person = personBL.VerifyPersonAuthentication(token); if (person != null) { if (person.IsValidToken) { TopupInteractor interactor = new TopupInteractor(); var topupRequests = topupBL.GetTopupRequestsByVendor(person.VendorCode); var requestsApiResponse = interactor.CreatePendingTopupsResponse(topupRequests); return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, requestsApiResponse)); } else { response.HttpCode = 401; response.Message = "Expired token or invalid credentials."; return(Request.CreateResponse <IResponse>(HttpStatusCode.Unauthorized, response)); } } else { response.HttpCode = 500; response.Message = "Something went wrong"; return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response)); } } }
public PersonEN AuthenticatePerson(String pEmail, String pPassword) { PersonEN person = new PersonEN(); try { connection.Cnn.Open(); person = connection.Cnn.Query <PersonEN>("SpValidateVendorCredentials", new { email = pEmail, password = pPassword }, commandType: CommandType.StoredProcedure).FirstOrDefault(); } catch (Exception ex) { Console.WriteLine("Error PersonDAL: " + ex.Message); EventViewerLoggerDAL.LogError(ex.Message); } finally { connection.Cnn.Close(); } return(person); }
public SimpleOperationModel AddPersonNickname(PersonEN pPerson, string pNickname) { SimpleOperationModel result = new SimpleOperationModel(); result.Message = "error"; result.Result = false; try { var profile = personDAL.GetGamerProfileByNickname(pNickname); if (profile == null) { profile = new GamerProfileEN(); profile.Nickname = pNickname; profile.PersonID = pPerson.PersonID; profile.RegDate = DateTime.Now; if (personDAL.InsertGamerProfile(profile) > 0) { result.Result = true; result.Message = "inserted"; } } else { result.Result = false; result.Message = "conflict"; } } catch (Exception ex) { Console.WriteLine(ex.InnerException); EventViewerLoggerBL.LogError("AddPersonNickname: " + ex.Message); } return(result); }
public PersonEN RequestBalance(string VendorEmail) { PersonEN person = new PersonEN(); try { cnn.Cnn.Open(); person = cnn.Cnn.Query <PersonEN>("SpRequestBalance", new { vendorEmail = VendorEmail }, commandType: CommandType.StoredProcedure).FirstOrDefault(); } catch (Exception ex) { Console.WriteLine("Error BalanceRequestDAL: " + ex.Message); EventViewerLoggerDAL.LogError(ex.Message); person = null; } finally { cnn.Cnn.Close(); } return(person); }