Exemplo n.º 1
0
        public void Insert(MoneyDonation donation)
        {
            FinancialBoxRepository financialBoxRepository = new FinancialBoxRepository();

            if (donation == null)
            {
                throw new Exception("A doação não pode ser nulo");
            }

            if (donation.Value <= 0)
            {
                throw new Exception("A doação deve ser maior que 0");
            }

            if (string.IsNullOrEmpty(donation.Donor.Name))
            {
                throw new Exception("O doador precisa ter Name");
            }

            if (donation.Date == null || donation.Date == DateTime.MinValue)
            {
                throw new Exception("Informe a data da doação");
            }

            moneyDonationRepository.Insert(donation);

            FinancialBox financialBox = new FinancialBox();

            financialBox.Date        = donation.Date;
            financialBox.Description = "Caixa atualizado atraves da doação " + donation.Id;
            financialBox.Value       = donation.Value;

            financialBoxRepository.Insert(financialBox);
        }
Exemplo n.º 2
0
        public async Task <ActionResult> MoneyDonation(MoneyDonation model)
        {
            try
            {
                RootObject userLoc = getAddress(model.latitude, model.longitude);

                Donator donator = (Donator)Session["donator"];
                model.DonatorName  = donator.Name;
                model.DonatorEmail = donator.Email;
                model.Date         = DateTime.Now;
                model.Place        = userLoc.display_name;
                model.IsTaken      = false;
                model.IsDelivered  = false;
                model.IsConfirmed  = false;


                /* ================== send e-mail to volunteer ================ */
                var bodyMessage   = "You have a notification for money donation";
                var body          = "<p>Email From: {0} ({1})</p><p>Message: </p><p>{2}</p>";
                var message       = new MailMessage();
                var volunteerList = ReadVolunteerFromFirebase();
                // recipient mail (we have to send the notification to all volunteer)
                foreach (var v in volunteerList)
                {
                    message.To.Add(new MailAddress(v.Email));
                }
                message.From       = new MailAddress("*****@*****.**"); // sender mail
                message.Subject    = "Notifications for money donation from Hunger Solver";
                message.Body       = string.Format(body, model.DonatorName, model.DonatorEmail, bodyMessage);
                message.IsBodyHtml = true;

                using (var smtp = new SmtpClient())
                {
                    // the following information is fixed for gmail
                    // for outlook the host should be "smtp-mail.outlook.com"
                    // configuration for the Client
                    var credential = new NetworkCredential
                    {
                        UserName = "******", // sender mail
                        Password = "******"             // sender pass
                    };
                    smtp.Credentials = credential;
                    smtp.Host        = "smtp.gmail.com";
                    smtp.Port        = 587;
                    smtp.EnableSsl   = true;
                    await smtp.SendMailAsync(message);
                }

                CreateMoneyDonationToFirebase(model);

                return(this.Redirect("/Donation/MoneyDonation"));
            }
            catch (Exception e)
            {
                Debug.WriteLine("Exception from MoneyDonation Submit: " + e);
            }

            return(View());
        }
        public void UpdateMoneyDeliveredStatus(MoneyDonation data)
        {
            firebaseClient   = new FireSharp.FirebaseClient(firebaseConfig);
            data.IsDelivered = true;

            SetResponse setResponse = firebaseClient.Set("MoneyDonation/" + data._id, data);

            Debug.WriteLine("updated response");
        }
Exemplo n.º 4
0
        public void AddMoneyDonationToFirebase(MoneyDonation money)
        {
            firebaseClient = new FireSharp.FirebaseClient(firebaseConfig);
            var          data     = money;
            PushResponse response = firebaseClient.Push("MoneyDonation/", data);

            data._id = response.Result.name;
            SetResponse setResponse = firebaseClient.Set("MoneyDonation/" + data._id, data);
        }
Exemplo n.º 5
0
        public int CheckAmountBkash(int donorID, int organisationID)
        {
            MoneyDonation donation = new MoneyDonation()
            {
                //DonorID = donorID,
                //OrganisationID = organisationID
            };

            return(donationDataAccess.CheckAmountCard(donation));
        }
Exemplo n.º 6
0
        public int CardDonation(MoneyDonation moneyDonatation)
        {
            string        sql    = "SELECT Balance From Users WHERE CardNumber= '" + moneyDonatation.CardNumber + "' AND Pin= '" + moneyDonatation.CardPin + "'";
            SqlDataReader reader = this.GetData(sql);

            if (reader.Read())
            {
                return(Convert.ToInt32(reader["Amount"]));
            }
            return(-1);
        }
Exemplo n.º 7
0
        public int CheckAmountCard(MoneyDonation moneyDonation)
        {
            string        sql    = "SELECT Balance From BankAccount WHERE CardNumber= '" + moneyDonation.CardNumber + "' AND Pin= '" + moneyDonation.BkashPin + "'";
            SqlDataReader reader = this.GetData(sql);

            if (reader.Read())
            {
                return(Convert.ToInt32(reader["Balance"]));
            }
            return(-1);
        }
