示例#1
0
 public int SavePayment(PostPaymentData paymentData)
 {
     using (var payContext = GetDbContext())
     {
         Payment payment   = Mapper.Map <PostPaymentData, Payment>(paymentData);
         int     patientId = payContext.Patients.FirstOrDefault(pat => pat.PatientGivenId == paymentData.PatientGivenId).Id;
         payment.PatientId = patientId;
         payContext.Payments.Add(payment);
         return(payContext.SaveChanges());
     }
 }
示例#2
0
        public BasicInfo SavePayment(IPostPaymentData iPaymentData)
        {
            BasicInfo paymentInfo = new BasicInfo();

            PostPaymentData paymentData = Mapper.Map <IPostPaymentData, PostPaymentData>(iPaymentData);  //map properties into payment data

            paymentData.CreatedDate = DateTime.Now;
            if (!paymentData.IsValid())
            {
                return(GetErrorResponse <BasicInfo>(paymentData.ErrorMessages));
            }

            int status = postPaymentDao.SavePayment(paymentData);               //save payment

            if (ExecutionError(status))
            {
                return(GetErrorResponse <BasicInfo>("Error occured making payment"));
            }

            return(GetSuccessResponse($"Payment of {paymentData.Amount} naira by {paymentData.Username} was successful", paymentInfo));
        }