示例#1
0
        public static HttpResponseMessage Moto(string posRefId, int purchaseAmountCents, int surchargeAmountCents,
                                               bool suppressMerchantPassword, string headerPosName, string headerPosVersion)
        {
            var motoRequest = new MotoRequest
            {
                PosRefId                 = posRefId,
                PurchaseAmountCents      = purchaseAmountCents,
                SurchargeAmountCents     = surchargeAmountCents,
                SuppressMerchantPassword = suppressMerchantPassword
            };

            try
            {
                var response = "http://localhost:8282/v1"
                               .AppendPathSegment("moto")
                               .WithHeader(HeaderPosName, headerPosName)
                               .WithHeader(HeaderPosVersion, headerPosVersion)
                               .PostJsonAsync(motoRequest)
                               .Result;

                return(response);
            }
            catch (AggregateException ae)
            {
                foreach (var ex in ae.InnerExceptions)
                {
                    if (ex is FlurlHttpTimeoutException)
                    {
                        return(new HttpResponseMessage(HttpStatusCode.RequestTimeout));
                    }
                }

                throw;
            }
        }
示例#2
0
        public static void SaveMotoRequest(MotoRequestModel _request, out string message)
        {
            try
            {
                message = "";

                using (var db = new eCardEntities())
                {
                    if (_request.ID == Guid.Empty) //NEW
                    {
                        MotoRequest newMoto = new MotoRequest
                        {
                            ID             = Guid.NewGuid(),
                            Date           = DateTime.Now,
                            RequestedBy    = UniversalService.CurrentUser.ID,
                            ClientCode     = _request.ClientCode,
                            Company        = _request.Company,
                            PaxName        = _request.PaxName.ToUpper(),
                            RecordLocator  = _request.RecordLocator.ToUpper(),
                            Currency       = _request.Currency,
                            Amount         = _request.Amount,
                            Others         = _request.Others,
                            BCDFee         = _request.BCDFee,
                            AdminFee       = _request.AdminFee,
                            Total          = _request.Amount + _request.BCDFee + _request.Others + _request.AdminFee,
                            OptionTime     = _request.OptionTime,
                            ApprovalCode   = _request.ApprovalCode,
                            Remarks        = _request.Remarks,
                            Invoice        = _request.Invoice,
                            Status         = _request.Status,
                            DeclinedReason = _request.DeclinedReason,
                            ApprovedBy     = Guid.Empty
                        };

                        db.Entry(newMoto).State = EntityState.Added;

                        db.SaveChanges();
                    }
                    else
                    {
                        var moto = db.MotoRequest.FirstOrDefault(r => r.ID == _request.ID);

                        if (moto != null)
                        {
                            moto.ClientCode = _request.ClientCode;

                            moto.Company = _request.Company;

                            moto.PaxName = _request.PaxName.ToUpper();

                            moto.RecordLocator = _request.RecordLocator.ToUpper();

                            moto.Currency = _request.Currency;

                            moto.AdminFee = _request.AdminFee;

                            moto.Total = _request.Amount + _request.Others + _request.BCDFee + _request.AdminFee;

                            moto.OptionTime = _request.OptionTime;

                            moto.ApprovalCode = _request.ApprovalCode;

                            moto.Remarks = _request.Remarks;

                            moto.Invoice = _request.Invoice;

                            moto.Status = _request.Status;

                            moto.DeclinedReason = _request.DeclinedReason;

                            moto.ApprovedDate = DateTime.Now;

                            moto.ApprovedBy = UniversalService.CurrentUser.ID;

                            db.Entry(moto).State = EntityState.Modified;

                            db.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception error)
            {
                message = error.Message;
            }
        }