Beispiel #1
0
 /// <summary>
 /// Saves the Order in database
 /// </summary>
 private void SaveExecute()
 {
     try
     {
         tblOrder order = new tblOrder();
         order.Price = Price;
         order.State = "Waiting";
         using (PizzaRestourantEntities db = new PizzaRestourantEntities())
         {
             tblGuest guest = db.tblGuests.Where(x => x.Username == "2201996800109").FirstOrDefault();
             order.FKGuest = guest.Id;
             DateTime dateTime = DateTime.Now;
             order.CreatedDate = dateTime.Date;
             order.CreatedTime = dateTime.TimeOfDay;
             db.tblOrders.Add(order);
             db.SaveChanges();
         }
         MessageBox.Show($"Ordered Successfully! Order Status: {order.State}");
         main.Close();
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message.ToString());
     }
 }
Beispiel #2
0
        public LoginViewModel(Login login)
        {
            this.login = login;
            guest      = new tblGuest();

            Service s = new Service();
        }
Beispiel #3
0
        public string DeleteGuest(int ID)
        {
            string   retVal = string.Empty;
            tblGuest guest  = _ODB.tblGuests.Where(e => e.ID == ID).SingleOrDefault();

            if (guest != null)
            {
                if (guest.tblReservation.tblInvitation.ENumber == Current.User.ENumber || Current.User.IsAdmin || Current.User.IsStaff)
                {
                    Logging.Log(Logging.LogType.Audit, string.Format("User {0} has chosen to delete guest with ID {1} and email '{2}'", Current.User.Username, guest.ID, guest.EmailAddress));
                    _ODB.tblGuests.DeleteObject(guest);
                    _ODB.SaveChanges();
                    retVal = "The selected guest was deleted successfully.";
                }
                else
                {
                    retVal = "You are not authorized to delete guests from this reservation";
                }
            }
            else
            {
                retVal = "The selected guest could not be deleted. The system could not find the guest by the provided ID";
            }

            return(retVal);
        }
Beispiel #4
0
        /// <summary>
        /// Method for login user
        /// </summary>
        private void LoginExecute()
        {
            string username = mainWindow.NameTextBox.Text;

            // Hash password
            var hasher         = new SHA256Managed();
            var unhashed       = Encoding.Unicode.GetBytes(mainWindow.passwordBox.Password);
            var hashed         = hasher.ComputeHash(unhashed);
            var hashedPassword = Convert.ToBase64String(hashed);

            string password = hashedPassword;

            Service s = new Service();

            //Checks if there is a username and password in the database
            tblGuest userLogin = s.GetUsernamePassword(username, password);

            if (userLogin != null)
            {
                PrintMessage();

                CakeMenu cakeMenu = new CakeMenu
                {
                    Owner = mainWindow
                };
                mainWindow.Hide();
                cakeMenu.ShowDialog();
            }
            else
            {
                Xceed.Wpf.Toolkit.MessageBox.Show("Korisničko ime ili lozinka nisu ispravni,\n pokušajte opet.", "Nalog nije pronađen.");
            }
        }
Beispiel #5
0
        private void LoginGExecute()
        {
            Service s = new Service();

            string jmbg = login.JMBG.Text;

            tblGuest guestLogin = s.GetJMBG(jmbg);

            if (guestLogin != null && login.passwordBox.Password == "Gost")
            {
                //Storing logged in guest data
                LoggedGuest.name    = guestLogin.GuestName;
                LoggedGuest.surname = guestLogin.GuestSurname;
                LoggedGuest.jmbg    = guestLogin.JMBG;
                LoggedGuest.email   = guestLogin.EMail;
                LoggedGuest.id      = guestLogin.GuestID;
                employeeLoging      = false;
                guestLoging         = true;
                login.loggedIn      = false;
                login.Close();
            }
            else
            {
                VisibleLoginFail();
            }
        }
