コード例 #1
0
        /*
        public IQueryable<PartnershipNight> GetPartnershipNightsByMonth(DateTime extractMonthAndYear)
        {
            throw new NotImplementedException();
        }

        public IQueryable<PartnershipNight> GetPartnershipNightsByDate(DateTime date)
        {
            throw new NotImplementedException();
        }

        public IQueryable<PartnershipNight> GetPartnershipNightsByLoc(BvLocation loc)
        {
            throw new NotImplementedException();
        }

        public IQueryable<PartnershipNight> GetPartnershipNightsByDateRange(DateTime firstDate, DateTime lastDate, BvLocation loc)
        {
            throw new NotImplementedException();
        }
        */
        public void UpdatePartnershipNight(PartnershipNight pn)
        {
            var db = new CapstoneDbContext();
            if (pn.PartnershipNightId == 0)
            {
                pn.Charity = db.Charities.Find(pn.Charity.CharityId);
                pn.BVLocation = db.BvLocations.Find(pn.BVLocation.BvLocationId);
                db.PartnershipNights.Add(pn);
            }
            else
            {
                var dbEntry = db.PartnershipNights.Find(pn.PartnershipNightId);
                if (dbEntry != null)
                {
                    dbEntry.Date = pn.Date;
                    dbEntry.Charity = pn.Charity;
                    dbEntry.BVLocation = pn.BVLocation;
                    dbEntry.CheckRequestId = pn.CheckRequestId;
                    dbEntry.Comments = pn.Comments;
                    dbEntry.CheckRequestFinished = pn.CheckRequestFinished;
                    dbEntry.BeforeTheEventFinished = pn.BeforeTheEventFinished;
                    dbEntry.AfterTheEventFinished = pn.AfterTheEventFinished;
                }
            }
            db.SaveChanges();
        }
コード例 #2
0
 public void DeletePartnershipNight(PartnershipNight pn)
 {
     //throw new NotImplementedException();
     var db = new CapstoneDbContext();
     db.PartnershipNights.Remove(pn);
     db.SaveChanges();
     //TODO: Add in error handling
 }
コード例 #3
0
 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();
 }
コード例 #4
0
 public PartnershipNight UpdatePartnershipNight(PartnershipNight pn)
 {
     throw new NotImplementedException();
 }
コード例 #5
0
        public ActionResult Edit(PNightEditViewModel vmodel)
        {
            //PartnershipNight pnight = pnRepo.GetPartnershipNights().FirstOrDefault<PartnershipNight>(pn => pn.PartnershipNightId)

            if (ModelState.IsValid)
            {
                // Transfer view model values to a partnership night object
                PartnershipNight pnight = new PartnershipNight();
                pnight.PartnershipNightId = vmodel.PartnershipNightId;
                pnight.Date = vmodel.Date;
                pnight.Comments = vmodel.Comments;
                pnight.CheckRequestId = vmodel.CheckRequestId;
                pnight.CheckRequestFinished = vmodel.CheckRequestFinished;
                pnight.BeforeTheEventFinished = vmodel.BeforeTheEventFinished;
                pnight.AfterTheEventFinished = vmodel.AfterTheEventFinished;

                // Store the correct child objects
                pnight.Charity = charRepo.GetCharities().FirstOrDefault(ch => ch.CharityId == vmodel.CharityId);
                pnight.BVLocation = bvlocRepo.GetBvLocations().FirstOrDefault(bvl => bvl.BvLocationId == vmodel.BVLocationId);

                // Save the changes to the partnership night
                pnRepo.UpdatePartnershipNight(pnight);
                TempData["message"] = string.Format("Partnership Night for BV Location {0}, {1} has been saved", pnight.Date.ToShortDateString(), pnight.BVLocation.BvStoreNum);
                return RedirectToAction("Index");
            }
            else
            {
                // there is something wrong with the data values
                return View(vmodel);
            }
        }