Ejemplo n.º 1
0
        public static KoloNotification UnsuffisantBalanceNotification(Customer c, KoloConstants.Operation.Category category)
        {
            KoloNotification n = new KoloNotification();

            n.Title        = "Insufficant Balance";
            n.Message      = "Dear " + c.Person.Firstname + " your balance (" + c.Balance + ") is insuffisant for this operation : " + category.ToString();
            n.Category     = category.ToString();
            n.CreationDate = DateTime.Now;
            n.Readed       = false;
            n.ExpiryDate   = DateTime.Now.AddDays(3);

            return(n);
        }
Ejemplo n.º 2
0
        public static List <KoloNotification> GenerateNotification <T>(T t, KoloConstants.Operation.Category category, KoloAndroidEntities db, out string error)
        {
            error = "";
            List <KoloNotification> notifications = new List <KoloNotification>();

            if (t.GetType() == typeof(TransfertP2p))
            {
                var tmp = t as TransfertP2p;
                KoloNotification senderNotification   = new KoloNotification();
                KoloNotification recieverNotification = new KoloNotification();

                senderNotification.IdCustomer   = tmp.IdSendingCustomer;
                recieverNotification.IdCustomer = (int)tmp.IdReceiverCustomer;

                notifications.Add(senderNotification);
                notifications.Add(recieverNotification);

                FillNotifications(tmp, ref notifications, db);
            }
            else if (t.GetType() == typeof(EneoBillPayment))
            {
                var tmp = t as EneoBillPayment;
                KoloNotification notification = new KoloNotification();

                notification.IdCustomer = tmp.IdCustomer;

                notifications.Add(notification);

                FillNotifications(tmp, ref notifications, db);
            }
            else if (t.GetType() == typeof(TopUp))
            {
                var tmp = t as TopUp;
                KoloNotification notification = new KoloNotification();

                notification.IdCustomer = tmp.IdCustomer;

                notifications.Add(notification);

                FillNotifications(tmp, ref notifications, db);
            }
            return(notifications);
        }