Beispiel #6
0
        public tblGuest AddGuest(tblGuest guest)
        {
            try
            {
                using (PizzaRestoranEntities context = new PizzaRestoranEntities())
                {
                    tblGuest newGuest = new tblGuest
                    {
                        GuestID      = guest.GuestID,
                        GuestName    = guest.GuestName,
                        GuestSurname = guest.GuestSurname,
                        EMail        = guest.EMail,
                        JMBG         = guest.JMBG
                    };

                    context.tblGuests.Add(newGuest);
                    context.SaveChanges();
                    guest.GuestID = newGuest.GuestID;
                    return(guest);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception: " + ex.Message.ToString());
                return(null);
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            tblGuest tblGuest = db.tblGuests.Find(id);

            db.tblGuests.Remove(tblGuest);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "id,title,firstname,lastname,checkindate,expectedcheckoutdate,checkoutdate,checkoutstatus,checkouttype,billamount,roomnumber,folionumber,ecallowed,vip,primaryguest,guestcount,eventcode,groupcode,loyaltynumber,emailid,language,phonenumber,age,gender,dob,companyname,companyaddress1,companyaddress2,companycode,createddatetime,updateddatetime,wstatus,tvright,checkinRequestFrom")] tblGuest tblGuest)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblGuest).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblGuest));
 }
Beispiel #9
0
 public ActionResult Edit([Bind(Include = "guest_phone_number,guest_name,time_arrived,num_of_guests,table_num,reservation")] tblGuest tblGuest)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblGuest).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.table_num = new SelectList(db.tblUnusedTables, "table_num", "description", tblGuest.table_num);
     return(View(tblGuest));
 }
Beispiel #10
0
        /// <summary>
        /// A method for registering new guests
        /// </summary>
        private void SignUpExecute()
        {
            try
            {
                Service s = new Service();

                string name    = Guest.GuestName;
                string surname = Guest.GuestSurname;
                string jmbg    = Guest.JMBG;
                string email   = Guest.EMail;

                //JMBG validation
                if (!ValidationJMBG.CheckJMBG(jmbg))
                {
                    return;
                }

                //Check if the JMBG exists in the database
                tblGuest employee = s.GetGuestJMBG(jmbg);

                if (employee != null)
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("JMBG already exists in the database, try another.", "JMBG");
                    return;
                }

                //Check if the email exists in the database
                tblGuest employeeEmail = s.GetGuestEmail(email);

                if (employeeEmail != null)
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("E-mail already exists in the database, try another.", "E-mail");
                    return;
                }

                s.AddGuest(Guest);

                IsUpdateGuest = true;

                string poruka = "Guest: " + Guest.GuestName + " " + Guest.GuestSurname;
                Xceed.Wpf.Toolkit.MessageBox.Show(poruka, "Successfully added Guest", MessageBoxButton.OK);
                login.txtName.Text                = "";
                login.txtSurname.Text             = "";
                login.txtJMBG.Text                = "";
                login.txtEmail.Text               = "";
                login.pnlLoginGuest.Visibility    = Visibility.Visible;
                login.pnlLoginEmployee.Visibility = Visibility.Collapsed;
                login.pnlSignUpGuest.Visibility   = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                Xceed.Wpf.Toolkit.MessageBox.Show(ex.ToString());
            }
        }
Beispiel #11
0
        public ActionResult DeleteConfirmed(string id)
        {
            tblGuest       tblGuest    = db.tblGuests.Find(id);
            tblUsedTable   table       = db.tblUsedTables.Find(tblGuest.table_num);
            tblUnusedTable unusedTable = new tblUnusedTable();

            unusedTable.table_num   = table.table_num;
            unusedTable.description = table.description;
            db.tblUnusedTables.Add(unusedTable);
            db.tblUsedTables.Remove(table);
            db.tblGuests.Remove(tblGuest);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: Guests/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblGuest tblGuest = db.tblGuests.Find(id);

            if (tblGuest == null)
            {
                return(HttpNotFound());
            }
            return(View(tblGuest));
        }
