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); } }
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); }
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; } }