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();
 }
Example #2
0
        public void SaveUser(User u)
        {
            var db = new CapstoneDbContext();
            if (u.UserId == 0)
                db.Users.Add(u);
            else
            {
                User dbEntry = db.Users.Find(u.UserId);
                if (dbEntry != null)
                {
                    dbEntry.UserFName = u.UserFName;
                    dbEntry.UserLName = u.UserLName;
                    dbEntry.UserEmail = u.UserEmail;
                    dbEntry.PhoneNumber = u.PhoneNumber;
                    dbEntry.AccessLevel = u.AccessLevel;
                    dbEntry.BvLocation = u.BvLocation;
                }

            }
            db.SaveChanges();
        }
 public ActionResult EditUser(User u)
 {
     if (ModelState.IsValid)
     {
         BvLocation l = lRepo.GetBvLocation(u.BvLocation.BvStoreNum);
         if (l != null)
         {
             u.BvLocation = l;
             uRepo.SaveUser(u);
             TempData["message"] = string.Format("{0} has been saved", u.UserFName + " " + u.UserLName);
         }
         else
         {
             TempData["message"] = string.Format("{0} is not a valid Restaurant", u.BvLocation.BvStoreNum);
         }
         return RedirectToAction("AdminUserIndex");
     }
     else
     {
         return View(u);
     }
 }