Example #1
0
        public static void CreateEmployee(Employees employee)
        {
            var context = new TableReadyContext();

            context.Employees.Add(employee);
            context.SaveChanges();
        }
        public static void AddEmployeeToAutheticationMatrix(AuthenticationMatrix authMatrix)
        {
            var context = new TableReadyContext();

            context.AuthenticationMatrix.Add(authMatrix);
            context.SaveChanges();
        }
Example #3
0
        public static void CreateCustomer(Customers customer)
        {
            var context = new TableReadyContext();

            context.Customers.Add(customer);
            context.SaveChanges();
        }
Example #4
0
        public static void CreateWaitlist(WaitlistEntry waitlist)
        {
            var context = new TableReadyContext();

            context.WaitlistEntry.Add(waitlist);
            context.SaveChanges();
        }
Example #5
0
        public static void CreateOwner(Owners owner)
        {
            var context = new TableReadyContext();

            context.Owners.Add(owner);
            context.SaveChanges();
        }
Example #6
0
        public static void AddEmployeeToRestaurant(RestaurantEmployees restaurantEmployee)
        {
            var context = new TableReadyContext();

            context.RestaurantEmployees.Add(restaurantEmployee);
            context.SaveChanges();
        }
Example #7
0
        public static void AddOwnerToRestaurant(RestaurantOwners restaurantOwner)
        {
            var context = new TableReadyContext();

            context.RestaurantOwners.Add(restaurantOwner);
            context.SaveChanges();
        }
        public static void CreateUser(Users user)
        {
            var context = new TableReadyContext();

            context.Users.Add(user);
            context.SaveChanges();
        }
