예제 #1
0
        public void UpdateForm(Entities.Form sec3)
        {
            var db = new CapstoneDbContext();

               if (sec3.FormId == 0)
               {
               db.Forms.Add(sec3);
               }
               else
               {
               var dbEntry = db.Forms.Find(sec3.FormId);
               if (dbEntry != null)
               {
                   dbEntry.ActualSalesFour = sec3.ActualSalesFour;
                   dbEntry.ActualSalesFive = sec3.ActualSalesFive;
                   dbEntry.ActualSalesSix = sec3.ActualSalesSix;
                   dbEntry.ActualSalesSeven = sec3.ActualSalesSeven;
                   dbEntry.ActualSalesEight = sec3.ActualSalesEight;
                   dbEntry.ActualGcFour = sec3.ActualGcFour;
                   dbEntry.ActualGcFive = sec3.ActualGcFive;
                   dbEntry.ActualGcSix = sec3.ActualGcSix;
                   dbEntry.ActualGcSeven = sec3.ActualGcSeven;
                   dbEntry.ActualGcEight = sec3.ActualGcEight;
                   dbEntry.PosiDonations = sec3.PosiDonations;
                   dbEntry.Notes = sec3.Notes;
               }
               db.SaveChanges();
               }
        }
예제 #2
0
        public IQueryable<Entities.Form> GetForms()
        {
            var db = new CapstoneDbContext();

            return (from sec3 in db.Forms
                    select sec3).AsQueryable<Form>();
        }
예제 #3
0
        public void AddCharity(Charity charity)
        {
            var db = new CapstoneDbContext();

            db.Charities.Add(charity);
            db.SaveChanges();
        }
예제 #4
0
 public Entities.User GetUser(int userId)
 {
     var db = new CapstoneDbContext();
     return (from u in db.Users.Include("BvLocation")
             where u.UserId == userId
             select u).FirstOrDefault();
 }
예제 #5
0
        public void AddUser(Entities.User u)
        {
            try
              {
            var db = new CapstoneDbContext();
            db.Users.Add(u);

                db.SaveChanges();
              }
              catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) //Catches errors in creating the db User table for the first time
              {
              Exception raise = dbEx;
              foreach (var validationErrors in dbEx.EntityValidationErrors)
              {
                  foreach (var validationError in validationErrors.ValidationErrors)
                  {
                      string message = string.Format("{0}:{1}",
                          validationErrors.Entry.Entity.ToString(),
                          validationError.ErrorMessage);
                      // raise a new exception nesting
                      // the current instance as InnerException
                      raise = new InvalidOperationException(message, raise);
                  }
              }
              throw raise;
              }
        }
 public PartnershipNight GetPartnershipNightById(int eventId)
 {
     var db = new CapstoneDbContext();
     return (from pnight in db.PartnershipNights.Include("Charity").Include("BVLocation")
             where pnight.PartnershipNightId == eventId
             select pnight).FirstOrDefault();
 }
예제 #7
0
 //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 PartnershipNight GetPartnershipNightByDate(DateTime date, BvLocation loc)
 {
     var db = new CapstoneDbContext();
     return (from pnight in db.PartnershipNights.Include("Charity").Include("BVLocation")
             where pnight.Date == date && pnight.BVLocation == loc
             select pnight).FirstOrDefault();
 }
예제 #9
0
        public void AddUser(Entities.User u)
        {
            var db = new CapstoneDbContext();

            db.Users.Add(u);
            db.SaveChanges();
        }
예제 #10
0
        /*public Charity GetCharityById(int id)
         * {
         *  //throw new NotImplementedException();
         *  var db = new CapstoneDbContext();
         *  return (from charity in db.Charities
         *          where charity.CharityId == id
         *          select charity).FirstOrDefault();
         * }*/

        public IQueryable <Charity> GetCharities()
        {
            var db = new CapstoneDbContext();

            return((from charity in db.Charities
                    select charity).AsQueryable <Charity>());
        }
