Exemplo n.º 1
0
        public void CreateSponsorProfileTest()
        {
            using (var db = new CSBCDbContext())
            {
                var repPeople = new PersonRepository(db);
                var people = db.People.Where(p => p.Sponsor == true).ToList();
                var repColor = new ColorRepository(db);
                var color = repColor.GetByName(1, "Red").ID;

                Contract.Assert(color != 0);
                var repProfile = new SponsorProfileRepository(db);
                var person = people.FirstOrDefault();
                var sponsorProfile = repProfile.Insert(new SponsorProfile
                    {
                        SpoName = person.LastName + "Company",
                        SponsorProfileID = 0,
                        CompanyID = 1,
                        HouseID = person.HouseID,
                        State = "FL",
                        City = "Coral Springs",
                        Address = "10 Main Street",
                        ContactName = person.FirstName + " " + person.LastName

                    });

                var profile = repProfile.GetById(sponsorProfile.SponsorProfileID);
                Assert.IsTrue(profile != null);
                repProfile.Delete(profile);
                profile = repProfile.GetById(sponsorProfile.SponsorProfileID);
                Assert.IsTrue(profile == null);

            }
        }
Exemplo n.º 2
0
 public void GetSponsorsInSeasonTest()
 {
     using (var db = new CSBCDbContext())
     {
         var repProfile = new SponsorProfileRepository(db);
         var sponsors = repProfile.GetSponsorsInSeason(1, 9);
         Assert.IsTrue(sponsors.Any());
     }
 }
Exemplo n.º 3
0
 public void GetByIdSponsorProfileTest()
 {
     var context = new CSBCDbContext();
     var repProfile = new SponsorProfileRepository(context);
     var profile = context.SponsorProfiles.First<SponsorProfile>();
     var profile2 = repProfile.GetById(profile.SponsorProfileID);
     Assert.IsTrue(profile2 != null);
     Assert.IsTrue(profile2.SponsorProfileID == profile.SponsorProfileID);
 }
Exemplo n.º 4
0
        private void UpdateRow(int rowId)
        {
            using (var db = new CSBCDbContext())
            {
                var repSponsorProfile = new SponsorProfileRepository(db);
                var repSponsor = new SponsorRepository(db);

                try
                {
                    var sponsorProfile = CreateSponsorProfileObjectFromRow();
                    var sponsorProfileId = repSponsorProfile.Insert(sponsorProfile);
                    var sponsor = CreateSponsorObjectFromRow(sponsorProfileId.SponsorProfileID);

                    //sponsor.SpoAmount = cmbFees.SelectedItem.Text; // fee need to check

                    //need to update both tables
                    //oSponsors.UpdRow(RowID, Session["CompanyID"], Session["TimeZone"]);

                    Master.SponsorId = sponsor.SponsorID;
                    Master.SponsorProfileId = sponsorProfile.SponsorProfileID;
                }
                catch (Exception ex)
                {
                    ErrorMessage = "UpdRow::" + ex.Message;
                }
            }
        }
Exemplo n.º 5
0
        private void LoadProfile(int sponsorProfileId)
        {
            try
            {
                using (var db = new CSBCDbContext())
                {
                    var rep = new SponsorProfileRepository(db);
                    var sponsorProfile = rep.GetById(sponsorProfileId);

                    if (sponsorProfile != null)
                    {
                        txtSponsorName.Text = sponsorProfile.SpoName;
                        Master.SponsorProfileId = sponsorProfile.SponsorProfileID;
                        txtContact.Text = sponsorProfile.ContactName;
                        txtAddress.Text = sponsorProfile.Address;
                        txtCity.Text = sponsorProfile.City;
                        txtState.Text = sponsorProfile.State;
                        txtZip.Text = sponsorProfile.Zip;
                        txtPhone.Text = sponsorProfile.Phone;
                        txtWebsite.Text = sponsorProfile.URL;
                        txtEmail.Text = sponsorProfile.EMAIL;
                        //need to call function that gets balance
                        var repSponsor = new SponsorRepository(db);
                        var balance = repSponsor.GetSponsorBalance(sponsorProfile.SponsorProfileID);
                        lblBalance.Text = balance.ToString("C");
                        if (balance > 0)
                            lblBalance.ForeColor = System.Drawing.Color.Red;
                        if (balance == 0)
                            lblBalance.ForeColor = System.Drawing.Color.Black;
                        if (balance < 0)
                            lblBalance.ForeColor = System.Drawing.Color.DarkGreen;

                    }
                }

            }
            catch (Exception ex)
            {
                lblError.Text = "LoadProfile::" + ex.Message;
            }
        }
Exemplo n.º 6
0
 protected void LoadSponsors()
 {
     using (var db = new CSBCDbContext())
     {
         var rep = new SponsorProfileRepository(db);
         var sponsors = rep.GetAll(Master.CompanyId).ToList<SponsorProfile>();
         cmbSponsorNames.DataSource = sponsors;
         cmbSponsorNames.DataValueField = "SponsorProfileId";
         cmbSponsorNames.DataTextField = "SpoName";
         cmbSponsorNames.DataBind();
     }
 }
Exemplo n.º 7
0
        private void GetSponsorsForSeason(int seasonId)
        {
            using (var db = new CSBCDbContext())
            {
                try
                {
                    var rep = new SponsorProfileRepository(db);
                    List<SponsorProfile> sponsors;
                    //if (String.IsNullOrEmpty(value))
                        sponsors = rep.GetSponsorsInSeason(Master.CompanyId, Master.SeasonId).ToList<SponsorProfile>();
                    //else
                    //    sponsors = rep.GetAll(Master.CompanyId).ToList<SponsorProfile>();

                    gridSponsorsInSeason.DataSource = sponsors;
                    gridSponsorsInSeason.DataBind();
                }
                catch (Exception ex)
                {
                    lblError.Text = "GetData::" + ex.Message;
                }
                }
        }
Exemplo n.º 8
0
 public void SearchSponsorProfileTest2()
 {
     using (var db = new CSBCDbContext())
     {
         var repProfile = new SponsorProfileRepository(db);
         var sponsors = repProfile.GetAll(1, "Fa");
         Assert.IsTrue(sponsors.Any());
     }
 }