Beispiel #13
0
        // GET: Guests/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblGuest tblGuest = db.tblGuests.Find(id);

            if (tblGuest == null)
            {
                return(HttpNotFound());
            }
            ViewBag.table_num = new SelectList(db.tblUnusedTables, "table_num", "description", tblGuest.table_num);
            return(View(tblGuest));
        }
Beispiel #14
0
        /// <summary>
        /// Checks if there is a phoneNumber in the database
        /// </summary>
        /// <param name="phoneNumber"></param>
        /// <returns></returns>
        public tblGuest GetPhoneNumber(string phoneNumber)
        {
            try
            {
                using (BirthdayCakeEntities context = new BirthdayCakeEntities())
                {
                    tblGuest user = (from e in context.tblGuests where e.PhoneNumber.Equals(phoneNumber) select e).First();

                    return(user);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
                return(null);
            }
        }
Beispiel #15
0
        /// <summary>
        /// Method for adding new Guest
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public tblGuest AddUser(tblGuest user)
        {
            try
            {
                using (BirthdayCakeEntities context = new BirthdayCakeEntities())
                {
                    if (user.GuestID == 0)
                    {
                        tblGuest newUser = new tblGuest
                        {
                            GuestID          = user.GuestID,
                            GuestUsername    = user.GuestUsername,
                            GuestPassword    = user.GuestPassword,
                            GuestNameSurname = user.GuestNameSurname,
                            GuestAddress     = user.GuestAddress,
                            PhoneNumber      = user.PhoneNumber,
                            NumberOrder      = user.NumberOrder
                        };

                        context.tblGuests.Add(newUser);
                        context.SaveChanges();
                        user.GuestID = newUser.GuestID;
                        return(user);
                    }
                    else
                    {
                        tblGuest userToEdit = (from r in context.tblGuests where r.GuestID == user.GuestID select r).First();

                        userToEdit.GuestUsername    = user.GuestUsername;
                        userToEdit.GuestPassword    = user.GuestPassword;
                        userToEdit.GuestNameSurname = user.GuestNameSurname;
                        userToEdit.GuestAddress     = user.GuestAddress;
                        userToEdit.PhoneNumber      = user.PhoneNumber;
                        userToEdit.NumberOrder      = user.NumberOrder;
                        context.SaveChanges();
                        return(user);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Nešto je pošlo po zlu prilikom registracije", "Greška");
                System.Diagnostics.Debug.WriteLine("Exception: " + ex.Message.ToString());
                return(null);
            }
        }
Beispiel #16
0
        /// <summary>
        /// Return username and password on database
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public tblGuest GetUsernamePassword(string username, string password)
        {
            try
            {
                using (BirthdayCakeEntities context = new BirthdayCakeEntities())
                {
                    tblGuest user = (from e in context.tblGuests where e.GuestUsername.Equals(username) where e.GuestPassword.Equals(password) select e).First();

                    return(user);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
                return(null);
            }
        }
Beispiel #17
0
        public tblGuest GetGuestJMBG(string JMBG)
        {
            try
            {
                using (PizzaRestoranEntities context = new PizzaRestoranEntities())
                {
                    tblGuest emoloyee = (from e in context.tblGuests where e.JMBG.Equals(JMBG) select e).First();


                    return(emoloyee);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
                return(null);
            }
        }
        /// <summary>
        /// Gets the Guest that ordered selecred order
        /// </summary>
        private void GetOrderOwner()
        {
            tblOrder selectedOrder = new tblOrder();
            tblGuest guest         = new tblGuest();

            try
            {
                using (PizzaRestourantEntities db = new PizzaRestourantEntities())
                {
                    selectedOrder = db.tblOrders.Where(x => x.Id == Order.Id).FirstOrDefault();
                    guest         = db.tblGuests.Where(x => x.Id == selectedOrder.FKGuest).FirstOrDefault();
                }
                MessageBox.Show($"Username: {guest.Username}");
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message.ToString());
            };
        }
Beispiel #19
0
        public ActionResult Create([Bind(Include = "guest_phone_number,guest_name,time_arrived,num_of_guests,table_num,reservation")] tblGuest tblGuest)
        {
            if (ModelState.IsValid)
            {
                tblUnusedTable table     = db.tblUnusedTables.Find(tblGuest.table_num);
                tblUsedTable   usedTable = new tblUsedTable();
                usedTable.table_num   = table.table_num;
                usedTable.description = table.description;
                //add used table
                db.tblUsedTables.Add(usedTable);
                //remove from available tables
                db.tblUnusedTables.Remove(table);
                db.tblGuests.Add(tblGuest);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.table_num = new SelectList(db.tblUnusedTables, "table_num", "description", tblGuest.table_num);
            return(View(tblGuest));
        }
Beispiel #20
0
        //public CGuest(int guestID, string gender, string ageGroup, string city, string ethnicity, int eventID)
        //{
        //    GuestID = guestID;
        //    Gender = gender;
        //    AgeGroup = ageGroup;
        //    City = city;
        //    Ethnicity = ethnicity;
        //    EventID = eventID;
        //}

        //methods
        public bool Insert()
        {
            try
            {
                LFGuestSystemEntities oDc = new LFGuestSystemEntities();

                tblGuest t_guest = new tblGuest();

                t_guest.GuestID = 1;

                // automatically calculate the new GuestID
                if (oDc.tblGuests.Count() > 0)
                {
                    t_guest.GuestID = oDc.tblGuests.Max(p => p.GuestID) + 1;
                }

                // fill in the data
                this.GuestID = t_guest.GuestID;

                t_guest.Gender        = this.Gender;
                t_guest.AgeGroup      = this.AgeGroup;
                t_guest.City          = this.City;
                t_guest.Ethnicity     = this.Ethnicity;
                t_guest.RepeatVisitor = this.RepeatVisitor;
                t_guest.EventID       = this.EventID;

                oDc.tblGuests.Add(t_guest);

                oDc.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #21
0
        //Create new user
        private void SignUpExecute()
        {
            try
            {
                Service s = new Service();

                string user        = this.Guest.GuestUsername;
                string phoneNumber = this.Guest.PhoneNumber;

                //uniqueness check username
                tblGuest User = s.GetUsername(user);

                if (User != null)
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Korisničko ime već postoji u bazi, pokušajte sa drugim.", "Korisničko ime");
                    return;
                }

                //uniqueness check phonenumber
                tblGuest PhoneNumber = s.GetPhoneNumber(phoneNumber);

                if (PhoneNumber != null)
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Broj telefona već neko koristi, pokušajte sa drugim.", "Korisničko ime");
                    return;
                }

                string password = this.Guest.GuestPassword;
                // Hash Password
                var hasher         = new SHA256Managed();
                var unhashed       = Encoding.Unicode.GetBytes(this.Guest.GuestPassword);
                var hashed         = hasher.ComputeHash(unhashed);
                var hashedPassword = Convert.ToBase64String(hashed);

                this.Guest.GuestPassword = hashedPassword;

                s.AddUser(this.Guest);
                IsUpdateGuest = true;

                string poruka = this.Guest.GuestNameSurname + "\nHvala Vam što ste nam uakzali poverenje.";
                Xceed.Wpf.Toolkit.MessageBox.Show(poruka, "Dobrodošli u L-Cake", MessageBoxButton.OK);

                mainWindow.NameTextBox.Text              = "";
                mainWindow.txtAddress.Text               = "";
                mainWindow.txtIme.Text                   = "";
                mainWindow.txtPhoneNumber.Text           = "";
                mainWindow.passwordBox.Password          = "";
                mainWindow.txtKorisnickoIme.Text         = "";
                mainWindow.txtLozinkaRegistracija.Text   = "";
                mainWindow.txtReLozinkaRegistracija.Text = "";
                mainWindow.login.Visibility              = Visibility.Visible;
                mainWindow.Images0.Visibility            = Visibility.Collapsed;
                mainWindow.Images1.Visibility            = Visibility.Visible;
                mainWindow.SignUp.Visibility             = Visibility.Collapsed;
                mainWindow.NameTextBox.Focus();
            }
            catch (Exception ex)
            {
                Xceed.Wpf.Toolkit.MessageBox.Show(ex.ToString());
            }
        }
Beispiel #22
0
        /// <summary>
        /// Adds a guest to a student event reservation
        /// </summary>
        /// <param name="Model">Guest View Model</param>
        /// <returns>ActionResult</returns>
        public ActionResult AddGuest(GuestViewModel Model)
        {
            tblReservation Reservation = _ODB.tblReservations.Where(e => e.ID == Model.ReservationID).SingleOrDefault();

            if (Reservation != null)
            {
                if (Reservation.tblInvitation.ENumber == Current.User.ENumber || Current.User.IsAdmin || Current.User.IsStaff)
                {
                    if (ModelState.IsValid)
                    {
                        if (Reservation.tblGuests.Count < Reservation.tblEventDate.MaxNumberGuests)
                        {
                            if (Reservation.tblEventDate.AllowGuestRegistration)
                            {
                                tblGuest existingGuest = Reservation.tblGuests.Where(e => e.EmailAddress.ToUpper() == Model.EmailAddress.ToUpper()).FirstOrDefault();
                                if (existingGuest == null)
                                {
                                    tblGuest newGuest = Model.As_tblGuest();
                                    newGuest.tblReservation = Reservation;
                                    _ODB.tblGuests.AddObject(newGuest);
                                    _ODB.SaveChanges();
                                    Logging.Log(Logging.LogType.Audit, string.Format("User {0} has added new guest with email '{1}', Guest ID={2} to reservation with ID {3}", Current.User.Username, newGuest.EmailAddress, newGuest.ID, Reservation.ID));
                                    if (Reservation.IsConfirmed)
                                    {
                                        this.ShowPageMessage(string.Format("Successfully added guest '{0}, {1} {2}' with email '{3}' to reservation. Your reservation has already been confirmed.  Please be sure to pay any additional fees that may be related to the additional guests you have added.", newGuest.LastName, newGuest.FirstName, newGuest.MiddleName, newGuest.EmailAddress));
                                    }
                                    else
                                    {
                                        this.ShowPageMessage(string.Format("Successfully added guest '{0}, {1} {2}' with email '{3}' to reservation.", newGuest.LastName, newGuest.FirstName, newGuest.MiddleName, newGuest.EmailAddress));
                                    }

                                    return(this.RedirectToAction <StudentController>(c => c.Reservation(Reservation.ID)));
                                }
                                else
                                {
                                    this.ShowPageError(string.Format("A guest has already been added to this reservation with the provided email address: {0}.", Model.EmailAddress));
                                }
                            }
                            else
                            {
                                this.ShowPageError("The selected event date for this reservation does not allow guest registration.");
                            }
                        }
                        else
                        {
                            this.ShowPageError(string.Format("You have already added the maximum number of guests. Guest Count: {0}. Max Guests: {1}", Reservation.tblGuests.Count, Reservation.tblEventDate.MaxNumberGuests));
                        }
                    }
                    else
                    {
                        this.ShowPageError(DataConstants.ModelStateInvalidError);
                    }
                }
                else
                {
                    this.ShowPageError("You are not authorized to add guests to this reservation");
                }
            }
            else
            {
                this.ShowPageError("Reservation could not be found for the given ID. No guest was added.");
            }

            ViewBag.ExpandAddGuestSection = true;
            ViewBag.GuestModel            = Model;
            return(View("Reservation", Reservation));
        }
Beispiel #23
0
 public MainWindowViewModel(MainWindow mainWindow)
 {
     this.mainWindow = mainWindow;
     guest           = new tblGuest();
 }