/// <summary> /// Deletes a suite. /// </summary> /// <param name="id">The identifier.</param> public static void DeleteSuite(int id) { //LINQ to SQL var db = new HotelDataDataContext(); //find the booked suite var delete = from d in db.Bookings where d.Id == id select d; db.Bookings.DeleteAllOnSubmit(delete); db.SubmitChanges(); }
/// <summary> /// Books the suite. /// </summary> /// <param name="tempSuite">The temporary suite.</param> /// <param name="checkInDate">The check in date.</param> /// <param name="daysToStay">The days to stay.</param> /// <param name="fullName">The full name.</param> /// <param name="gender">The gender.</param> /// <param name="telephone">The telephone.</param> /// <param name="email">The email.</param> /// <param name="adress">The adress.</param> /// <param name="city">The city.</param> /// <param name="state">The state.</param> /// <param name="zipcode">The zipcode.</param> /// <param name="breakfast">if set to <c>true</c> [breakfast].</param> /// <returns><c>True</c> if sucess.</returns> public static bool BookSuite(Suite tempSuite, string checkInDate, string daysToStay, string fullName, string gender, string telephone, string email, string adress, string city, string state, string zipcode, bool breakfast) { var db = new HotelDataDataContext(); DateTime checkIn; DateTime.TryParse(checkInDate, out checkIn); DateTime checkOut = checkIn.AddDays(Convert.ToInt32(daysToStay)); try { var booking = new Booking { SuiteNumber = tempSuite.SuiteNumber, StartDate = checkIn, EndDate = checkOut, Name = fullName, Telephone = telephone, Email = email, Adress = adress, City = city, State = state, ZipCode = zipcode, Breakfast = breakfast }; db.Bookings.InsertOnSubmit(booking); db.SubmitChanges(); return true; } catch (Exception ex) { return false; } }
/// <summary> /// Creates a new user /// </summary> /// <param name="username">Username</param> /// <param name="password">Password</param> /// <returns><c>True</c> if successful</returns> public static bool CreateUser(string username, string password) { //hash password string passwordHash = BCryptHelper.HashPassword(password, BCryptHelper.GenerateSalt()); //role to set to user string role = "Employee"; //LINQ to SQL HotelDataDataContext db = new HotelDataDataContext(); try { User newUser = new User {Hash = passwordHash, Username = username, Role = role}; db.Users.InsertOnSubmit(newUser); db.SubmitChanges(); } catch (Exception) { return false; } return true; }