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(); } }
public IQueryable<Entities.Form> GetForms() { var db = new CapstoneDbContext(); return (from sec3 in db.Forms select sec3).AsQueryable<Form>(); }
public void AddCharity(Charity charity) { var db = new CapstoneDbContext(); db.Charities.Add(charity); db.SaveChanges(); }
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(); }
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(); }
//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(); }
public void AddUser(Entities.User u) { var db = new CapstoneDbContext(); db.Users.Add(u); db.SaveChanges(); }
/*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>()); }
public IQueryable <BvLocation> GetBvLocations() { var db = new CapstoneDbContext(); return((from l in db.BvLocations select l).AsQueryable <BvLocation>()); }
public BvLocation GetBvLocation(string storeNum) { var db = new CapstoneDbContext(); return (from l in db.BvLocations where l.BvStoreNum == storeNum select l).FirstOrDefault(); }
public IQueryable <Entities.Form> GetForms() { var db = new CapstoneDbContext(); return((from sec3 in db.Forms select sec3).AsQueryable <Form>()); }
public Entities.BvLocation GetBvLocation(int bvLocationId) { var db = new CapstoneDbContext(); return (from l in db.BvLocations where l.BvLocationId == bvLocationId select l).FirstOrDefault(); }
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>()); }
public BvLocation GetBvLocation(string storeNum) { var db = new CapstoneDbContext(); return((from l in db.BvLocations where l.BvStoreNum == storeNum select l).FirstOrDefault()); }
public Entities.BvLocation GetBvLocation(int bvLocationId) { var db = new CapstoneDbContext(); return((from l in db.BvLocations where l.BvLocationId == bvLocationId select l).FirstOrDefault()); }
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()); }
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); }
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; }
public Form GetFormById(int id) { var db = new CapstoneDbContext(); return (from sec3 in db.Forms where sec3.FormId == id select sec3).FirstOrDefault(); }
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 }
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()); }
//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 }
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 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); }
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); }
//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; }
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; }
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; }
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); }
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); }
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); }
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 }
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(); }
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 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(); }
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 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(); }
public void AddForm(Form sec3) { var db = new CapstoneDbContext(); db.Forms.Add(sec3); }
/*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>(); }
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(); }