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 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)); } }
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)); } }