Beispiel #1
0
        public Donation CreateDonation()
        {
            #region add user
            var user = new ApplicationUser()
            {
                Name     = "Teste User",
                UserName = "******",
                Email    = "*****@*****.**",
            };
            helper.UserManager.CreateAsync(user, "Teste_123");
            #endregion
            #region add Type
            var type = new DonationType
            {
                DonationTypeName = "TESTE",
            };
            var typeResponse = helper.Context.Add(type);
            #endregion

            var donation = new Donation()
            {
                Description  = "Doação",
                Quantity     = "15",
                DonationType = 1,
                Status       = "pending",
                UserId       = helper.UserManager.FindByEmailAsync("*****@*****.**").Result.Id,
            };
            var response = helper.Context.Add(donation);
            Assert.AreEqual(response.State, EntityState.Added);

            return(response.Entity);
        }
        public async Task <IViewComponentResult> InvokeAsync(DonationType donationType, int targetId)
        {
            string formAction    = "";
            string targetIdField = "";

            if (donationType == DonationType.DonationRequest)
            {
                formAction    = "DonationDetailsForRequest";
                targetIdField = "requestId";
            }
            else if (donationType == DonationType.Mission)
            {
                formAction    = "DonationDetailsForMission";
                targetIdField = "missionId";
            }
            else if (donationType == DonationType.Organisation)
            {
                formAction    = "DonationDetailsForOrganisation";
                targetIdField = "organisationId";
            }

            ViewData["FormAction"]    = formAction;
            ViewData["TargetIdField"] = targetIdField;
            ViewData["TargetId"]      = targetId;

            return(View());
        }
Beispiel #3
0
 public async Task <List <Donation> > GetDonationListAsync(DonationType DonationType)
 {
     using (var db = new DonorsDBContext())
     {
         return(await db.Donations.Where(x => x.DonationType == (short)DonationType).ToListAsync());
     }
 }
