public int AddBooking([FromBody] CreatBooking creatBooking) { #region mapping Customer customer = new Customer() { email = creatBooking.personEmail, name = creatBooking.personName, password = creatBooking.personPassword, persontype = creatBooking.personType, phone = creatBooking.number }; BookingTime bookingTime = new BookingTime() { date = creatBooking.date_, startTime = creatBooking.startTime, endTime = creatBooking.endTime }; Booking booking = new Booking() { totalPrice = Convert.ToDouble(creatBooking.totalprice), hairdresserId = creatBooking.hairdressId, salonId = creatBooking.salonBookingId, customerId = btcr.createCustomer(customer).customerId, bookingTimeId = btcr.CreateBookingTime(bookingTime).bookingTimeId, services = creatBooking.services }; #endregion return(btcr.AddBooking(booking)); //return btcr.AddBooking(booking); }
public IActionResult BookARoom(int roomId, DateTime startTime, DateTime endTime, string description) { // Отбираем времена для контроля непересечения бронируемого времени с уже существующими List <BookingTime> currentTimes = db.BookingTimes.Where(u => u.RoomId == roomId).ToList(); foreach (BookingTime time in currentTimes) { // Если бронируемое время как-либо пересекается с существующим/ими if (time.StartTime == startTime && time.EndTime == endTime || time.StartTime < startTime && time.EndTime == endTime || time.StartTime == startTime && time.EndTime > endTime || time.StartTime < startTime && time.EndTime > endTime || time.StartTime > startTime && time.EndTime < endTime) { ViewBag.TimeBusy = "Время занято, повторите ввод"; return(View()); } } // Иначе новый неподтвержденный экземпляр времени в БД с возвратом в Index BookingTime newBookingTime = new BookingTime() { StartTime = startTime, EndTime = endTime, Description = description, IsConfirmed = false, RoomId = roomId }; db.BookingTimes.Add(newBookingTime); db.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public void ConfirmTime(int id) { BookingTime time = db.BookingTimes.Where(t => t.Id == id).Single(); time.IsConfirmed = true; db.SaveChanges(); }
public void NotConfirmTime(int id) { BookingTime time = db.BookingTimes.Where(t => t.Id == id).Single(); db.BookingTimes.Remove(time); db.SaveChanges(); }
public BookingTime CreateBookingTime(BookingTime bt) { var id = 0; try { SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationDbContext"].ConnectionString); var cmd = sqlConnection.CreateCommand(); sqlConnection.Open(); cmd.CommandType = CommandType.Text; cmd.CommandText = @"insert into BookingTime(date_, startTime, endTime) output inserted.bookingTimeId values (@date_, @startTime, @endTime);"; cmd.Parameters.AddWithValue("@date_", bt.date); cmd.Parameters.AddWithValue("@startTime", bt.startTime); cmd.Parameters.AddWithValue("@endTime", bt.endTime); //cmd.Parameters.AddWithValue("@bookingTimeBookingId", bt.bookingTimeBookingId); id = (int)cmd.ExecuteScalar(); bt.bookingTimeId = id; sqlConnection.Close(); return(bt); } catch (Exception e) { throw e; } }
public ActionResult DeleteConfirmed(int id) { BookingTime bookingTime = db.BookingTimes.Find(id); db.BookingTimes.Remove(bookingTime); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "TimeId,Time")] BookingTime bookingTime) { if (ModelState.IsValid) { db.Entry(bookingTime).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bookingTime)); }
public ActionResult Create([Bind(Include = "TimeId,Time")] BookingTime bookingTime) { if (ModelState.IsValid) { db.BookingTimes.Add(bookingTime); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bookingTime)); }
public ActionResult Edit([Bind(Include = "BookingTimeID,BookingID,Date,TimeStart,Duration")] BookingTime bookingTime) { if (ModelState.IsValid) { db.Entry(bookingTime).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BookingID = new SelectList(db.Bookings, "BookingID", "Notes", bookingTime.BookingID); return(View(bookingTime)); }
// GET: BookingTimes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BookingTime bookingTime = db.BookingTimes.Find(id); if (bookingTime == null) { return(HttpNotFound()); } return(View(bookingTime)); }
protected void Page_Load(object sender, EventArgs e) { //vars to store the date and time string BookingDate; string BookingTime; //get the date and time from the quety string BookingDate = Request.QueryString["BookingDate"]; BookingTime = Request.QueryString["BookingTime"]; //display the date txtDate.Text = BookingDate; //display the taime but removeing the - character txtTime.Text = BookingTime.Remove(0, 1); }
// GET: BookingTimes/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BookingTime bookingTime = db.BookingTimes.Find(id); if (bookingTime == null) { return(HttpNotFound()); } ViewBag.BookingID = new SelectList(db.Bookings, "BookingID", "Notes", bookingTime.BookingID); return(View(bookingTime)); }
public static BookingTime CreateBookingTime(SqlDataReader dbReader) { // Use try to check if all fields is valid try { var bookingTime = new BookingTime { bookingTimeId = dbReader.GetInt32(dbReader.GetOrdinal("bookingTimeId")), date = dbReader.GetString(dbReader.GetOrdinal("date_")), startTime = dbReader.GetString(dbReader.GetOrdinal("startTime")), endTime = dbReader.GetString(dbReader.GetOrdinal("endTime")) }; return(bookingTime); } catch (Exception) { // The build failed, return a null return(null); } }
public BookingTime FindBookingTime(int id) { SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationDbContext"].ConnectionString); SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = @"select * from BookingTime where bookingTimeId = @bookingTimeId"; cmd.Parameters.AddWithValue("@bookingTimeId", id); cmd.Connection = sqlConnection; cmd.Connection.Open(); var dbReader = cmd.ExecuteReader(); BookingTime b = null; while (dbReader.Read()) { b = ObjectBuilder.CreateBookingTime(dbReader); } return(b); }
public IActionResult Index(bool confirm, int roomId) { BookingTime time = db.BookingTimes.Where(t => t.Room.Id == roomId).Single(); // Если подтверждаем заявку - переставляем флаг IsConfirmed на true if (confirm) { if (time != null) { time.IsConfirmed = true; db.SaveChanges(); } return(View()); } // Если отклоняем заявку - удаляем запись события из БД else { db.BookingTimes.Remove(time); db.SaveChanges(); return(View()); } }
public void SaveOrUpdateBooking(Teacher teacher, Student student, Subject subject, BookingTime bookingTime, string description) { using (var dbContext = new DataAccess.TeachersAssistantDbContext()) { _unitOfWork.InitializeDbContext(dbContext); var calendar = _unitOfWork._calendarBookingRepository.GetAll().SingleOrDefault(p => p.BookingTimeId == bookingTime.BookingTimeId); if (calendar == null) { var bookingTimes = new BookingTime { StartTime = bookingTime.StartTime, EndTime = bookingTime.EndTime }; _unitOfWork._bookingTimeRepository.Add(bookingTimes); _unitOfWork.SaveChanges(); calendar = new CalendarBooking { StudentId = (int)student.StudentId, SubjectId = (int)subject.SubjectId, TeacherId = (int)teacher.TeacherId, BookingTimeId = (int)bookingTimes.BookingTimeId, Description = description }; _unitOfWork._calendarBookingRepository.Add(calendar); _unitOfWork.SaveChanges(); } else { var bkTime = _unitOfWork._bookingTimeRepository.GetById((int)bookingTime.BookingTimeId); bkTime.StartTime = bookingTime.StartTime; bkTime.EndTime = bookingTime.EndTime; calendar.BookingTime = bkTime; calendar.Description = description; _unitOfWork.SaveChanges(); } } }
public BookingTime CreateBookingTime(BookingTime bt) { return(Dbbooking.CreateBookingTime(bt)); }
public override string ToString() { return($"Bane {CourtNumber} booket d. {BookingTime.ToShortDateString()} kl. {BookingTime.Hour} af {Booker}"); }
public BookingTime saveBookingTime([FromBody] BookingTime bookingtime) { BookingTime result = btcr.CreateBookingTime(bookingtime); return(result); }
// Статический метод, вызывается единожды в Program.Main() public static void UsersInitialize(ApplicationContext appContext) { /* Пока данных Пользователей нет, добавить данные в БД */ if (!appContext.Users.Any() && !appContext.Users.Any()) { // Три пользователя User admin = new User { Email = "admin", Password = "******", Role = 0 }; User manager = new User { Email = "*****@*****.**", Password = "******", Role = 0 }; User employee = new User { Email = "*****@*****.**", Password = "******", Role = 1 }; appContext.AddRange(new List <User> { admin, manager, employee }); appContext.SaveChanges(); } /* Аналогично для комнат */ if (!appContext.Rooms.Any() && !appContext.BookingTimes.Any()) { // И комнаты с событиями, подтвержденными и нет Room room2001 = new Room() { Name = "200.1", SeatsNumber = 20, HasProjector = true, HasTable = true, Description = "Комната обучения" }; Room room2002 = new Room() { Name = "200.2", SeatsNumber = 25, HasProjector = true, HasTable = false, Description = "Презентационная комната" }; Room room2003 = new Room() { Name = "200.3", SeatsNumber = 15, HasProjector = false, HasTable = true, Description = "Комната для собеседований" }; Room room2004 = new Room() { Name = "200.4", SeatsNumber = 20, HasProjector = true, HasTable = true, Description = "Универсальная комната" }; Room room2005 = new Room() { Name = "200.5", SeatsNumber = 30, HasProjector = true, HasTable = true, Description = "Презентационная комната" }; Room room3001 = new Room() { Name = "300.1", SeatsNumber = 10, HasProjector = false, HasTable = true, Description = "Кабинет заседания начальства" }; Room room3002 = new Room() { Name = "300.2", SeatsNumber = 30, HasProjector = true, HasTable = false, Description = "Переговорная" }; Room room3003 = new Room() { Name = "300.3", SeatsNumber = 50, HasProjector = true, HasTable = true, Description = "Переговорная" }; appContext.Rooms.AddRange(new List <Room> { room2001, room2002, room2003, room2004, room2005, room3001, room3002, room3003 }); appContext.SaveChanges(); BookingTime bookingTime20011 = new BookingTime() { Description = "Инструктаж", StartTime = new DateTime(2019, 3, 21, 8, 30, 0), EndTime = new DateTime(2019, 3, 21, 9, 30, 0), IsConfirmed = true, RoomId = room2001.Id }; BookingTime bookingTime20012 = new BookingTime() { Description = "Основы профессии", StartTime = new DateTime(2019, 3, 21, 9, 30, 0), EndTime = new DateTime(2019, 3, 21, 10, 30, 0), IsConfirmed = true, RoomId = room2001.Id }; BookingTime bookingTime20013 = new BookingTime() { Description = "Вопросы-ответы", StartTime = new DateTime(2019, 3, 21, 10, 30, 0), EndTime = new DateTime(2019, 3, 21, 12, 00, 0), IsConfirmed = false, RoomId = room2001.Id }; BookingTime bookingTime30011 = new BookingTime() { Description = "Заседание директоров", StartTime = new DateTime(2019, 3, 22, 9, 00, 0), EndTime = new DateTime(2019, 3, 22, 12, 00, 0), IsConfirmed = true, RoomId = room3001.Id }; BookingTime bookingTime30012 = new BookingTime() { Description = "Обсуждение отчетов", StartTime = new DateTime(2019, 3, 21, 13, 30, 0), EndTime = new DateTime(2019, 3, 21, 15, 00, 0), IsConfirmed = false, RoomId = room3001.Id }; appContext.BookingTimes.AddRange(new List <BookingTime>() { bookingTime20011, bookingTime20012, bookingTime20013, bookingTime30011, bookingTime30012 }); appContext.SaveChanges(); } }