public HttpResponseMessage Get(int cardId)
        {
            try
            {
                var entity = balanceBusiness.GetBalanceByCardId(cardId);
                var model  = mapper.MapFromBalanceEntityToBalanceModel(entity);

                return(Request.CreateResponse <BalanceModel>(HttpStatusCode.OK, model));
            }
            catch (Exception ex)
            {
                return(apiResponseWrapper.Response(HttpStatusCode.InternalServerError, ex));
            }
        }
        public HttpResponseMessage Pay([FromBody] PurchaseModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var purchaseEntity = mapper.MapFromPurchaseFromModelToEntity(model);
                    var transaction    = paymentBusiness.Pay(purchaseEntity);

                    return(apiResponseWrapper.Response(HttpStatusCode.OK, transaction));
                }

                return(apiResponseWrapper.Response(HttpStatusCode.InternalServerError, null));
            }
            catch (Exception ex)
            {
                return(apiResponseWrapper.Response(HttpStatusCode.InternalServerError, ex));
            }
        }
Exemple #3
0
        public HttpResponseMessage Get(string cardNumber)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var entity = cardBusiness.GetByCardNumber(cardNumber);
                    var model  = mapper.MapFromCardEntityToCardModel(entity);

                    //return apiResponseWrapper.Response(HttpStatusCode.OK, model);

                    return(Request.CreateResponse <CardModel>(HttpStatusCode.OK, model));
                }

                return(apiResponseWrapper.Response(HttpStatusCode.InternalServerError, null));
            }
            catch (Exception ex)
            {
                return(apiResponseWrapper.Response(HttpStatusCode.InternalServerError, ex));
            }
        }