Ejemplo n.º 3
0
        public static Tuple <List <KoloNotification>, List <CustomerBalanceHistory> > MakeOperation <T>(T t, KoloAndroidEntities db, out string error)
        {
            error = "";
            List <CustomerBalanceHistory> customerBalanceHistories = new List <CustomerBalanceHistory>();
            List <KoloNotification>       koloNotifications        = new List <KoloNotification>();

            if (t.GetType() == typeof(TransfertP2p))
            {
                var tmp = t as TransfertP2p;
                tmp.Sender = db.Customers.Include("Person").FirstOrDefault(c => c.IdCustomer == tmp.IdSendingCustomer);
                if (!CheckCustomerBalance(tmp.Sender, tmp.Amount))
                {
                    KoloNotification n = KoloNotifiactionHelper.UnsuffisantBalanceNotification(tmp.Sender, KoloConstants.Operation.Category.SENDA2A);
                    koloNotifications.Add(n);
                }
                else
                {
                    if (tmp.TransfertStatusCode == KoloConstants.Operation.Status.COMPLETED.ToString())
                    {
                        customerBalanceHistories = CustomerHistoryHelper.GenerateCustomerHistories <TransfertP2p>(tmp, db, out error);
                    }
                    koloNotifications = KoloNotifiactionHelper.GenerateNotification <TransfertP2p>(tmp, KoloConstants.Operation.Category.SENDA2A, db, out error);
                }
            }
            else if (t.GetType() == typeof(EneoBillPayment))
            {
                var tmp = t as EneoBillPayment;
                tmp.Customer = db.Customers.Include("Person").FirstOrDefault(c => c.IdCustomer == tmp.IdCustomer);
                if (!CheckCustomerBalance(tmp.Customer, tmp.BillAmount))
                {
                    KoloNotification n = KoloNotifiactionHelper.UnsuffisantBalanceNotification(tmp.Customer, KoloConstants.Operation.Category.PAYENEOBILL);
                    koloNotifications.Add(n);
                }
                else
                {
                    customerBalanceHistories = CustomerHistoryHelper.GenerateCustomerHistories <EneoBillPayment>(tmp, db, out error);
                    koloNotifications        = KoloNotifiactionHelper.GenerateNotification <EneoBillPayment>(tmp, KoloConstants.Operation.Category.SENDMAD, db, out error);
                }
            }
            else if (t.GetType() == typeof(TopUp))
            {
                var tmp = t as TopUp;
                tmp.Customer = db.Customers.Include("Person").FirstOrDefault(c => c.IdCustomer == tmp.IdCustomer);

                if (!CheckCustomerBalance(tmp.Customer, Int32.Parse(tmp.Amount)))
                {
                    switch (tmp.OperatorCode)
                    {
                    case nameof(KoloConstants.Operation.Category.ORANGE):
                        KoloNotification n = KoloNotifiactionHelper.UnsuffisantBalanceNotification(tmp.Customer, KoloConstants.Operation.Category.ORANGE);
                        koloNotifications.Add(n);
                        break;

                    case nameof(KoloConstants.Operation.Category.MTN):
                        n = KoloNotifiactionHelper.UnsuffisantBalanceNotification(tmp.Customer, KoloConstants.Operation.Category.MTN);
                        koloNotifications.Add(n);
                        break;

                    case nameof(KoloConstants.Operation.Category.NEXTTEL):
                        n = KoloNotifiactionHelper.UnsuffisantBalanceNotification(tmp.Customer, KoloConstants.Operation.Category.NEXTTEL);
                        koloNotifications.Add(n);
                        break;

                    case nameof(KoloConstants.Operation.Category.YOOMEE):
                        n = KoloNotifiactionHelper.UnsuffisantBalanceNotification(tmp.Customer, KoloConstants.Operation.Category.YOOMEE);
                        koloNotifications.Add(n);
                        break;

                    case nameof(KoloConstants.Operation.Category.CAMTEL):
                        n = KoloNotifiactionHelper.UnsuffisantBalanceNotification(tmp.Customer, KoloConstants.Operation.Category.CAMTEL);
                        koloNotifications.Add(n);
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    customerBalanceHistories = CustomerHistoryHelper.GenerateCustomerHistories <TopUp>(tmp, db, out error);
                    switch (tmp.OperatorCode)
                    {
                    case nameof(KoloConstants.Operation.Category.ORANGE):
                        koloNotifications = KoloNotifiactionHelper.GenerateNotification <TopUp>(tmp, KoloConstants.Operation.Category.ORANGE, db, out error);
                        break;

                    case nameof(KoloConstants.Operation.Category.MTN):
                        koloNotifications = KoloNotifiactionHelper.GenerateNotification <TopUp>(tmp, KoloConstants.Operation.Category.MTN, db, out error);
                        break;

                    case nameof(KoloConstants.Operation.Category.NEXTTEL):
                        koloNotifications = KoloNotifiactionHelper.GenerateNotification <TopUp>(tmp, KoloConstants.Operation.Category.NEXTTEL, db, out error);
                        break;

                    case nameof(KoloConstants.Operation.Category.YOOMEE):
                        koloNotifications = KoloNotifiactionHelper.GenerateNotification <TopUp>(tmp, KoloConstants.Operation.Category.YOOMEE, db, out error);
                        break;

                    case nameof(KoloConstants.Operation.Category.CAMTEL):
                        koloNotifications = KoloNotifiactionHelper.GenerateNotification <TopUp>(tmp, KoloConstants.Operation.Category.CAMTEL, db, out error);
                        break;

                    default:
                        break;
                    }
                }
            }
            else if (t.GetType() == typeof(TransferGravity))
            {
                var tmp = t as TransferGravity;
                tmp.Customer = db.Customers.Include("Person").FirstOrDefault(c => c.IdCustomer == tmp.KoloSenderId);
                if (!CheckCustomerBalance(tmp.Customer, tmp.Amount))
                {
                    KoloNotification n = KoloNotifiactionHelper.UnsuffisantBalanceNotification(tmp.Customer, KoloConstants.Operation.Category.SENDMAD);
                    koloNotifications.Add(n);
                }
                else
                {
                    customerBalanceHistories = CustomerHistoryHelper.GenerateCustomerHistories <TransferGravity>(tmp, db, out error);
                    koloNotifications        = KoloNotifiactionHelper.GenerateNotification <TransferGravity>(tmp, KoloConstants.Operation.Category.SENDMAD, db, out error);
                }
            }

            var tuple = new Tuple <List <KoloNotification>, List <CustomerBalanceHistory> >(koloNotifications, customerBalanceHistories);

            return(tuple);
        }