public string UnbookTime(string date, string time, string user, int inmateSSN) { KrimmDBEntities2 db = new KrimmDBEntities2(); int booking = db.Bookings.Where(s => s.Date == date).Where(s => s.Time == time).Select(s => s.BookingId).FirstOrDefault(); Bookings book = db.Bookings.Single(s => s.BookingId == booking); book.Iduser = null; book.PersonOfInterest = null; return("Din tid är avbokad"); }
public bool SaveAvailableTimeToDB(string date, string time) { KrimmDBEntities2 db = new KrimmDBEntities2(); if (date == null || time == null) { return(false); } else { Bookings createBooking = new Bookings(); createBooking.Date = date; createBooking.Time = time; db.Bookings.Add(createBooking); db.SaveChanges(); } return(true); }
public string BookTime(string date, string time, string user, int inmateSSN) { KrimmDBEntities2 db = new KrimmDBEntities2(); int booking = db.Bookings.Where(s => s.Date == date).Where(s => s.Time == time).Select(s => s.BookingId).FirstOrDefault(); var tempUser = db.Bookings.Where(s => s.BookingId == booking).Select(s => s.Iduser).FirstOrDefault(); if (tempUser == null) { int userId = db.Users.Where(s => s.Username == user).Select(s => s.UserId).FirstOrDefault(); Bookings book = db.Bookings.Single(s => s.BookingId == booking); book.Iduser = userId; book.PersonOfInterest = inmateSSN; db.SaveChanges(); return("Din bokning har genomförts den " + date + " klockan " + time); } else { return("Tiden var redan upptagen"); } }