Esempio n. 1
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            Donator donator            = (Donator)dataGridView1.Rows[e.RowIndex].DataBoundItem;
            FormModificareDonator form = new FormModificareDonator(donator, this.serviceDonator, this);

            form.Show();
        }
Esempio n. 2
0
        protected void btnSignin_Click(object sender, EventArgs e)
        {
            Donator objDonatorOutput = new Donator();

            Donator objDonatorInput = new Donator();

            objDonatorInput.Email    = txtEmail.Value;
            objDonatorInput.Password = txtPwd.Value;

            BLL objBLL = new BLL();

            objDonatorOutput = objBLL.SignInBLL(objDonatorInput);

            // We are putting the entire output object objUserMasterOutput into the session variables so that all the user details
            // will be accessible throughout the application on all the pages.
            if (objDonatorOutput != null)
            {
                Session["UserDetailsSession"] = objDonatorOutput;
                Response.Redirect("UserDashboard.aspx");
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "UserNotFound", "alert('User not found.')", true);
            }
        }
Esempio n. 3
0
        private void btnAdauga_Click(object sender, EventArgs e)
        {
            PungaSange punga = new PungaSange();

            if (textBoxNume.Text == "" || textBoxPrenume.Text == "" || textBoxEmail.Text == "")
            {
                MessageBox.Show("Completati toate datele despre donator!");
            }
            else
            {
                Donator donator = new Donator();
                donator.Email               = textBoxEmail.Text;
                donator.Nume                = textBoxNume.Text;
                donator.Prenume             = textBoxPrenume.Text;
                punga.CantitateSange        = 500.0F;
                punga.CantitatePlasma       = 275.0F;
                punga.CantitateGlobuleRosii = 75;  //trilioane
                punga.CantitateTrombocite   = 150; //miliarde
                try
                {
                    serviceCentru.AddPungaSange(punga, donator, centru);
                }catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                loadDataGridView2();
            }
        }
Esempio n. 4
0
        public Donator findOne(int id)
        {
            log.InfoFormat("Entering findOne with value {0}", id);
            IDbConnection con = DBUtils.getConnection();

            using (var comm = con.CreateCommand())
            {
                comm.CommandText = "select id,nume, adresa, nrTelefon from donatori where id=@id";
                IDbDataParameter paramId = comm.CreateParameter();
                paramId.ParameterName = "@id";
                paramId.Value         = id;
                comm.Parameters.Add(paramId);

                using (var dataR = comm.ExecuteReader())
                {
                    if (dataR.Read())
                    {
                        int     idD       = dataR.GetInt32(0);
                        String  nume      = dataR.GetString(1);
                        String  adresa    = dataR.GetString(2);
                        long    nrTelefon = dataR.GetInt64(3);
                        Donator donator   = new Donator(idD, nume, adresa, nrTelefon);
                        log.InfoFormat("Exiting findOne with value {0}", donator);
                        return(donator);
                    }
                }
            }
            log.InfoFormat("Exiting findOne with value {0}", null);
            return(null);
        }
Esempio n. 5
0
        protected void btnSignUp_Click(object sender, EventArgs e)
        {
            int output;             //Step 2.1
            BLL objBLL = new BLL(); // Step 2.2

            //Step 1: Instantiate UserMaster from the BusinessObjects class and assign user inputs from the form to the object objUserMaster properties.
            Donator objDonator = new Donator();

            objDonator.FullName = txtFullName.Value;
            objDonator.Email    = txtEmail.Value;
            objDonator.Password = txtPwd.Value;
            objDonator.Active   = 1;
            objDonator.Role     = "User";

            //Step 2: Call the signup method of BLL(SignUpBLL)
            output = objBLL.SignUpBLL(objDonator);

            //Step 3: Display an alert box based on the output
            //If a row is affected (Success condition), alert box will be displayed for success else error message will be displayed.
            if (output > 0)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alertwindow", "alert('Registered successfully');window.location.href = 'SignIn.aspx';", true);
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "alertwindow", "alert('Error occurred');window.location.href = 'SignUpPage.aspx';", true);
            }
        }