Exemplo n.º 8
0
        public int DonateByCard(long cardNumber, int amount, int pin)
        {
            MoneyDonation moneyDonation = new MoneyDonation()
            {
                CardNumber = cardNumber,
                CardAmount = amount,
                CardPin    = pin
            };

            return(moneyDonationDataAccess.CardDonation(moneyDonation));
        }
Exemplo n.º 9
0
        public int DonateByBkash(long phoneNumber, int amount, int pin)
        {
            MoneyDonation moneyDonation = new MoneyDonation()
            {
                MobileNumber = phoneNumber,
                BkashAmount  = amount,
                BkashPin     = pin
            };

            return(moneyDonationDataAccess.BkashDonation(moneyDonation));
        }
Exemplo n.º 10
0
 public void CreateMoneyDonationToFirebase(MoneyDonation money)
 {
     try
     {
         AddMoneyDonationToFirebase(money);
         ModelState.AddModelError(string.Empty, "Submitted Successfully");
     }
     catch (Exception ex)
     {
         ModelState.AddModelError(string.Empty, ex.Message);
         Debug.WriteLine("exception from Create money donation: " + ex.Message);
     }
 }
        public void UpdateMoneyConfirmationStatus(MoneyDonation data)
        {
            firebaseClient = new FireSharp.FirebaseClient(firebaseConfig);
            Volunteer volunteer = (Volunteer)Session["volunteer"];

            data.IsConfirmed    = true;
            data.VolunteerName  = volunteer.Name;
            data.VolunteerPhone = volunteer.Mobile;
            data.VolunteerEmail = volunteer.Email;
            SetResponse setResponse = firebaseClient.Set("MoneyDonation/" + data._id, data);

            SendConfirmationMessageToDonor("money", data.Amount, data.VolunteerName, data.VolunteerPhone, data.VolunteerEmail, data.DonatorEmail);
            Debug.WriteLine("updated response");
        }
Exemplo n.º 12
0
        public int CheckAmountBkash(MoneyDonation moneyDonation)
        {
            string        sql    = "SELECT Balance From Bkash WHERE PhoneNumber= '" + moneyDonation.MobileNumber + "' AND Pin= '" + moneyDonation.BkashPin + "'";
            SqlDataReader reader = this.GetData(sql);

            if (reader.Read())
            {
                return(Convert.ToInt32(reader["Balance"]));
            }
            return(-1);

            /*
             * string sql = "SELECT DonationID From Donations WHERE DonorId= '" + donation.DonorID + "' AND OrganisationID= '" + donation.OrganisationID + "'";
             * SqlDataReader reader = this.GetData(sql);
             * if (reader.Read())
             * {
             *
             *  return Convert.ToInt32(reader["Amount"]);
             * }
             * return -1;
             */
        }
Exemplo n.º 13
0
        private void btConfirmar_Click(object sender, EventArgs e)
        {
            try
            {
                MoneyDonation dinheiro = new MoneyDonation();
                dinheiro.Donor = new Donor();
                dinheiro.Date  = Doa.Date;
                dinheiro.Donor = Doa.Donor;
                dinheiro.Note  = Doa.Note;
                dinheiro.Type  = "Dinheiro";
                dinheiro.Value = Convert.ToDecimal(tbValor.Text);

                moneyDonationService.Insert(dinheiro);
                MessageBox.Show("Doação cadastrada com sucesso!");

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        // ================== deliver donation ==============
        public ActionResult DeliveredDonationByVolunteer(ConfirmDonation model)
        {
            string item_id = model.item_id;

            Debug.WriteLine(item_id);
            Debug.WriteLine("i'm triggering");
            try
            {
                firebaseClient = new FireSharp.FirebaseClient(firebaseConfig);

                if (model.item_type == "food")
                {
                    FirebaseResponse response = firebaseClient.Get("FoodDonation/" + item_id);
                    FoodDonation     data     = JsonConvert.DeserializeObject <FoodDonation>(response.Body);
                    UpdateFoodDeliveredStatus(data);
                }
                else if (model.item_type == "cloth")
                {
                    FirebaseResponse response = firebaseClient.Get("ClothDonation/" + item_id);
                    ClothDonation    data     = JsonConvert.DeserializeObject <ClothDonation>(response.Body);
                    UpdateClothDeliveredStatus(data);
                }
                else if (model.item_type == "money")
                {
                    FirebaseResponse response = firebaseClient.Get("MoneyDonation/" + item_id);
                    MoneyDonation    data     = JsonConvert.DeserializeObject <MoneyDonation>(response.Body);
                    UpdateMoneyDeliveredStatus(data);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception from Food Donation confirmation: " + ex);
            }

            return(RedirectToAction("/Index2"));
        }
 public void Insert(MoneyDonation donation)
 {
     db.MoneyDonations.Add(donation);
     Save();
 }
Exemplo n.º 16
0
        public MoneyDonation CreateMoneyDonation(MoneyDonation moneyDonation)
        {
            var createMoneyDonation = Context.Add(moneyDonation);

            return(createMoneyDonation.Entity);
        }