예제 #11
0
        public void UpdateForm(Entities.Form sec3)
        {
            var db = new CapstoneDbContext();

            if (sec3.FormId == 0)
            {
                db.Forms.Add(sec3);
            }
            else
            {
                var dbEntry = db.Forms.Find(sec3.FormId);
                if (dbEntry != null)
                {
                    dbEntry.ActualSalesFour  = sec3.ActualSalesFour;
                    dbEntry.ActualSalesFive  = sec3.ActualSalesFive;
                    dbEntry.ActualSalesSix   = sec3.ActualSalesSix;
                    dbEntry.ActualSalesSeven = sec3.ActualSalesSeven;
                    dbEntry.ActualSalesEight = sec3.ActualSalesEight;
                    dbEntry.ActualGcFour     = sec3.ActualGcFour;
                    dbEntry.ActualGcFive     = sec3.ActualGcFive;
                    dbEntry.ActualGcSix      = sec3.ActualGcSix;
                    dbEntry.ActualGcSeven    = sec3.ActualGcSeven;
                    dbEntry.ActualGcEight    = sec3.ActualGcEight;
                    dbEntry.PosiDonations    = sec3.PosiDonations;
                    dbEntry.Notes            = sec3.Notes;
                }
                db.SaveChanges();
            }
        }
예제 #12
0
        public IQueryable <BvLocation> GetBvLocations()
        {
            var db = new CapstoneDbContext();

            return((from l in db.BvLocations
                    select l).AsQueryable <BvLocation>());
        }
예제 #13
0
        //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();
        }
예제 #14
0
 public BvLocation GetBvLocation(string storeNum)
 {
     var db = new CapstoneDbContext();
     return (from l in db.BvLocations
             where l.BvStoreNum == storeNum
             select l).FirstOrDefault();
 }
예제 #15
0
        public IQueryable <Entities.Form> GetForms()
        {
            var db = new CapstoneDbContext();

            return((from sec3 in db.Forms
                    select sec3).AsQueryable <Form>());
        }
예제 #16
0
 public Entities.BvLocation GetBvLocation(int bvLocationId)
 {
     var db = new CapstoneDbContext();
     return (from l in db.BvLocations
             where l.BvLocationId == bvLocationId
             select l).FirstOrDefault();
 }
