コード例 #1
0
        public object Post(ServicePaymentFormModel model)
        {
            try
            {
                tbPayment payment = model.ConvertModelToPayment();
                ServicePaymentFormModel response;

                if (payment.pay_id != 0)
                {
                    response = model.ConvertPaymentToModel(this.RecoverPayment(payment));
                }
                else
                {
                    response = model.ConvertPaymentToModel(this.CreatePayment(payment));
                }

                if (response.id != 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.Created, response));
                }

                return(Request.CreateResponse(HttpStatusCode.Conflict));
            }
            catch (Exception ex)
            {
                log.Error("Error: " + ex.Message);
                if (ex.InnerException != null)
                {
                    log.Error("Inner exception: " + ex.InnerException.Message);
                }
                throw new Exception("Error Post, ver log para mas detalle: " + ex.Message);
            }
        }
        public object Post(ServicePaymentFormModel model)
        {
            try
            {
                tbPayment payment    = model.ConvertModelToPayment();
                var       createdObj = PaymentFormMock.Instancia().Create(payment);

                var result = model.ConvertPaymentToModel(createdObj);

                if (result.id != 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.Created, result));
                }

                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
            catch (Exception ex)
            {
                log.Error("Mensaje de Error: " + ex.Message);
                if (ex.InnerException != null)
                {
                    log.Error("Inner exception: " + ex.InnerException.Message);
                }
                throw ex;
            }
        }
        public object Get(int id)
        {
            try
            {
                ServicePaymentFormModel model = new ServicePaymentFormModel();

                listaMock = PaymentFormMock.Instancia().Get(id);
                var result = model.ConvertListPaymentToListModel(listaMock);

                if (result != null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, result));
                }

                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }
            catch (Exception ex)
            {
                log.Error("Mensaje de Error: " + ex.Message);
                if (ex.InnerException != null)
                {
                    log.Error("Inner exception: " + ex.InnerException.Message);
                }
                throw ex;
            }
        }
コード例 #4
0
        public object Get(int id)
        {
            try
            {
                ServicePaymentFormModel model = new ServicePaymentFormModel();

                ServicePaymentFormBusiness servicePaymentFormBusiness = new ServicePaymentFormBusiness(id);
                return(model.ConvertListPaymentToListModel(servicePaymentFormBusiness.RecuperarPagosPorUsuario()));
            }
            catch (Exception ex)
            {
                log.Error("Error get: " + ex.Message);
                if (ex.InnerException != null)
                {
                    log.Error("Inner exception: " + ex.InnerException.Message);
                }
                throw ex;
            }
        }