Esempio n. 6
0
        public void FindDonatorTest()
        {
            var _datetime = new DateTime(2018, 4, 14);
            var _donator  = new Donator();

            _donator.Id                 = 1;
            _donator.IdUtilizator       = 1;
            _donator.Nume               = "TEST";
            _donator.Prenume            = "TEST";
            _donator.DataDonarePosibila = _datetime;

            Donator _foundDonator = null;

            try
            {
                _donatorRepository.Add(_donator);
                _foundDonator = _donatorRepository.Find(_donator.Id);
            }
            catch (Exception)
            {
                Assert.Fail();
            }

            Assert.IsTrue(_foundDonator != null);
            Assert.IsTrue(_foundDonator.Id == _donator.Id);
            Assert.IsTrue(_foundDonator.IdUtilizator == _donator.IdUtilizator);
            Assert.IsTrue(_foundDonator.Nume == _donator.Nume);
            Assert.IsTrue(_foundDonator.Prenume == _donator.Prenume);
            Assert.IsTrue(_foundDonator.DataDonarePosibila == _donator.DataDonarePosibila);
            Assert.IsTrue(_foundDonator.GrupaDeSange == _donator.GrupaDeSange);
        }
Esempio n. 7
0
        public void UpdateDonatorTest()
        {
            var _datetime = new DateTime(2018, 4, 14);
            var _donator  = new Donator();

            _donator.Id                 = 1;
            _donator.IdUtilizator       = 1;
            _donator.Nume               = "TEST";
            _donator.Prenume            = "TEST";
            _donator.DataDonarePosibila = _datetime;

            var _newDateTime = new DateTime(2018, 4, 13);

            try
            {
                _donatorRepository.Add(_donator);
                _donator.IdUtilizator       = 1;
                _donator.Nume               = "TESTUPDATE";
                _donator.Prenume            = "TESTUPDATE";
                _donator.DataDonarePosibila = _newDateTime;
                _donatorRepository.Update(_donator);
            }
            catch (Exception)
            {
                Assert.Fail();
            }

            var _foundDonator = _donatorRepository.Find(_donator.Id);

            Assert.IsTrue(_foundDonator.Nume == "TESTUPDATE");
            Assert.IsTrue(_foundDonator.Prenume == "TESTUPDATE");
            Assert.IsTrue(_foundDonator.DataDonarePosibila == _newDateTime);
        }
Esempio n. 8
0
        public void DeleteDonatorTest()
        {
            var _datetime = new DateTime(2018, 4, 14);
            var _donator  = new Donator();

            _donator.Id                 = 1;
            _donator.IdUtilizator       = 1;
            _donator.Nume               = "TEST";
            _donator.Prenume            = "TEST";
            _donator.DataDonarePosibila = _datetime;

            var _initialSize = _donatorRepository.GetAll().Count();

            try
            {
                _donatorRepository.Add(_donator);
                _donatorRepository.Delete(_donator.Id);
            }
            catch (Exception)
            {
                Assert.Fail();
            }

            Assert.IsTrue(_initialSize == _donatorRepository.GetAll().Count());
        }
