public static void DeleteBarLogic(int?id) { using (BarTrackerDBEntities db = new BarTrackerDBEntities()) { var delbar = db.Bar.SingleOrDefault(x => x.BarId == id); db.Bar.Remove(delbar); db.SaveChanges(); } }
public static void RegistrationLogic(string LoginReg, string PasswordReg, string EmailReg) { using (BarTrackerDBEntities db = new BarTrackerDBEntities()) { db.User.Add(new User { Username = LoginReg, Password = PasswordReg, Email = EmailReg }); db.SaveChanges(); } }
public static void AddBarLogic(Bar bar) { if (bar.BarName != "" && bar.Category != "" && bar.City != "") { using (BarTrackerDBEntities db = new BarTrackerDBEntities()) { db.Bar.Add(bar); db.SaveChanges(); } } }
public static Bar EditBarLogic(Bar bar) { Bar Fullbar = new Bar(); using (BarTrackerDBEntities db = new BarTrackerDBEntities()) { Bar oldBar = db.Bar.SingleOrDefault(x => x.BarId == bar.BarId); oldBar.BarName = bar.BarName; oldBar.Category = bar.Category; oldBar.City = bar.City; db.SaveChanges(); Fullbar = db.Bar.Include(x => x.Rating).FirstOrDefault(x => x.BarId == bar.BarId); } return(Fullbar); }