Exemple #1
0
        public bool CreateMessageIn(MessageIn sms)
        {
            if (sms != null)
            {
                _context.Add(sms);
                _context.SaveChanges();
                return(true);
            }

            return(false);
        }
Exemple #2
0
        public bool CreateAudit(AuditLog category)
        {
            if (category != null)
            {
                _context.Add(category);
                _context.SaveChanges();
                return(true);
            }

            return(false);
        }
Exemple #3
0
        public async Task ProcessNewOnBaording()
        {
            try
            {
                // get all new onbaording
                var newOnboard = await _context.MessageIns.Where(x => x.IsProcessed == false && x.msg.ToUpper() == "IPT").ToListAsync();

                for (int i = 0; i < newOnboard.Count(); i++)
                {
                    using (var transaction = await _context.Database.BeginTransactionAsync(System.Data.IsolationLevel.ReadUncommitted))
                    {
                        var retSms = "";
                        var iptID  = "";

                        var existingTaxpayer = await _context.TaxPayers.Where(x => x.PhoneNo == newOnboard[i].PhoneNo).ToListAsync();

                        if (existingTaxpayer.Count() == 0)
                        {
                            TaxPayer taxpayer = new TaxPayer
                            {
                                PhoneNo          = newOnboard[i].PhoneNo,
                                IPTaxId          = _taxPayerRepository.GuidToBigInteger(Guid.NewGuid()).ToString().Substring(0, 10),
                                SubscriptionType = "DAILY",
                                AmountToDeduct   = 6,
                                Balance          = 3500,
                                CreatedBy        = "SMS",
                                IsActive         = true,
                                DateCreated      = DateTime.Now,
                                LastPaymentDate  = DateTime.Now,
                                NextPaymentDate  = DateTime.Now
                            };
                            iptID = taxpayer.IPTaxId;


                            retSms = "Thank you for Subcribing to IPT. Your I pay tax Id is " + iptID + " with DAILY deduction of " + taxpayer.AmountToDeduct.ToString() + "NGN.";

                            _context.Add(taxpayer);
                        }
                        else
                        {
                            iptID  = existingTaxpayer.FirstOrDefault().IPTaxId;
                            retSms = "You have already registered for IPT. Your IPT ID is " + iptID;
                        }



                        MessageOut messageOut = new MessageOut {
                            MSGType       = "SMS:TEXT",
                            msg           = retSms,
                            PhoneNo       = newOnboard[i].PhoneNo,
                            ServiceType   = "ON-BOARDING",
                            Sender        = "I PAY TAX",
                            IsProcessed   = true,
                            Status        = "Send",
                            Receiver      = newOnboard[i].PhoneNo,
                            DateProcessed = DateTime.Now
                        };

                        _context.Add(messageOut);

                        newOnboard[i].IsProcessed = true;

                        _context.SaveChanges();

                        transaction.Commit();

                        // return;
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }