//adds a massage slot to the database
 public static void addMassageSlot(Massage_Slots msSlot)
 {
     using (Massage_BookingEntities context = new Massage_BookingEntities())
     {
         context.Massage_Slots.Add(msSlot);
         context.SaveChanges();
     }
 }
 //adds a massage day to the database
 public static void addMassageDay(Massage_Days msDay)
 {
     using (Massage_BookingEntities context = new Massage_BookingEntities())
     {
         context.Massage_Days.Add(msDay);
         context.SaveChanges();
     }
 }
 //adds a booking to the database
 public static void addBooking(Booking booking)
 {
     using (Massage_BookingEntities context = new Massage_BookingEntities())
     {
         context.Bookings.Add(booking);
         context.SaveChanges();
     }
 }
 public static void changeMasseuseName(int dayId, string name)
 {
     using (Massage_BookingEntities context = new Massage_BookingEntities())
     {
         context.Massage_Days.Find(dayId).masseuse = name;
         context.SaveChanges();
     }
 }
 //allows the admin to change the payment status of the employee
 public static void changePaymentStatus(int bookingID)
 {
     using (Massage_BookingEntities context = new Massage_BookingEntities())
     {
         context.Bookings.Find(bookingID).has_paid = true;
         context.SaveChanges();
     }
 }
 public static void changeAttendancyStatusToFalse(int bookingID)
 {
     using (Massage_BookingEntities context = new Massage_BookingEntities())
     {
         context.Bookings.Find(bookingID).has_attended = false;
         context.SaveChanges();
     }
 }
Exemplo n.º 7
0
 public static void deleteBooking(int bookingId)
 {
     using (Massage_BookingEntities context = new Massage_BookingEntities())
     {
         context.Bookings.Remove(context.Bookings.First(booking => booking.id == bookingId));
         context.SaveChanges();
     }
 }
 // removes a booking from the database
 public static void removeBookingSlot(int bookingID)
 {
     using (Massage_BookingEntities context = new Massage_BookingEntities())
     {
         Booking book = context.Bookings.Find(bookingID);
         context.Bookings.Remove(book);
         context.SaveChanges();
     }
 }
 //removes a massage slot from the database
 public static void removeMassageSlot(int slotID)
 {
     using (Massage_BookingEntities context = new Massage_BookingEntities())
     {
         Massage_Slots slot = context.Massage_Slots.Find(slotID);
         context.Massage_Slots.Remove(slot);
         context.SaveChanges();
     }
 }
 //removes a massage day from the database
 public static void removeMassageDay(int dayID)
 {
     using (Massage_BookingEntities context = new Massage_BookingEntities())
     {
         Massage_Days mday = context.Massage_Days.Find(dayID);
         context.Massage_Days.Remove(mday);
         context.SaveChanges();
     }
 }
Exemplo n.º 11
0
        //public static string getMasseuseName(DateTime massageDay)
        //{
        //    using (Massage_BookingEntities context = new Massage_BookingEntities())
        //    {
        //        var masseuseName = from m in context.Massage_Days
        //                           where m.date == massageDay
        //                           select m.masseuse;

        //        return masseuseName.FirstOrDefault();
        //    }
        //}

        public static void refreshWeekInDB(IEnumerable <DateTime> weekDays)
        {
            try
            {
                using (Massage_BookingEntities context = new Massage_BookingEntities())
                {
                    string[] hours         = { "10:00", "10:20", "10:40", "11:00", "11:20", "11:40", "12:00", "12:20", "12:40", "13:00", "13:20", "13:40", "14:00", "14:20", "14:40", "15:00", "15:20", "15:40", "16:00", "16:20", "16:40" };
                    string[] masseuseNames = { "Ani", "Ani", "Stefi", "Stefi", "Ani" };

                    for (var day = 0; day < weekDays.Count(); day++)
                    {
                        Massage_Days newDay = new Massage_Days()
                        {
                            date     = weekDays.ElementAt(day),
                            masseuse = masseuseNames[day]
                        };
                        context.Massage_Days.Add(newDay);
                        context.SaveChanges();

                        foreach (var hour in hours)
                        {
                            Massage_Slots massageSlot = new Massage_Slots()
                            {
                                massage_day_id = newDay.id,
                                start_hour     = DateTime.Parse(hour)
                            };
                            context.Massage_Slots.Add(massageSlot);
                        }
                    }
                    context.SaveChanges();
                }
            }
            catch (DbUpdateException ex)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw;
            }
        }