Пример #1
0
         public PlaceOrderModel PlaceOrder(String CustomerId, decimal PaidAmount, string AddressId, string Quantity, string buywith, string discountamount = "", string Redeemeamount = "", string couponCode = "")
         {
               PlaceOrderModel objplaceorder = new PlaceOrderModel();
               try
               {
                   string merchantTxnId = dbCon.getindiantime().ToString("yyyyMMddHHmmssffff") + CustomerId;
                   if(PaidAmount==0)
                   {
                       int result = dbCon.CreateTransaction(merchantTxnId, CustomerId, PaidAmount);
                       if (result == 1)
                       {
                           string chektrans = "select id from AlterNetOrder where trnid=@1";
                           string[] param = { merchantTxnId };
                           DataTable dtcheckTrans = dbCon.GetDataTableWithParams(chektrans, param);
                           if (dtcheckTrans != null && dtcheckTrans.Rows.Count > 0)
                           {
                               dbCon.deleteAlternateOrder(merchantTxnId);
                           }
                           else
                           {
                               int chkalternat = CreateAlternateOrder(CustomerId, merchantTxnId, AddressId, PaidAmount.ToString(), Quantity, buywith, discountamount, Redeemeamount, couponCode);
                               if (chkalternat > 0 && PaidAmount == 0)
                               {
                                   int OrderId = WalletPlaceOrder(merchantTxnId);
                                   if (OrderId > 0)
                                   {
                                       // if success, Update the transaction 
                                       #region Update Transaction
                                       try
                                       {
                                           String querynew = "UPDATE [dbo].[CitrusPayment] SET [OrderId] = @1 ,[Order_TimeOfTransaction]= @2,[Statuse] = @3 ,[IsPaymentSuccess]=@4 WHERE [TxnId] =  '" + merchantTxnId + "'";
                                           string[] parms_new = { OrderId.ToString(), dbCon.getindiantime().ToString("dd/MMM/yyyy HH:mm:ss"), "3", "1" };
                                           int resvaltrn = dbCon.ExecuteQueryWithParams(querynew, parms_new);
                                           if (resvaltrn > 0)
                                           {
                                               String querynew1 = "UPDATE [dbo].[AlternetOrder] SET [UpdatedOnUtc]=@1,[IsPaymentDone]=@2 WHERE [TrnId] =  '" + merchantTxnId + "'";
                                               string[] parms_new1 = { dbCon.getindiantime().ToString("dd/MMM/yyyy HH:mm:ss"), "1" };

                                               int resvaltrn1 = dbCon.ExecuteQueryWithParams(querynew1, parms_new1);
                                               if (resvaltrn1 > 0)
                                               {
                                                   String querynew2 = "UPDATE [dbo].[Order] SET [UpdatedOnUtc] =@1,[IsPaymentDone]=@2 WHERE [TRNID] ='" + merchantTxnId + "'";
                                                   string[] parms_new2 = { dbCon.getindiantime().ToString("dd/MMM/yyyy HH:mm:ss"), "1" };

                                                   int resvaltrn2 = dbCon.ExecuteQueryWithParams(querynew2, parms_new2);
                                                   if (resvaltrn2 > 0)
                                                   {
                                                       objplaceorder.resultflag = "1";
                                                       objplaceorder.OrderId = OrderId.ToString();
                                                       objplaceorder.Message = "Your OrderNo:" + OrderId + " has been succesfully generated";
                                                   }
                                               }
                                           }
                                           else
                                           {
                                               objplaceorder.resultflag = "1";
                                               objplaceorder.OrderId = OrderId.ToString();
                                               objplaceorder.Message = "Your Order was Not Generated";
                                           }
                                       }
                                       catch (Exception err)
                                       {
                                           objplaceorder.resultflag = "1";
                                           objplaceorder.OrderId = OrderId.ToString();
                                           objplaceorder.Message = "Your Order was Not Generated";
                                       }
                                       #endregion
                                   }
                                   else
                                   {
                                       objplaceorder.resultflag = "1";
                                       objplaceorder.OrderId = OrderId.ToString();
                                       objplaceorder.Message = "Your Order was Not Generated";
                                   }

                               }
                               else
                               {
                                   objplaceorder.resultflag = "0";
                                   objplaceorder.Message = "Your Order was Not Generated";
                               }

                           }
                       }
                   }

               }
               catch(Exception ex)
               {

               }
               return objplaceorder;
         }