Esempio n. 9
0
        /*
         * GetDonatorInfo() takes the username and password given
         * and constructs a donator object and posts it to the api.
         *
         * The specific method in the django view that it posts it to takes
         * it and checks if there are any donators that match the posted donators and if there are
         * it returns a http status code 202 and if there arent it returns some other status code.
         *
         * The c# method returns a true or false based on wheter or not the donator was found in the database.
         */
        public static async Task <bool> GetDonatorInfo(string newUsername, string newPassword)
        {
            int     placeholderId = 0;//we can give the donator a random id because the API handles assigning IDs
            Donator newDonator    = new Donator()
            {
                id       = placeholderId,
                username = newUsername,
                password = newPassword,
            };                                                                                    //constructing the donator
            string json       = JsonConvert.SerializeObject(newDonator);
            var    content    = new StringContent(json, Encoding.UTF8, "application/json");       //formatting the string as JSON
            var    httpClient = new HttpClient();
            var    result     = await httpClient.PostAsync(String.Concat(URL, "auth/"), content); //change this later

            var contentstr = await result.Content.ReadAsStringAsync();

            var dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(contentstr);

            if (result.StatusCode == System.Net.HttpStatusCode.Created)
            {
                DonatorId = Convert.ToInt32(dict["id"]);
                return(true);
            }
            return(false);
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,FirstName,LastName,Sex,Email,PhoneNumber,State")] Donator donator)
        {
            if (id != donator.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(donator);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DonatorExists(donator.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(donator));
        }
Esempio n. 11
0
 private void Register(object obj)
 {
     // check if fields null
     try
     {
         var pass    = ((PasswordBox)obj).Password;
         var donator = new Donator();
         donator.Nume               = DonatorViewModel.Nume;
         donator.Prenume            = DonatorViewModel.Prenume;
         donator.DataDonarePosibila = DateTime.Now;
         donator.UserName           = DonatorViewModel.Username;
         donator.Password           = pass;
         donator.GrupaDeSange       = GrupaDeSange.Id;
         donator.TipUtilizator      = TipUtilizator.Donator.ToString();
         donator.InstitutieAsociata = InstitutieSelectata.Id;
         AppService.Instance.DonatorService.Add(donator);
         MessageBox.Show("Contol a fost creat cu succes!", "Info", MessageBoxButton.OK);
         var loginView = new LoginView();
         loginView.Show();
         Application.Current.MainWindow.Close();
         Application.Current.MainWindow = loginView;
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message, "Error", MessageBoxButton.OK);
     }
 }
Esempio n. 12
0
        public void InitializeTests()
        {
            _donator = new Donator
            {
                DataDonarePosibila = DateTime.Now,
                GrupaDeSange       = 7,
                Nume               = "TestFunctionalPrelucrare",
                Prenume            = "TestFunctionalPrelucrare",
                TipUtilizator      = "Donator",
                InstitutieAsociata = 10,
                UserName           = "******",
                Password           = "******"
            };

            _donatorService.Add(_donator);

            // create a mock donatie

            _donatiePrelucrabila = new Donatie
            {
                GrupaDeSange       = 6,
                DataDonare         = DateTime.Now,
                IdDonator          = _donator.Id,
                EtapaDonare        = "Analizata",
                InstitutieAsociata = _donator.InstitutieAsociata,
                MotivRefuz         = ""
            };

            _donatieService.Add(_donatiePrelucrabila);
        }
Esempio n. 13
0
        public IEnumerable <Donator> findAll()
        {
            log.Info("Entering findAll - Donator");
            IDbConnection   con      = DBUtils.getConnection();
            IList <Donator> donatori = new List <Donator>();

            using (var comm = con.CreateCommand())
            {
                comm.CommandText = "select id,nume,adresa,nrTelefon from donatori";

                using (var dataR = comm.ExecuteReader())
                {
                    while (dataR.Read())
                    {
                        int    idD       = dataR.GetInt32(0);
                        String nume      = dataR.GetString(1);
                        String adresa    = dataR.GetString(2);
                        long   nrTelefon = dataR.GetInt64(3);

                        Donator donator = new Donator(idD, nume, adresa, nrTelefon);
                        donatori.Add(donator);
                    }
                }
            }
            log.Info("Exiting findAll - Donator");
            return(donatori);
        }
Esempio n. 14
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,FirstName,LastName,Sex,Email,PhoneNumber,State,Elligible,BloodTypeID")] Donator donator)
        {
            if (id != donator.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await _context.UpdateDonator(donator);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_context.DonatorExists(donator.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BloodTypeID"] = new SelectList(_context.GetListOfBloodTypes(), "ID", "Type", donator.BloodTypeID);
            return(View(donator));
        }
Esempio n. 15
0
        public void getDonatorInstantiate(List <string[]> listOfDonators)
        {
            Donator BloodDonator;

            foreach (var item in listOfDonators)
            {
                BloodDonator = new Donator
                {
                    FirstName    = item[0],
                    LastName     = item[1],
                    Pesel        = item[2],
                    BloodType    = item[3],
                    BloodFactor  = item[4],
                    BloodAmount  = item[5],
                    DonationDate = item[6],
                    Place        = item[7]
                };

                if (validateDonator(BloodDonator))
                {
                    BloodDonator.IsDataValid = true;
                }
                else
                {
                    BloodDonator.IsDataValid = false;
                }

                addDonatorToDb(BloodDonator);
            }
        }
        public async Task <Guid> SaveDonator([FromBody] DonatorModel donatorModel)
        {
            var donator = new Donator(
                donatorModel.Name,
                donatorModel.Title,
                donatorModel.EmailAddress,
                donatorModel.Comment,
                donatorModel.Address,
                donatorModel.DonateeId,
                donatorModel.Keywords,
                donatorModel.Image);

            this.db.Donator.Add(donator);
            await this.db.SaveChangesAsync();

            var donatee = await this.db.Donatee.FindAsync(donator.DonateeId);

            if (!string.IsNullOrEmpty(donatorModel.EmailAddress))
            {
                var client = GetClient();

                var fullAddress = $"{this.configuration.GetValue<string>("PartWithEndpoint")}/content/{donatorModel.DonateeId}";
                var htmlBody    = "<p>You have received a new donation through PartWith!<br/> Here is a direct " + "<a href=" + fullAddress + ">link</a>" + " to that campaign. </p>";
                var mail        = new MailMessage("*****@*****.**", donatee.EmailAddress !, "Track PartWith donation: " + donatorModel.Title, htmlBody);
                mail.IsBodyHtml = true;
                client.Send(mail);
            }

            return(donator.Id);
        }
Esempio n. 17
0
        public async Task <IActionResult> Edit(int id, [Bind("Donatorid,GrupaKrwi,Rh,Waga,Wzrost,Nastepnadonacja,Osobaid")] Donator donator)
        {
            if (id != donator.Donatorid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(donator);
                    await _context.SaveChangesAsync();

                    _context.Attach(donator).State = EntityState.Detached;
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DonatorExists(donator.Donatorid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Osobaid"] = new SelectList(_context.Osoba, "Osobaid", "Osobaid", donator.Osobaid);
            return(View(donator));
        }
Esempio n. 18
0
        public Donator findOne(int id)
        {
            log.Info("find one donator");
            IDbConnection con = dbUtils.DBUtils.getConnection();

            using (var comm = con.CreateCommand())
            {
                comm.CommandText = "select * from Donatori where id_donator=@id";
                IDbDataParameter paramId = comm.CreateParameter();
                paramId.ParameterName = "@id";
                paramId.Value         = id;
                comm.Parameters.Add(paramId);
                using (var dataR = comm.ExecuteReader())
                {
                    if (dataR.Read())
                    {
                        int    i = dataR.GetInt32(0);
                        string n = dataR.GetString(1);
                        string a = dataR.GetString(2);
                        string t = dataR.GetString(3);

                        Donator d = new Donator(n, t, a);
                        d.Id = i;
                        return(d);
                    }
                }
            }
            return(null);
        }
Esempio n. 19
0
        public IEnumerable <Donator> findAll()
        {
            log.Info("getting all donators");
            lock (this)
            {
                IDbConnection con = dbUtils.DBUtils.getConnection();

                /*       Npgsql.NpgsqlConnection con1 = (Npgsql.NpgsqlConnection)con;
                 *     Npgsql.NpgsqlConnection.ClearPool(con1);*/

                List <Donator> donatori = new List <Donator>();
                using (var comm = con.CreateCommand())
                {
                    comm.CommandText = "select * from donatori";


                    using (var dataR = comm.ExecuteReader())
                    {
                        while (dataR.Read())
                        {
                            Donator d = new Donator(dataR.GetString(1), dataR.GetString(2), dataR.GetString(3));
                            d.Id = dataR.GetInt32(0);
                            donatori.Add(d);
                        }
                    }
                }

                log.InfoFormat("exit findall with value {0}", donatori);
                return(donatori);
            }
        }
Esempio n. 20
0
        public IList <Donator> findDonatoriDupaNume(string nume)
        {
            log.InfoFormat("getting donators with name {0}", nume);
            IDbConnection  con      = dbUtils.DBUtils.getConnection();
            List <Donator> donatori = new List <Donator>();

            using (var comm = con.CreateCommand())
            {
                comm.CommandText = "select * from donatori where name=@name";
                IDbDataParameter paramName = comm.CreateParameter();
                paramName.ParameterName = "@name";
                paramName.Value         = nume;
                comm.Parameters.Add(paramName);
                using (var dataR = comm.ExecuteReader())
                {
                    while (dataR.Read())
                    {
                        Donator d = new Donator(dataR.GetString(1), dataR.GetString(2), dataR.GetString(3));
                        d.Id = dataR.GetInt32(0);
                        donatori.Add(d);
                    }
                }
            }

            log.InfoFormat("exiting with value {0}", donatori);
            return(donatori);
        }
Esempio n. 21
0
 private void handleDonatori(string numeDonator, string nrTel, string adresa)
 {
     lock (this)
     {
         Donator donator = null;
         try
         {
             donator = getDonator(numeDonator, nrTel);
             if (donator != null)
             {
                 if (!adresa.Equals(donator.Address))
                 {
                     Donator forUpdate = new Donator(numeDonator, nrTel, adresa);
                     forUpdate.Id = donator.Id;
                     updateDonator(forUpdate);
                     notifyAllDonatorUpdate(forUpdate);
                 }
             }
             else
             {
                 saveDonator(new Donator(numeDonator, nrTel, adresa));
                 Donator d = getDonator(numeDonator, nrTel);
                 notifyAllDonatorAdd(d);
             }
         }
         catch (TeledonException e)
         {
             Console.WriteLine("exceptie donator get server");
         }
     }
 }
Esempio n. 22
0
        public void RegisterDonator(string userName, string password, string nume, string prenume, string sex, DateTime dataNastere, string domiciliu, string localitate, string judet, string resedinta, string localitateResedinta, string judetResedinta, string telefon, string email)
        {
            using (UnitOfWork unitOfWork = new UnitOfWork())
            {
                Donator donator = new Donator(nume, prenume, sex, dataNastere, domiciliu, localitate, judet, resedinta, localitateResedinta, judetResedinta, telefon, email);
                unitOfWork.DonatorRepo.Save(donator);
                string      encryptedPassword = Util.EncryptPassword(password);
                UserDonator user = new UserDonator(userName, encryptedPassword);
                unitOfWork.UserDonatorRepo.Save(user);
                unitOfWork.Save();
                donator             = unitOfWork.DonatorRepo.GetBy(d => d.Email.Equals(email));
                user                = unitOfWork.UserDonatorRepo.GetBy(u => u.Username.Equals(userName));
                donator.UserDonator = user;
                user.Donator        = donator;
                unitOfWork.Save();

                /*
                 * Donator donator = new Donator(nume, prenume, sex, dataNastere, domiciliu, localitate, judet, resedinta, localitateResedinta, judetResedinta, telefon, email);
                 * string encryptedPassword = Util.EncryptPassword(password);
                 * UserDonator user = new UserDonator(userName, encryptedPassword);
                 * donator.UserDonator = user;
                 * user.Donator = donator;
                 * unitOfWork.UserDonatorRepo.Save(user);
                 * unitOfWork.DonatorRepo.Save(donator);
                 * unitOfWork.Save();
                 */
            }
        }
Esempio n. 23
0
        public HttpResponseMessage DisconfirmDonatorInRequest(RequestDisconfirmDonatorModel model)
        {
            bool isCanceled = false;


            DonationsRequest request = this.requestsManager.GetItem(model.RequestId) as DonationsRequest;

            if (request != null)
            {
                Donator donator = request.Donators.FirstOrDefault(i => i.UserId == model.UserId) as Donator;

                if (donator != null)
                {
                    donator.IsApproved = false;

                    this.donatorsManager.UpdateItem(donator);
                    this.donatorsManager.SaveChanges();

                    isCanceled = true;
                }
            }

            HttpResponseMessage resp = new HttpResponseMessage();

            resp.Content = new StringContent(JsonConvert.SerializeObject(new ChangeGeneralResponseViewModel()
            {
                IsSuccessful = isCanceled
            }));
            resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            return(resp);
        }
Esempio n. 24
0
 public void commitDonatori(string nume, string nrTel, string adresa)
 {
     lock (this)
     {
         Donator donator = null;
         try
         {
             donator = getDonator(nume);
             if (donator != null && donator.PhoneNumber.Equals(nrTel))
             {
                 Donator forUpdate = new Donator(nume, nrTel, adresa);
                 forUpdate.Id = donator.Id;
                 updateDonator(forUpdate);
             }
             else
             {
                 saveDonator(new Donator(nume, nrTel, adresa));
             }
         }
         catch (TeledonException e)
         {
         }
         notifyAllAngajatiCommit();
     }
 }
Esempio n. 25
0
        public int SignUpDAL(Donator objDonator)
        {
            int           output     = 0;
            SqlConnection connection = new SqlConnection(ConnectionString);
            string        sql        = string.Format(@"INSERT INTO
		[Donator] (FullName, Email, Password, Active, Role) VALUES
		('{0}','{1}','{2}','{3}','{4}')"        ,
                                                     objDonator.FullName,
                                                     objDonator.Email, objDonator.Password, objDonator.Active, objDonator.Role);
            SqlCommand command = new SqlCommand(sql, connection);

            try
            {
                connection.Open();
                // ExecuteNonQuery() is Used to execute the insert command.
                // This inserts the data into the DB.
                output = command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
            return(output);
        }
Esempio n. 26
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());
        }
Esempio n. 27
0
 public void UpdateDonator(Donator donator)
 {
     using (UnitOfWork unitOfWork = new UnitOfWork())
     {
         unitOfWork.DonatorRepo.Update(donator);
         unitOfWork.Save();
     }
 }
Esempio n. 28
0
        public ActionResult DeleteConfirmed(int id)
        {
            Donator donator = db.Donator.Find(id);

            db.Donator.Remove(donator);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 29
0
 static void UpdateDoonator(Donator entity)
 {
     using (var db = new DonateContext())
     {
         db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
 public DonatorViewModel(Donator donator) : base(donator.UtilizatorObj)
 {
     IdUtilizator       = donator.IdUtilizator;
     Nume               = donator.Nume;
     Prenume            = donator.Prenume;
     DataDonarePosibila = donator.DataDonarePosibila;
     GrupaDeSange       = donator.GrupaDeSange;
 }
Esempio n. 31
0
        //添加单个Donator
        public static void CreateSingleDonator()
        {
            using (var context = new Context())
                //Context的实例用了using语句包装起来,这是因为DbContext实现了IDisposable接口。Dbcontext还包含了DbConnection的实例,该实例指向了具有特定连接字符串的数据库。在EF中合适地释放数据库连接和ADO.NET中同等重要
            {
                context.Database.CreateIfNotExists(); //如果数据库不存在则创建

                Donator donators = new Donator() {Name = "单个", Amount = 50, DonateDate = new DateTime(2016, 4, 7)};

                context.Donators.Add(donators);
                context.SaveChanges();

            }
        }
 public void Create(Donator donator)
 {
     //Donator donator = new Donator();
     db.Donator.Add(donator);
     db.SaveChanges();
 }
Esempio n. 33
0
        //一对多关系, 自定义配置链接
        public static void OneToManyCustom()
        {
            using (var context = new Context())
            {
                var donator = new Donator
                {
                    Amount = 6,
                    Name = "一对多时,添加的捐赠者",
                    DonateDate = DateTime.Parse("2016-7-6")
                };

                donator.PayWays.Add(new PayWay { Name = "支付宝" });
                donator.PayWays.Add(new PayWay { Name = "微信" });
                context.Donators.Add(donator);
                context.SaveChanges();
            }
        }