Example #1
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();
        }
Example #2
0
        public void AddBvLocation(BvLocation bvLocation)
        {
            var db = new CapstoneDbContext();

            db.BvLocations.Add(bvLocation);
            db.SaveChanges();;
        }
Example #3
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();
               }
        }
Example #4
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();
            }
        }
Example #5
0
        public void AddUser(Entities.User u)
        {
            var db = new CapstoneDbContext();

            db.Users.Add(u);
            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();
        }
Example #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();
 }
Example #8
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;
              }
        }
Example #9
0
        public void AddCharity(Charity charity)
        {
            var db = new CapstoneDbContext();

            db.Charities.Add(charity);
            db.SaveChanges();
        }
 public void DeletePartnershipNight(PartnershipNight pn)
 {
     //throw new NotImplementedException();
     var db = new CapstoneDbContext();
     db.PartnershipNights.Remove(pn);
     db.SaveChanges();
     //TODO: Add in error handling
 }
        public void AddPartnershipNight(PartnershipNight pn)
        {
            //throw new NotImplementedException();
            var db = new CapstoneDbContext();

            db.PartnershipNights.Add(pn);
            db.SaveChanges();
            //TODO: Add in error handling
        }
Example #12
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;
 }
Example #13
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;
 }
Example #14
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;
 }
 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;
 }
Example #16
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);
        }
Example #17
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);
        }
Example #18
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);
        }
Example #19
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);
        }
 //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
        }
        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();
        }
Example #23
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();
        }
Example #24
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();
        }
Example #25
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();
        }
 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();
        }
Example #28
0
 public void AddUser(Entities.User u)
 {
     var db = new CapstoneDbContext();
     db.Users.Add(u);
     db.SaveChanges();
 }
 public void AddBvLocation(BvLocation bvLocation)
 {
     var db = new CapstoneDbContext();
     db.BvLocations.Add(bvLocation);
     db.SaveChanges(); ;
 }
 public void AddStatsInfo(Entities.StatsInfo s)
 {
     var db = new CapstoneDbContext();
     db.StatsInfos.Add(s);
     db.SaveChanges();
 }