Example #1
0
 public static TransfertP2p AskConfirmationOfTransfertA2A(TransfertP2p tA2A, KoloAndroidEntities db, out string error)
 {
     error = "";
     try
     {
         TransfertP2p t = db.TransfertP2p.FirstOrDefault(tP2P => tP2P.IdTransfertP2p == tA2A.IdTransfertP2p);
         t.TransfertStatusCode = tA2A.TransfertStatusCode;
         Tuple <List <KoloNotification>, List <CustomerBalanceHistory> > tuple = OperationHelper.MakeOperation <TransfertP2p>(t, db, out error);
         db.KoloNotifications.AddRange(tuple.Item1);
         db.CustomerBalanceHistories.AddRange(tuple.Item2);
         db.SaveChanges();
         return(t);
     }
     catch (Exception ex)
     {
         error = ExceptionHelper.GetExceptionMessage(ex);
     }
     return(new TransfertP2p()
     {
         IdTransfertP2p = -30, TransfertStatusCode = error
     });
 }
Example #2
0
 public static TransfertP2p ConfirmTransfertA2A(TransfertP2p tA2A, KoloAndroidEntities db, out string error)
 {
     error = "";
     if (TransfertVerification(tA2A))
     {
         if (tA2A.TransfertStatusCode != KoloConstants.Operation.Status.CONFIRM_PENDING.ToString())
         {
             try
             {
                 TransfertP2p t = db.TransfertP2p.FirstOrDefault(tP2P => tP2P.IdTransfertP2p == tA2A.IdTransfertP2p);
                 t.TransfertStatusCode = tA2A.TransfertStatusCode;
                 t.Sender              = db.Customers.FirstOrDefault(c => c.IdCustomer == t.IdSendingCustomer);
                 t.Receiver            = db.Customers.FirstOrDefault(c => c.IdCustomer == t.IdSendingCustomer);
                 t.TransfertStatusCode = KoloConstants.Operation.Status.COMPLETED.ToString();
                 Tuple <List <KoloNotification>, List <CustomerBalanceHistory> > tuple = OperationHelper.MakeOperation <TransfertP2p>(t, db, out error);
                 db.KoloNotifications.AddRange(tuple.Item1);
                 db.CustomerBalanceHistories.AddRange(tuple.Item2);
                 db.SaveChanges();
                 return(t);
             }
             catch (Exception ex)
             {
                 error = ExceptionHelper.GetExceptionMessage(ex);
             }
             return(new TransfertP2p()
             {
                 IdTransfertP2p = -30, TransfertStatusCode = error
             });
         }
         return(new TransfertP2p()
         {
             IdTransfertP2p = -20, TransfertStatusCode = "Le statut du transfert est inadequat pour une reception : " + tA2A.TransfertStatusCode
         });
     }
     return(new TransfertP2p()
     {
         IdTransfertP2p = -10, TransfertStatusCode = "Parametres du transfert sont non conformes"
     });
 }
Example #3
0
 public static TransfertP2p SendTransfertA2A(TransfertP2p tA2A, KoloAndroidEntities db, out string error)
 {
     error = "";
     if (TransfertVerification(tA2A))
     {
         try
         {
             tA2A.TransfertDate       = DateTime.Now;
             tA2A.TransfertStatusCode = KoloConstants.Operation.Status.RECEIVE_PENDING.ToString();
             tA2A.Reference           = OfficeHelper.GenerateUniqueId();
             Tuple <List <KoloNotification>, List <CustomerBalanceHistory> > tuple = OperationHelper.MakeOperation <TransfertP2p>(tA2A, db, out error);
             db.KoloNotifications.AddRange(tuple.Item1);
             db.CustomerBalanceHistories.AddRange(tuple.Item2);
             db.TransfertP2p.Add(tA2A);
             db.SaveChanges();
             return(tA2A);
         }
         catch (Exception e)
         {
             error = ExceptionHelper.GetExceptionMessage(e);
         }
     }
     return(null);
 }