//Aka save/update charity
 public void EditCharity(Charity charity)
 {
     var db = new CapstoneDbContext();
     if (charity.CharityId == 0)
     {
         //first add any children
         //Add new user
         db.Charities.Add(charity);
     }
     else
     {
         Charity dbEntry = db.Charities.Find(charity.CharityId);
         if (dbEntry != null)
         {
             dbEntry.Name = charity.Name;
             dbEntry.Address = charity.Address;
             dbEntry.City = charity.City;
             dbEntry.Zip = charity.Zip;
             dbEntry.Phone = charity.Phone;
             dbEntry.FederalTaxId = charity.FederalTaxId;
             dbEntry.TypeOfCharity = charity.TypeOfCharity;
         }
     }
     db.SaveChanges();
 }
 public ActionResult Edit(Charity charity)
 {
     if (ModelState.IsValid)
     {
         // Save the changes to the partnership night
         charRepo.EditCharity(charity);
         TempData["message"] = string.Format("{0} has been saved", charity.Name);
         return RedirectToAction("Index");
     }
     else
     {
         // there is something wrong with the data values
         return View(charity);
     }
 }
 public ActionResult Index()
 {
     //data to get db up and running -- delete when done
     //add a location
     BvLocation loc1 = new BvLocation { Address = "333 N Main St", City = "BobVille", BvStoreNum = "BV99", Phone = "839-839-8393", Zip = "88898" };
     lRepo.AddBvLocation(loc1);
     //add a user
     User u1 = new User { UserFName = "Bob", UserLName = "Bobberson", AccessLevel = 1, BvLocation = loc1, Password = "******", UserEmail = "*****@*****.**", PhoneNumber = "541-389-8293" };
     uRepo.AddUser(u1);
     //add a charity
     Charity c1 = new Charity { Address = "8939 S Seventh", City = "CharityVille", FederalTaxId = "893018XS", Name = "HopeForBob", Phone = "893-829-8393", TypeOfCharity = "Helpful", Zip = "83928" };
     cRepo.AddCharity(c1);
     //add a partnership night
     PartnershipNight pn1 = new PartnershipNight { AfterTheEventFinished = false, AmountRaised = 0, BeforeTheEventFinished = true, BVLocation = loc1, Charity = c1, CheckRequestFinished = false, Comments = "blah blah", Date = DateTime.Parse("05/30/2014") };
     pnRepo.AddPartnershipNight(pn1);
     //add stats
     StatsInfo s1 = new StatsInfo { AmountOfTotalSalesToCharity = 25.88M, CashDonations = 19.83M, GuestCount = 10, TotalSales = 100.00M, partnershipNight = pn1};
     sRepo.AddStatsInfo(s1);
     return View();
 }
 public void AddCharity(Charity charity)
 {
     var db = new CapstoneDbContext();
     db.Charities.Add(charity);
     db.SaveChanges();
 }