Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            CashDonation cashDonation = db.CashDonations.Find(id);

            db.CashDonations.Remove(cashDonation);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
 public CashDonation Insert(CashDonation CashDonation)
 {
     if (CashDonation.Amount < 200)
     {
         throw new Exception("Transaction amount must not be less than 200");
     }
     return(repository.Add(CashDonation));
 }
Ejemplo n.º 3
0
        public bool Update(CashDonation CashDonation)
        {
            var original = this.FindById(CashDonation.Id);

            if (original != null)
            {
                //AutoMapper.Mapper.Map<CashDonation, CashDonation>(CashDonation, original);
            }
            repository.Update(original);
            return(true);
        }
Ejemplo n.º 4
0
        // GET: CashDonations/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CashDonation cashDonation = db.CashDonations.Find(id);

            if (cashDonation == null)
            {
                return(HttpNotFound());
            }
            return(View(cashDonation));
        }
Ejemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "CashDonationId,DonationTypeId,CaptureEmail,DateCaptured,Amount")] CashDonation cashDonation)
 {
     if (ModelState.IsValid)
     {
         var userName = User.Identity.GetUserName();
         cashDonation.DateCaptured    = DateTime.Now;
         cashDonation.CaptureEmail    = userName;
         db.Entry(cashDonation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DonationTypeId = new SelectList(db.DonationTypes, "DonationTypeId", "TypeName", cashDonation.DonationTypeId);
     return(View(cashDonation));
 }
Ejemplo n.º 6
0
        // GET: CashDonations/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CashDonation cashDonation = db.CashDonations.Find(id);

            if (cashDonation == null)
            {
                return(HttpNotFound());
            }
            ViewBag.DonationTypeId = new SelectList(db.DonationTypes, "DonationTypeId", "TypeName", cashDonation.DonationTypeId);
            return(View(cashDonation));
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> Verify(string trxref)
        {
            if (string.IsNullOrEmpty(trxref) == true)
            {
                if (Session["trxref"] != null)
                {
                    trxref = Session["trxref"].ToString();
                }
            }
            //verify that we have the reference
            var attempt = cashDonationAttemptService.GetByReference(trxref);

            var user = _userManager.FindByNameAsync(User.Identity.Name);

            if (attempt != null)
            {
                //oh great! We got the money, ok now lets confirm
                var verifyResponse = await paystackService.VerifyCharge(payStackConfiguration.GetDefault().Secret, attempt.Reference);

                if (verifyResponse.Successful)
                {
                    //excellent, confirmed so

                    //1. Update the attempt
                    attempt.IsSuccessful      = true;
                    attempt.CardType          = verifyResponse.Data.Authorization.CardType;
                    attempt.AuthorizationCode = verifyResponse.Data.Authorization.AuthorizationCode;
                    attempt.Bank        = verifyResponse.Data.Authorization.Bank;
                    attempt.Last4Digits = verifyResponse.Data.Authorization.Last4Digits;
                    attempt.Amount      = verifyResponse.Data.Amount / 100; //api returns amount in kobo, we divide by 100 to get the naira equivalent
                    attempt.DateUpdated = DateTime.Now;
                    attempt.UpdatedBy   = User.Identity.Name;

                    //save changes
                    cashDonationAttemptService.Update(attempt);

                    //2. Credit the subscriber
                    CashDonation topUp = new CashDonation {
                        Amount = attempt.Amount, CreatedBy = attempt.CreatedBy, Date = DateTime.Now, DateCreated = DateTime.Now, CashDonationAttemptId = attempt.Id
                    };
                    topUpService.Insert(topUp);

                    return(View("Status", true));//RedirectToAction("Index", "Dashboard");
                }
            }

            return(View("Status", false));
        }
Ejemplo n.º 8
0
        public ActionResult Create([Bind(Include = "CashDonationId,DonationTypeId,CaptureEmail,DateCaptured,Amount")] CashDonation cashDonation)
        {
            if (ModelState.IsValid)
            {
                if (cashDonation.Amount > 0)
                {
                    var userName = User.Identity.GetUserName();
                    cashDonation.DateCaptured = DateTime.Now;
                    cashDonation.CaptureEmail = userName;
                    db.CashDonations.Add(cashDonation);
                    db.SaveChanges();
                    return(RedirectToAction("OnceOff", "Payment", new { amount = (double)cashDonation.Amount }));
                }
                else
                {
                    ModelState.AddModelError("", "Invalid amount, please enter valid amount");
                    ViewBag.DonationTypeId = new SelectList(db.DonationTypes, "DonationTypeId", "TypeName", cashDonation.DonationTypeId);
                    return(View(cashDonation));
                }
            }

            ViewBag.DonationTypeId = new SelectList(db.DonationTypes, "DonationTypeId", "TypeName", cashDonation.DonationTypeId);
            return(View(cashDonation));
        }
Ejemplo n.º 9
0
 public bool Delete(CashDonation CashDonation)
 {
     repository.Delete(CashDonation);
     return(true);
 }
Ejemplo n.º 10
0
 public bool Exists(CashDonation CashDonation)
 {
     return(repository.GetAll(x => x.Amount.Equals(CashDonation.Amount) &&
                              x.Date.Equals(CashDonation.Date) &&
                              x.CreatedBy.Trim().Equals(CashDonation.CreatedBy.Trim(), StringComparison.InvariantCultureIgnoreCase)).Any());
 }