public PartnershipNight GetPartnershipNightByDate(DateTime date, BvLocation loc)
 {
     var db = new ApplicationDbContext();
     return (from pnight in db.PartnershipNights.Include("Charity").Include("BVLocation")
             where pnight.StartDate == date && pnight.BVLocation == loc
             select pnight).FirstOrDefault();
 }
 public List<PartnershipNight> GetPartnershipNights(BvLocation l)
 {
     var db = new ApplicationDbContext();
     List<PartnershipNight> partnershipnights = (from c in db.PartnershipNights.Include("BvLocation").Include("Charity")
                                                 where c.BVLocation.BvLocationId == l.BvLocationId
                                                 select c).ToList<PartnershipNight>();
     return partnershipnights;
 }
        public void SaveBvLocation(BvLocation l)
        {
            var db = new ApplicationDbContext();
            if (l.BvLocationId == 0)
                db.BvLocations.Add(l);
            else
            {
                BvLocation dbEntry = db.BvLocations.Find(l.BvLocationId);
                if (dbEntry != null)
                {
                    dbEntry.Address = l.Address;
                    dbEntry.BvStoreNum = l.BvStoreNum;
                    dbEntry.City = l.City;
                    dbEntry.Phone = l.Phone;
                    dbEntry.Zip = l.Zip;
                }

            }
            db.SaveChanges();
        }
예제 #4
0
 public ActionResult LocationEdit(BvLocation l)
 {
     if (ModelState.IsValid)
     {
         lRepo.SaveBvLocation(l);
         TempData["message"] = string.Format("{0} has been saved", l.BvStoreNum);
         return RedirectToAction("LocationIndex");
     }
     else
     {
         return View(l);
     }
 }
 public void AddBvLocation(BvLocation bvLocation)
 {
     var db = new ApplicationDbContext();
     db.BvLocations.Add(bvLocation);
     db.SaveChanges(); ;
 }