예제 #17
0
        public void AddBvLocation(BvLocation bvLocation)
        {
            var db = new CapstoneDbContext();

            db.BvLocations.Add(bvLocation);
            db.SaveChanges();;
        }
        /*
         * 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();
        }
        public IQueryable <PartnershipNight> GetPartnershipNights()  //Doing it this way as per suggestion. Seems highly inefficient to me to grab all partnership nights en masse, would prefer to narrow them via some criteria. Options commented out below for the future, should we decide to implement them.
        {
            var db = new CapstoneDbContext();

            return((from pnight in db.PartnershipNights.Include("Charity").Include("BVLocation")
                    select pnight).AsQueryable <PartnershipNight>());
        }
예제 #20
0
        public BvLocation GetBvLocation(string storeNum)
        {
            var db = new CapstoneDbContext();

            return((from l in db.BvLocations
                    where l.BvStoreNum == storeNum
                    select l).FirstOrDefault());
        }
예제 #21
0
        public Entities.BvLocation GetBvLocation(int bvLocationId)
        {
            var db = new CapstoneDbContext();

            return((from l in db.BvLocations
                    where l.BvLocationId == bvLocationId
                    select l).FirstOrDefault());
        }
예제 #22
0
        public Form GetFormById(int id)
        {
            var db = new CapstoneDbContext();

            return((from sec3 in db.Forms
                    where sec3.FormId == id
                    select sec3).FirstOrDefault());
        }
        public PartnershipNight GetPartnershipNightByDate(DateTime date, BvLocation loc)
        {
            var db = new CapstoneDbContext();

            return((from pnight in db.PartnershipNights.Include("Charity").Include("BVLocation")
                    where pnight.Date == date && pnight.BVLocation == loc
                    select pnight).FirstOrDefault());
        }
        public PartnershipNight GetPartnershipNightById(int eventId)
        {
            var db = new CapstoneDbContext();

            return((from pnight in db.PartnershipNights.Include("Charity").Include("BVLocation")
                    where pnight.PartnershipNightId == eventId
                    select pnight).FirstOrDefault());
        }
예제 #25
0
 public ActionResult AdminLocIndex()
 {
     //need to get a list of all users
     var db = new CapstoneDbContext();
     List<BvLocation> locations = (from l in db.BvLocations
                         select l).ToList<BvLocation>();
     return View(locations);
 }
예제 #26
0
 public List<PartnershipNight> GetPartnershipNights(BvLocation l)
 {
     var db = new CapstoneDbContext();
     List<PartnershipNight> partnershipnights = (from c in db.PartnershipNights.Include("BvLocation").Include("Charity")
                                  where c.BVLocation.BvLocationId == l.BvLocationId
                                  select c).ToList<PartnershipNight>();
     return partnershipnights;
 }
예제 #27
0
        public Form GetFormById(int id)
        {
            var db = new CapstoneDbContext();

            return (from sec3 in db.Forms
                    where sec3.FormId == id
                    select sec3).FirstOrDefault();
        }
예제 #28
0
 public Charity GetCharityByName(string name)
 {
     //throw new NotImplementedException();
     var db = new CapstoneDbContext();
     return (from charity in db.Charities
             where charity.Name == name
             select charity).FirstOrDefault();
 }
 public void DeletePartnershipNight(PartnershipNight pn)
 {
     //throw new NotImplementedException();
     var db = new CapstoneDbContext();
     db.PartnershipNights.Remove(pn);
     db.SaveChanges();
     //TODO: Add in error handling
 }
예제 #30
0
        public Entities.User GetUser(int userId)
        {
            var db = new CapstoneDbContext();

            return((from u in db.Users.Include("BvLocation")
                    where u.UserId == userId
                    select u).FirstOrDefault());
        }
예제 #31
0
        //need to pass a user to this method once the login stuff is worked out
        public ViewResult Calendar()
        {
            User u = uRepo.GetUser(11);
            BvLocation bvLocation = lRepo.GetBvLocation(u.BvLocation.BvLocationId);
            var db = new CapstoneDbContext();
            bvLocation.PartnershipNights = lRepo.GetPartnershipNights(bvLocation);

            return View(bvLocation);
        }
        public void AddPartnershipNight(PartnershipNight pn)
        {
            //throw new NotImplementedException();
            var db = new CapstoneDbContext();

            db.PartnershipNights.Add(pn);
            db.SaveChanges();
            //TODO: Add in error handling
        }
예제 #33
0
        public Charity GetCharityByName(string name)
        {
            //throw new NotImplementedException();
            var db = new CapstoneDbContext();

            return((from charity in db.Charities
                    where charity.Name == name
                    select charity).FirstOrDefault());
        }
예제 #34
0
        public List <PartnershipNight> GetPartnershipNights(BvLocation l)
        {
            var db = new CapstoneDbContext();
            List <PartnershipNight> partnershipnights = (from c in db.PartnershipNights.Include("BvLocation").Include("Charity")
                                                         where c.BVLocation.BvLocationId == l.BvLocationId
                                                         select c).ToList <PartnershipNight>();

            return(partnershipnights);
        }
예제 #35
0
        public ActionResult AdminUserIndex()
        {
            //need to get a list of all users
            var db = new CapstoneDbContext();
            List<User> users = (from u in db.Users.Include("BvLocation")
                                select u).ToList<User>();

            //TODO:  add functionality to get users by restaurant or city?
            return View(users);
        }
예제 #36
0
 //If we decide not to allow deletion we can take this out later
 public Charity DeleteCharity(int charityId)
 {
     var db = new CapstoneDbContext();
     Charity dbEntry = db.Charities.Find(charityId);
     if (dbEntry != null)
     {
         db.Charities.Remove(dbEntry);
         db.SaveChanges();
     }
     return dbEntry;
 }
예제 #37
0
 public BvLocation DeleteBvLocation(int bvLocationId)
 {
     var db = new CapstoneDbContext();
     BvLocation dbEntry = db.BvLocations.Find(bvLocationId);
     if (dbEntry != null)
     {
         db.BvLocations.Remove(dbEntry);
         db.SaveChanges();
     }
     return dbEntry;
 }
예제 #38
0
 public User DeleteUser(int userId)
 {
     var db = new CapstoneDbContext();
     User dbEntry = db.Users.Find(userId);
     if (dbEntry != null)
     {
         db.Users.Remove(dbEntry);
         db.SaveChanges();
     }
     return dbEntry;
 }
예제 #39
0
 public Form DeleteForm(int id)
 {
     var db = new CapstoneDbContext();
     var dbEntry = db.Forms.Find(id);
     if (dbEntry != null)
     {
         db.Forms.Remove(dbEntry);
         db.SaveChanges();
     }
     return dbEntry;
 }
예제 #40
0
        public Charity DeleteCharity(int charityId)  //If we decide not to allow deletion we can take this out later
        {
            var     db      = new CapstoneDbContext();
            Charity dbEntry = db.Charities.Find(charityId);

            if (dbEntry != null)
            {
                db.Charities.Remove(dbEntry);
                db.SaveChanges();
            }
            return(dbEntry);
        }
예제 #41
0
        public Form DeleteForm(int id)
        {
            var db      = new CapstoneDbContext();
            var dbEntry = db.Forms.Find(id);

            if (dbEntry != null)
            {
                db.Forms.Remove(dbEntry);
                db.SaveChanges();
            }
            return(dbEntry);
        }
예제 #42
0
        public BvLocation DeleteBvLocation(int bvLocationId)
        {
            var        db      = new CapstoneDbContext();
            BvLocation dbEntry = db.BvLocations.Find(bvLocationId);

            if (dbEntry != null)
            {
                db.BvLocations.Remove(dbEntry);
                db.SaveChanges();
            }
            return(dbEntry);
        }
예제 #43
0
        public User DeleteUser(int userId)
        {
            var  db      = new CapstoneDbContext();
            User dbEntry = db.Users.Find(userId);

            if (dbEntry != null)
            {
                db.Users.Remove(dbEntry);
                db.SaveChanges();
            }
            return(dbEntry);
        }
 //should this take a partnership night or id as parameter?
 public PartnershipNight DeletePartnershipNight(int id)
 {
     //throw new NotImplementedException();
     var db = new CapstoneDbContext();
     PartnershipNight dbEntry = db.PartnershipNights.Find(id);
     if (dbEntry != null)
     {
         db.PartnershipNights.Remove(dbEntry);
         db.SaveChanges();
     }
     return dbEntry;
     //TODO: Add in error handling
 }
        public PartnershipNight DeletePartnershipNight(int id) //should this take a partnership night or id as parameter?
        {
            //throw new NotImplementedException();
            var db = new CapstoneDbContext();
            PartnershipNight dbEntry = db.PartnershipNights.Find(id);

            if (dbEntry != null)
            {
                db.PartnershipNights.Remove(dbEntry);
                db.SaveChanges();
            }
            return(dbEntry);
            //TODO: Add in error handling
        }
예제 #46
0
        public void SaveBvLocation(BvLocation l)
        {
            var db = new CapstoneDbContext();
            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();
        }
예제 #47
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();
        }
예제 #48
0
        public void SaveBvLocation(BvLocation l)
        {
            var db = new CapstoneDbContext();

            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();
        }
예제 #49
0
        public void SaveUser(User u)
        {
            var db = new CapstoneDbContext();

            if (u.UserId == 0)
            {
                db.BvLocations.Find(u.BvLocation.BvLocationId);
                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  = db.BvLocations.Find(u.BvLocation.BvLocationId);
                }
            }
            db.SaveChanges();
        }
예제 #50
0
 public void AddUser(Entities.User u)
 {
     var db = new CapstoneDbContext();
     db.Users.Add(u);
     db.SaveChanges();
 }
예제 #51
0
 public void AddBvLocation(BvLocation bvLocation)
 {
     var db = new CapstoneDbContext();
     db.BvLocations.Add(bvLocation);
     db.SaveChanges(); ;
 }
 public void AddCharity(Entities.Charity c)
 {
     var db = new CapstoneDbContext();
     db.Charities.Add(c);
     db.SaveChanges();
 }
        /*
        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();
        }
예제 #54
0
        public void AddForm(Form sec3)
        {
            var db = new CapstoneDbContext();

            db.Forms.Add(sec3);
        }
예제 #55
0
 /*public Charity GetCharityById(int id)
 {
     //throw new NotImplementedException();
     var db = new CapstoneDbContext();
     return (from charity in db.Charities
             where charity.CharityId == id
             select charity).FirstOrDefault();
 }*/
 public IQueryable<Charity> GetCharities()
 {
     var db = new CapstoneDbContext();
     return (from charity in db.Charities
             select charity).AsQueryable<Charity>();
 }
예제 #56
0
 public IQueryable<BvLocation> GetBvLocations()
 {
     var db = new CapstoneDbContext();
     return (from l in db.BvLocations
             select l).AsQueryable<BvLocation>();
 }
 public void AddStatsInfo(Entities.StatsInfo s)
 {
     var db = new CapstoneDbContext();
     db.StatsInfos.Add(s);
     db.SaveChanges();
 }