Example #9
0
        public static void CreateReservation(ReservationEntry reservation)
        {
            var context = new TableReadyContext();

            context.ReservationEntry.Add(reservation);
            context.SaveChanges();
        }
        public static int CreateAuthentication(Authentication auth)

        {
            var context   = new TableReadyContext();
            var authGroup = context.Authentication;
            var existAuth = authGroup.SingleOrDefault(p => p.Username == auth.Username);

            if (existAuth == null)
            {
                var maxAuthBefore = authGroup.SingleOrDefault(p => p.Id == authGroup.Max(k => k.Id));
                context.Authentication.Add(auth);
                context.SaveChanges();
                var maxAuthAfter = authGroup.SingleOrDefault(p => p.Id == authGroup.Max(k => k.Id));

                if (maxAuthAfter.Id == maxAuthBefore.Id + 1)
                {
                    return(maxAuthAfter.Id);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return(0);
            }
        }
Example #11
0
        public static void EditRestaurant(Restaurants restaurant)
        {
            var context            = new TableReadyContext();
            var originalRestaurant = context.Restaurants.SingleOrDefault(p => p.RestaurantId == restaurant.RestaurantId);

            originalRestaurant.RestaurantName = restaurant.RestaurantName;
            context.SaveChanges();
        }
Example #12
0
        public static void CancelReservation(int id)
        {
            var context             = new TableReadyContext();
            var originalReservation = context.ReservationEntry.SingleOrDefault(p => p.ReservationId == id);

            originalReservation.ReservationStatus = "cancelled";
            context.SaveChanges();
        }
Example #13
0
        public static void CancelPartySizeWaitlist(int id)
        {
            var context          = new TableReadyContext();
            var originalWaitlist = context.WaitlistEntry.SingleOrDefault(p => p.WaitlistEntryId == id);

            originalWaitlist.WaitlistStatus = "cancelled";
            context.SaveChanges();
        }
Example #14
0
        public static void UpdatePartySizeWaitlist(WaitlistEntry waitlist)
        {
            var context          = new TableReadyContext();
            var originalWaitlist = context.WaitlistEntry.SingleOrDefault(p => p.WaitlistEntryId == waitlist.WaitlistEntryId);

            originalWaitlist.PartySize = waitlist.PartySize;
            context.SaveChanges();
        }
        public static void DeleteAuthMatrixByIds(int restId, int authId)
        {
            var context             = new TableReadyContext();
            var authorizationMatrix = context.AuthenticationMatrix.SingleOrDefault(p => p.AuthenticationId == authId && p.RestaurantId == restId);

            context.AuthenticationMatrix.Remove(authorizationMatrix);
            context.SaveChanges();
        }
        public static void UpdateAuthenticationMatrixByIDs(AuthenticationMatrix restAuth)
        {
            var context = new TableReadyContext();
            var originalAuthRestaurant = context.AuthenticationMatrix.SingleOrDefault(p => p.AuthenticationId == restAuth.AuthenticationId && p.RestaurantId == restAuth.RestaurantId);

            originalAuthRestaurant.Role = restAuth.Role;
            context.SaveChanges();
        }
Example #17
0
        public static void UpdateReservation(ReservationEntry reservation)
        {
            var context             = new TableReadyContext();
            var originalReservation = context.ReservationEntry.SingleOrDefault(re => re.ReservationId == reservation.ReservationId);

            originalReservation.EntryOrigin       = reservation.EntryOrigin;
            originalReservation.PartySize         = reservation.PartySize;
            originalReservation.ReservationStatus = reservation.ReservationStatus;
            context.SaveChanges();
        }
Example #18
0
        public static void UpdateWaitlist(WaitlistEntry waitlist)
        {
            var context          = new TableReadyContext();
            var originalWaitlist = context.WaitlistEntry.SingleOrDefault(we => we.WaitlistEntryId == waitlist.WaitlistEntryId);

            originalWaitlist.EntryOrigin    = waitlist.EntryOrigin;
            originalWaitlist.PartySize      = waitlist.PartySize;
            originalWaitlist.WaitlistStatus = waitlist.WaitlistStatus;
            context.SaveChanges();
        }
Example #19
0
        public static void UpdateWaitlist(WaitlistEntry waitEntry)
        {
            var context = new TableReadyContext();
            var originalWailisttEntry = context.WaitlistEntry.SingleOrDefault(p => p.WaitlistEntryId == waitEntry.WaitlistEntryId);

            originalWailisttEntry.PartySize      = waitEntry.PartySize;
            originalWailisttEntry.WaitlistStatus = waitEntry.WaitlistStatus;
            originalWailisttEntry.EntryOrigin    = waitEntry.EntryOrigin;
            originalWailisttEntry.CheckinDate    = waitEntry.CheckinDate;
            context.SaveChanges();
        }
Example #20
0
        public static void UpdateReservation(ReservationEntry reservation)
        {
            var context             = new TableReadyContext();
            var originalReservation = context.ReservationEntry.SingleOrDefault(p => p.ReservationId == reservation.ReservationId);

            originalReservation.PartySize           = reservation.PartySize;
            originalReservation.ReservationDateTime = reservation.ReservationDateTime;
            originalReservation.ReservationStatus   = reservation.ReservationStatus;
            originalReservation.CheckinDateTime     = reservation.CheckinDateTime;
            originalReservation.CustomerMessage     = reservation.CustomerMessage;
            context.SaveChanges();
        }
Example #21
0
        public static void UpdateRestaurantEmployee(RestaurantEmployees restaurantEmployee)
        {
            var context = new TableReadyContext();
            var originalRestaurantEmployee = context.RestaurantEmployees.SingleOrDefault(p => p.RestaurantId == restaurantEmployee.RestaurantId && p.EmployeeId == restaurantEmployee.EmployeeId);

            originalRestaurantEmployee.NewRequestFlag = restaurantEmployee.NewRequestFlag;
            originalRestaurantEmployee.RequestStatus  = restaurantEmployee.RequestStatus;
            originalRestaurantEmployee.StartDate      = restaurantEmployee.StartDate;
            originalRestaurantEmployee.EndDate        = restaurantEmployee.EndDate;
            originalRestaurantEmployee.Active         = restaurantEmployee.Active;
            originalRestaurantEmployee.Status         = restaurantEmployee.Status;
            context.SaveChanges();
        }
Example #22
0
        public static void UpdateRestaurantOwner(RestaurantOwners restaurantOwner)
        {
            var context = new TableReadyContext();
            var originalRestaurantOwner = context.RestaurantOwners.SingleOrDefault(p => p.RestaurantId == restaurantOwner.RestaurantId && p.OwnerId == restaurantOwner.OwnerId);

            originalRestaurantOwner.Request       = restaurantOwner.Request;
            originalRestaurantOwner.RequestStatus = restaurantOwner.RequestStatus;
            originalRestaurantOwner.StartDate     = restaurantOwner.StartDate;
            originalRestaurantOwner.EndDate       = restaurantOwner.EndDate;
            originalRestaurantOwner.Active        = restaurantOwner.Active;
            originalRestaurantOwner.Status        = restaurantOwner.Status;
            context.SaveChanges();
        }
        public static void UpdateUser(Users user)
        {
            var context      = new TableReadyContext();
            var originalUser = context.Users.SingleOrDefault(p => p.UserId == user.UserId);

            originalUser.LastName  = user.LastName;
            originalUser.FirstName = user.FirstName;
            originalUser.Email     = user.Email;
            originalUser.Country   = user.Country;
            originalUser.City      = user.City;
            originalUser.Province  = user.Province;
            originalUser.Phone     = user.Phone;
            originalUser.Address   = user.Address;
            context.SaveChanges();
        }
        public static bool UpdateAuthentication(Authentication auth)
        {
            var context   = new TableReadyContext();
            var authGroup = context.Authentication;
            var existAuth = authGroup.SingleOrDefault(p => p.Username == auth.Username);

            if (existAuth == null || existAuth.Id == auth.Id)
            {
                var originalAuth = authGroup.SingleOrDefault(p => p.Id == auth.Id);
                originalAuth.Password = auth.Password;
                originalAuth.Username = auth.Username;
                context.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #25
0
        public static int CreateRestaurant(Restaurants restaurant)
        {
            var context       = new TableReadyContext();
            var restGroup     = context.Restaurants;
            var maxRestBefore = restGroup.SingleOrDefault(p => p.RestaurantId == restGroup.Max(k => k.RestaurantId));

            context.Restaurants.Add(restaurant);
            context.SaveChanges();
            var maxRestAfter = restGroup.SingleOrDefault(p => p.RestaurantId == restGroup.Max(k => k.RestaurantId));

            if (maxRestAfter.RestaurantId == maxRestBefore.RestaurantId + 1)
            {
                return(maxRestAfter.RestaurantId);
            }
            else
            {
                return(0);
            }
        }