Beispiel #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,DonationTypeName")] DonationType donationType)
        {
            if (id != donationType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(donationType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DonationTypeExists(donationType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(donationType));
        }
Beispiel #5
0
 public Donation(int id, decimal amnt, DateTime date, DonationType donType, Person person)
 {
     ID           = id;
     Amount       = amnt;
     DonationDate = date;
     DonationType = donType;
     Giver        = person;
 }
Beispiel #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            DonationType donationType = db.DonationTypes.Find(id);

            db.DonationTypes.Remove(donationType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #7
0
        public async Task Handle_WhenCalled_ReturnDonateServerResponse(DonationType donationType)
        {
            var result = await donateServerCommand.Handle(new DonateServerRequest
            {
                DonationType = donationType
            }, CancellationToken.None);

            Assert.That(result, Is.TypeOf <DonateServerResponse>().And.Not.Null);
            Assert.That(result.IsSucceeded, Is.True);
        }
Beispiel #8
0
 public ActionResult Edit([Bind(Include = "DonationTypeId,Name,Note,IsMoney")] DonationType donationType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(donationType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(donationType));
 }
Beispiel #9
0
        public void CreateDonationType()
        {
            var type = new DonationType
            {
                DonationTypeName = "TESTE Dinheiro",
            };
            var response = helper.Context.Add(type);

            Assert.AreEqual(response.State, EntityState.Added);
        }
Beispiel #10
0
        public ActionResult Create([Bind(Include = "DonationTypeId,Name,Note,IsMoney")] DonationType donationType)
        {
            if (ModelState.IsValid)
            {
                db.DonationTypes.Add(donationType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(donationType));
        }
Beispiel #11
0
        public async Task <IActionResult> Create([Bind("Id,DonationTypeName")] DonationType donationType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(donationType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(donationType));
        }
Beispiel #12
0
        // GET: DonationType
        public ActionResult Index()
        {
            DonationType myModel = new DonationType();

            if (TempData["model"] != null)
            {
                myModel = (DonationType)TempData["model"];
                TempData.Remove("model");
            }
            return(View(myModel));
        }
Beispiel #13
0
        public DateTime NextDonation(DonationType nextType)
        {
            DateTime        next = new DateTime();
            DonationContext con  = new DonationContext();

            var lastTime = con.Donations.Where(p => p.Donor.Pesel == this.Pesel).Select(l => l.Date).Max();
            var lastType = con.Donations.Where(p => p.Donor.Pesel == this.Pesel && p.Date == lastTime)
                           .Select(x => x.DonationType).First();

            next = lastTime.AddDays(64);
            return(next);
        }
Beispiel #14
0
        // GET: DonationTypes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DonationType donationType = db.DonationTypes.Find(id);

            if (donationType == null)
            {
                return(HttpNotFound());
            }
            return(View(donationType));
        }
Beispiel #15
0
        public async Task <DonateServerResult> DonateServer(DonationType donationType, string code)
        {
            var token = await VerifyAndGetPaymentToken(code);

            using (var transaction = database.BeginTransaction().Transaction)
            {
                var _ = await userManager.AddCredits(DonationDictionary.CalculateCredits(donationType),
                                                     httpContextReader.CurrentUserId) ?? throw new DatabaseException();

                await ExecuteOrderTransaction(donationType, code, token);

                transaction.Complete();

                return(new DonateServerResult(true, DonationDictionary.CalculateCredits(donationType)));
            }
        }
Beispiel #16
0
        private async Task ExecuteOrderTransaction(DonationType donationType, string code, Token token)
        {
            var orderTransaction = await database.OrderTransactionRepository.Find(new SqlBuilder()
                                                                                  .Append("transaction_id").Equals.Append($"'{code}'")
                                                                                  .And
                                                                                  .Append("amount").Equals.Append((decimal)donationType)
                                                                                  .Build().Query) ?? throw new ServerException("Donating server failed");

            if (!orderTransaction.IsValidated)
            {
                throw new NoPermissionsException("Order transaction is not validated");
            }

            if (!await database.TokenRepository.Delete(token))
            {
                throw new DatabaseException();
            }
        }
Beispiel #17
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 35, Configuration.FieldSeparator),
                       Id,
                       DonationIdentificationNumberDin?.ToDelimitedString(),
                       DonationType?.ToDelimitedString(),
                       PhlebotomyStartDateTime.HasValue ? PhlebotomyStartDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       PhlebotomyEndDateTime.HasValue ? PhlebotomyEndDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       DonationDuration.HasValue ? DonationDuration.Value.ToString(Consts.NumericFormat, culture) : null,
                       DonationDurationUnits?.ToDelimitedString(),
                       IntendedProcedureType != null ? string.Join(Configuration.FieldRepeatSeparator, IntendedProcedureType.Select(x => x.ToDelimitedString())) : null,
                       ActualProcedureType != null ? string.Join(Configuration.FieldRepeatSeparator, ActualProcedureType.Select(x => x.ToDelimitedString())) : null,
                       DonorEligibilityFlag,
                       DonorEligibilityProcedureType != null ? string.Join(Configuration.FieldRepeatSeparator, DonorEligibilityProcedureType.Select(x => x.ToDelimitedString())) : null,
                       DonorEligibilityDate.HasValue ? DonorEligibilityDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       ProcessInterruption?.ToDelimitedString(),
                       ProcessInterruptionReason?.ToDelimitedString(),
                       PhlebotomyIssue != null ? string.Join(Configuration.FieldRepeatSeparator, PhlebotomyIssue.Select(x => x.ToDelimitedString())) : null,
                       IntendedRecipientBloodRelative,
                       IntendedRecipientName?.ToDelimitedString(),
                       IntendedRecipientDob.HasValue ? IntendedRecipientDob.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       IntendedRecipientFacility?.ToDelimitedString(),
                       IntendedRecipientProcedureDate.HasValue ? IntendedRecipientProcedureDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       IntendedRecipientOrderingProvider?.ToDelimitedString(),
                       PhlebotomyStatus?.ToDelimitedString(),
                       ArmStick?.ToDelimitedString(),
                       BleedStartPhlebotomist?.ToDelimitedString(),
                       BleedEndPhlebotomist?.ToDelimitedString(),
                       AphaeresisTypeMachine,
                       AphaeresisMachineSerialNumber,
                       DonorReaction,
                       FinalReviewStaffId?.ToDelimitedString(),
                       FinalReviewDateTime.HasValue ? FinalReviewDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       NumberOfTubesCollected.HasValue ? NumberOfTubesCollected.Value.ToString(Consts.NumericFormat, culture) : null,
                       DonationSampleIdentifier != null ? string.Join(Configuration.FieldRepeatSeparator, DonationSampleIdentifier.Select(x => x.ToDelimitedString())) : null,
                       DonationAcceptStaff?.ToDelimitedString(),
                       DonationMaterialReviewStaff != null ? string.Join(Configuration.FieldRepeatSeparator, DonationMaterialReviewStaff.Select(x => x.ToDelimitedString())) : null,
                       ActionCode
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
 public static int CalculateCredits(DonationType donationType) => donations.ContainsKey(donationType)
     ? donations[donationType]
     : throw new ServerException("Such donation does not exist");
Beispiel #19
0
        public ActionResult DonationCheckout(DonationType type, decimal amount)
        {
            if (type != DonationType.Single)
                return new HttpNotFoundResult("Only single donation allowed.");

            var model = new DonationCheckoutModel
            {
                Amount = amount.ToString("F2"),
                Type = type
            };

            this.ViewBag.Donations = ECommerceService.GetAllDonationsInfoForDomainByType(this.DomainID, DonationType.Single);
            this.ViewBag.Countries = ECommerceService.GetAllCountriesAsSelectList(this.DomainID);

            if (type == DonationType.Monthly)
            {
                //this.ViewBag.PaymentTypes = ECommerceService.GetAllPaymentDomainAsSelectList(this.DomainID, true)).ToList();
            }
            else
            {
                bool isDirect = DomainService.GetSettingsValue(SettingsKey.sagePayMethod, this.DomainID).ToLowerInvariant().Equals(SagePayPaymentType.Direct.ToString().ToLowerInvariant());
                this.ViewBag.PaymentTypes = ECommerceService.GetAllPaymentDomainAsSelectList(this.DomainID, true);
                this.ViewBag.IsDirect = isDirect;
                this.ViewBag.SagePay = ECommerceService.GetPaymentDomainIDByCode(this.DomainID, PaymentType.SagePay);
                if (isDirect)
                    this.ViewBag.CardTypes = Enum.GetValues(typeof(CardType)).Cast<CardType>().Select(c => new SelectListItem { Text = c.ToString(), Value = ((int)c).ToString() }).ToList();
            }

            return View(model);
        }
 public void Create(DonationType donationType)
 {
     _churchAppContext.DonationTypes.Add(donationType);
 }
 public void Delete(DonationType donationType)
 {
     _churchAppContext.DonationTypes.Remove(donationType);
 }
Beispiel #22
0
        public tbl_Orders SaveOrderAsDonation(int orderID, int domainID, decimal amount, string billingAddress1, string billingAddress2, string billingAddress3, string billingCity, string billingCountry,
                                              string billingFirstnames, string billingPhone, string billingPostCode, string billingState, string billingSurname, string customerEMail, int?customerID, int paymentDomainID, bool?giftAid,
                                              decimal totalTaxAmount, decimal totalAmount, DonationType donationType, int?parentOrderID)
        {
            var order = this.DbSet.FirstOrDefault(o => o.OrderID == orderID && o.O_DomainID == domainID);

            if (order == null)
            {
                order = new tbl_Orders()
                {
                    O_Timestamp     = DateTime.UtcNow,
                    O_DomainID      = domainID,
                    Currency        = "GBP",
                    O_ProductTypeID = (int)ProductType.Donation,
                    VendorTxCode    = "",
                    TxType          = "PAYMENT",
                };
                this.Create(order);
            }

            order.Amount = amount;

            order.BillingAddress1   = billingAddress1;
            order.BillingAddress2   = billingAddress2;
            order.BillingAddress3   = billingAddress3;
            order.BillingCity       = billingCity;
            order.BillingCountry    = billingCountry;
            order.BillingFirstnames = billingFirstnames;
            order.BillingPhone      = billingPhone;
            order.BillingPostCode   = billingPostCode;
            order.BillingState      = billingState;
            order.BillingSurname    = billingSurname;

            order.DeliveryAddress1   = billingAddress1;
            order.DeliveryAddress2   = billingAddress2;
            order.DeliveryAddress3   = billingAddress3;
            order.DeliveryCity       = billingCity;
            order.DeliveryCountry    = billingCountry;
            order.DeliveryFirstnames = billingFirstnames;
            order.DeliveryPhone      = billingPhone;
            order.DeliveryPostCode   = billingPostCode;
            order.DeliveryState      = billingState;
            order.DeliverySurname    = billingSurname;

            order.CustomerEMail     = customerEMail;
            order.CustomerID        = customerID;
            order.O_PaymentDomainID = paymentDomainID;
            order.GiftAid           = giftAid;
            order.O_DonationTypeID  = (int)donationType;
            order.O_ProductTypeID   = (int)ProductType.Donation;

            order.TotalTaxAmount = totalTaxAmount;
            order.TotalAmount    = totalAmount;


            order.O_ParentOrderID = parentOrderID;

            //if (parentOrderID.HasValue)
            //{
            //    var parentOrder = this.DbSet.FirstOrDefault(m => m.OrderID == parentOrderID.Value);
            //    if (parentOrder == null)
            //        return null;
            //    parentOrder.TotalTaxAmount += totalTaxAmount;
            //    parentOrder.TotalAmount += totalAmount;
            //}

            this.Context.SaveChanges();
            return(order);
        }
Beispiel #23
0
        public tbl_Orders SaveOrderForDonation(int orderID, int domainID, string billingAddress1, string billingAddress2, string billingAddress3, string billingCity, int billingCountryID, 
            string billingFirstnames, string billingPhone, string billingPostCode, string billingState, string billingSurname, string customerEMail, int? customerID, decimal amount,
            bool giftAid, int paymentDomainID, DonationType type, int? parentOrderID)
        {
            decimal totalTaxAmount = Math.Round((decimal)0, 2);
            //decimal totalDeliveryAmount = Math.Round((decimal)0, 2);
            //decimal deliveryTaxAmount = Math.Round((decimal)0, 2);
            //decimal totalDiscount = Math.Round((decimal)0, 2);
            decimal totalAmount = Math.Round(amount, 2);

            var country = CountryRepository.GetByID(billingCountryID);

            var orderDonation = OrdersRepository.SaveOrderAsDonation(orderID, domainID, totalAmount, billingAddress1, billingAddress2, billingAddress3, billingCity,
                country != null ? country.C_Code : String.Empty, billingFirstnames, billingPhone, billingPostCode, billingState, billingSurname, customerEMail,
                customerID, paymentDomainID, giftAid, totalTaxAmount, totalAmount, type, parentOrderID);

            if (orderDonation != null)
                orderDonation = OrdersRepository.UpdateOrderStatus(orderDonation.OrderID, (int)OrderStatus.Commited);

            return orderDonation;
        }
Beispiel #24
0
 public List<tbl_DonationInfo> GetAllDonationsInfoForDomainByType(int domainID, DonationType type)
 {
     string sType = type.ToString();
     return DonationInfoRepository.GetAllForDomain(domainID).Where(m => m.DI_Live == true && m.tbl_DonationType.DT_Name.Equals(sType)).ToList();
 }