Beispiel #1
0
        /*
         * Logic for the "ticker" that is used as a way of ensuring the game is still going on, if the ame crashes,
         * displays a messagebox saying you have crashed and creates a new instance of a game.
         */
        private void dtTicker(object sender, EventArgs e)
        {
            increment += 0.001;

            inputValue = Math.Round(increment, 2);

            if (Double.Parse(multiplierText.Content.ToString()) == Double.Parse(multiplierValue.Content.ToString()))
            {
                dt.IsEnabled = false;
                int bet = int.Parse(BetTextBoxValue.Text);
                Player.Balance = Player.Balance - Double.Parse(BetTextBoxValue.Text.ToString());
                FirebaseResponse response = client.Set("Users/" + Player.Username, (User)Player);


                multiplierText.Content = "Crashed";
                //Player.Balance = Player.Balance - bet;
                dt.Stop();
                gameTimer.Stop();

                MessageBox.Show("You have crashed!");

                Game nextGame = new Game(Player);
                nextGame.Show();
                this.Close();
            }
            else
            {
                multiplierText.Content = inputValue.ToString();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Insertar nombre y contraseña de una cuenta.
        /// </summary>
        /// <returns>
        /// <seealso cref="WebServicesBUAP.Respuesta"/>
        /// La respuesta de la operación.
        /// </returns>
        /// <param name="user">Nombre de usuario de autenticación.</param>
        /// <param name="pass">La contraseña de autenticación.</param>
        /// <param name="newUser">El nombre de usuario de la cuenta nueva.</param>
        /// <param name="newPass">La contraseña de la cuenta nueva</param>
        public Respuesta SetUser(string user, string pass, string newUser, string newPass)
        {
            Respuesta res = Authenticate(user, pass);

            if (res.Status == "error")
            {
                return(res);
            }

            if (!Regex.Match(newUser, "^[a-zA-Z0-9]+$").Success)
            {
                return(GetResponse(503));
            }

            if (!Regex.Match(newPass, "^(?=.*\\d+).{8,}$").Success)
            {
                return(GetResponse(502));
            }

            if (UserExists(newUser))
            {
                return(GetResponse(508));
            }

            FirebaseResponse fireRes = client.Set("usuarios/" + newUser, MD5Hash(newPass));

            if (fireRes != null)
            {
                res = GetResponse(404);
            }

            return(res);
        }
        private void BtnReg_Click(object sender, EventArgs e)
        {
            #region Condition check
            if (string.IsNullOrWhiteSpace(txtUser.Text) &&
                string.IsNullOrWhiteSpace(txtPass.Text) &&
                string.IsNullOrWhiteSpace(txtName.Text))
            {
                MessageBox.Show("Please input all fields");
                return;
            }
            #endregion
            FirebaseResponse getId = client.Get(@"Counter");
            int cnt = int.Parse(getId.ResultAs<string>()) + 1;
            MyUser user = new MyUser()
            {
                user = txtUser.Text,
                pass = txtPass.Text,
                name = txtName.Text,
                id = cnt.ToString(),
                numOfPart = "0"
            };

            SetResponse setUser = client.Set(@"Users/" + txtUser.Text, user);
            SetResponse setId = client.Set(@"Counter", cnt.ToString());
            MessageBox.Show("Registration Successfully !!");

        }
Beispiel #4
0
        public void add()
        {
            var           res            = client.Get(@"Doctors/");
            MyAppointment ResAppointment = res.ResultAs <MyAppointment>();

            if (ResAppointment != null)
            {
                counter = ResAppointment.counter;
                counter++;
            }
            else
            {
                counter = 1;
            }

            MyAppointment doctor = new MyAppointment()
            {
                Username = TextBox1.Text,
                Password = TextBox2.Text,
                Fullname = TextBox3.Text,
                counter  = counter
            };

            SetResponse set = client.Set(@"Doctors/" + counter, doctor);

            client.Set(@"Doctors/" + "/" + "counter", counter);
            Response.Write("<script>alert('Successfully Added!')</script>");
        }
Beispiel #5
0
        public ActionResult SolicitarCita(string CitaID)
        {
            client = new FireSharp.FirebaseClient(config);
            SetResponse response   = client.Set("Cita/" + CitaID + "/Paciente/PacienteID/", SessionHelper.GetNameIdentifier(User));
            SetResponse responseN2 = client.Set("Cita/" + CitaID + "/CitaEstado/", "Ci002");

            return(RedirectToAction("AceptadoPago", "Cita"));
        }
Beispiel #6
0
        protected override void OnExit(ExitEventArgs e)
        {
            base.OnExit(e);

            // Store the state
            _client.Set("ParkedActivities", _parkingLot.Activities);
            _client.Set("Days", _dayContainer.Days);
        }
        public void AddVoteToDestination(int destId)
        {
            var destenationsFromDatabase = client.Get("DavesTrain/destinations/").ResultAs <List <DestinationModel> >();
            var nd = destenationsFromDatabase.Where(x => x.Id == destId).FirstOrDefault();

            nd.vote = nd.vote + 1;

            client.Set("DavesTrain/destinations/" + destId + "/vote", nd.vote);
        }
        private void AddPsicologoToFirebase(Usuario usuario)
        {
            client = new FireSharp.FirebaseClient(config);
            var DatosPsicologo = usuario;

            DatosPsicologo.Psicologo.PsicologoID = DatosPsicologo.UsuarioID;
            SetResponse setResponse  = client.Set("Usuario/" + DatosPsicologo.UsuarioID, DatosPsicologo);
            SetResponse setResponse2 = client.Set("Psicologo/" + DatosPsicologo.UsuarioID + "/UsuarioID/", DatosPsicologo.UsuarioID);
        }
Beispiel #9
0
        public void AddNew(Student student)
        {
            var          data     = student;
            PushResponse response = _firebaseClient.Push("Student/", data);

            data.Id = response.Result.name;

            SetResponse setResponse = _firebaseClient.Set("Student/" + data.Id, data);
        }
        private void AddPacienteToFirebase(Usuario usuario)
        {
            client = new FireSharp.FirebaseClient(config);
            var DatosPaciente = usuario;

            DatosPaciente.Paciente.PacienteID = DatosPaciente.UsuarioID;
            SetResponse setResponse  = client.Set("Usuario/" + DatosPaciente.UsuarioID, DatosPaciente);
            SetResponse setResponse2 = client.Set("Paciente/" + DatosPaciente.UsuarioID + "/UsuarioID/", DatosPaciente.UsuarioID);
        }
 /// <summary>
 /// Add newly added patient details
 /// </summary>
 /// <param name="admission">adding patient details</param>
 public void NewAdmissionDac(Admission admission)
 {
     // Insert newly added patient details
     if (firebaseClient != null)
     {
         var response = firebaseClient.Set("AdmissionList/" + admission.NINumber, admission);
         UpdateWardAvailability(admission.WardType);
     }
 }
Beispiel #12
0
        private int AddHistoryLocation()
        {
            string           path      = "Phonecalls/" + phonenumberText.Text;
            FirebaseResponse response  = client.Get(path);
            Phonecall        phonecall = response.ResultAs <Phonecall>(); //The response will contain the data being retreived

            //neu day la lan dien thoai dau tien cua khach
            if (phonecall == null)
            {
                Location[] locs = new Location[1];
                if (originRBtn.Checked)
                {
                    locs[0] = new Location(locationCb.Text, 3, "origin");
                }
                else
                {
                    locs[0] = new Location(locationCb.Text, 3, "premium");
                }
                phonecall = new Phonecall
                {
                    locations = locs
                };
                response = client.Set(path, phonecall);
                Phonecall result = response.ResultAs <Phonecall>();
                return(0);
            }
            //neu khach da goi truoc do nhung nhap vao 1 dia chi moi
            else
            {
                int             length = 0;
                List <Location> ls     = new List <Location>();
                length = phonecall.locations.Length;
                for (int i = 0; i < phonecall.locations.Length; i++)
                {
                    ls.Add(phonecall.locations[i]);
                }
                if (originRBtn.Checked)
                {
                    ls.Add(new Location(locationCb.Text, 3, "origin"));
                }
                else
                {
                    ls.Add(new Location(locationCb.Text, 3, "premium"));
                }

                Location[] locs = ls.ToArray();

                phonecall = new Phonecall
                {
                    locations = locs
                };
                response = client.Set(path, phonecall);
                Phonecall result = response.ResultAs <Phonecall>();
                return(length);
            }
        }
Beispiel #13
0
        private string create_new_id()
        {
            var          retrieve_response = client.Get(sBorrowTable_path + "count");
            Borrow_Count data = retrieve_response.ResultAs <Borrow_Count>();
            int          plus = Convert.ToInt32(data.value) + 1;

            data.value = plus.ToString();
            SetResponse response = client.Set(sBorrowTable_path + "count", data);

            return(plus.ToString());
        }
        private void Ready()
        {
            Receive <ChatCreatedEvent>(@event =>
            {
                string path        = "user-chats/" + _userId;
                string lastMessage = String.Format("{0} created a chat with you", @event.Creator.Login);
                if (@event.Creator.Id == _userId)
                {
                    lastMessage = "You created a chat";
                }

                var userChat = new UserChatDto()
                {
                    ChatId            = @event.Id,
                    UserId            = _userId,
                    LastMessage       = lastMessage,
                    LastMessageAuthor = @event.Creator.Login,
                    LastMessageDate   = DateTime.UtcNow
                };

                userChat.Participants = @event.Participants
                                        .Select(x => new ChatParticipantDto()
                {
                    Id = x.Id, Login = x.Login
                }).ToList();
                string participantNames = string.Join(", ",
                                                      userChat.Participants.Where(x => x.Id != _userId).Select(x => x.Login));
                userChat.Name = participantNames;

                client.Push(path, userChat);
            });

            Receive <ChatMessageAddedEvent>(@event =>
            {
                string path = "user-chats/" + _userId;
                FirebaseResponse response = client.Get(path);
                Dictionary <string, UserChatDto> chats = response.ResultAs <Dictionary <string, UserChatDto> >();

                if (chats != null && chats.Any(x => x.Value.ChatId == @event.ChatId))
                {
                    var chat = chats.First(x => x.Value.ChatId == @event.ChatId);

                    string userChatPathLastMessage = String.Format("user-chats/{0}/{1}/LastMessage", _userId, chat.Key);
                    client.Set(userChatPathLastMessage, @event.Message);

                    string userChatPathLastMessageAuthor = String.Format("user-chats/{0}/{1}/LastMessageAuthor", _userId, chat.Key);
                    client.Set(userChatPathLastMessageAuthor, @event.Author.Login);

                    string userChatPathLastMessageDate = String.Format("user-chats/{0}/{1}/LastMessageDate", _userId, chat.Key);
                    client.Set(userChatPathLastMessageDate, @event.Date);
                }
            });
        }
Beispiel #15
0
        public ActionResult NewS(string name, DateTime exp, int numberofentrence, string email, string phone, string adres)
        {
            ViewBag.Name             = name;
            ViewBag.Exp              = exp;
            ViewBag.Numberofentrence = numberofentrence;
            if (name == "")
            {
                ViewBag.Message = "No name";
                return(View("New"));
            }

            var subscription = new Subscription();

            subscription.name   = name;
            subscription.email  = email;
            subscription.phone  = phone;
            subscription.addres = adres;
            if (exp != DateTime.Now)
            {
                subscription.exp = exp;
            }
            else
            {
                subscription.exp = DateTime.MinValue;
            }

            if (numberofentrence > 0)
            {
                subscription.numberofentrence = numberofentrence;
            }
            else
            {
                subscription.numberofentrence = -1;
            }

            subscription.deleted = 0;
            Client = new FirebaseClient(Config);
            var response = Client.Get("subscription");

            if (response.Body != "null")
            {
                var s = response.ResultAs <List <Subscription> >();
                subscription.code = s.Count;
                var response2 = Client.Set("subscription/" + s.Count, subscription);
            }
            else
            {
                var response2 = Client.Set("subscription/" + "0", subscription);
            }

            return(View("Index"));
        }
Beispiel #16
0
        public bool AddCustomer(Customer c)
        {
            FirebaseResponse firebaseResponse = firebaseClient.Get($"Customer/{c.ID}");

            if (firebaseResponse.Body == "null")
            {
                SetResponse response = firebaseClient.Set($"Customer/{c.ID}", c);
                Console.WriteLine($"Customer Added {c.ID}");
                return(true);
            }
            Console.WriteLine("Customer already exist");
            return(false);
        }
        public void Set()
        {
            var todo = new Todo
            {
                name     = "Execute SET",
                priority = 2
            };
            SetResponse response = _client.Set("todos/set", todo);
            Todo        result   = response.ResultAs <Todo>();

            Assert.NotNull(response);
            Assert.AreEqual(todo.name, result.name);
        }
Beispiel #18
0
 public HttpStatusCode addNewRecord(Contact contactData)
 {
     try
     {
         PushResponse response = client.Push("contactList", contactData);
         contactData.dbId = response.Result.name;
         return(client.Set("contactList/" + contactData.dbId, contactData).StatusCode);
     }
     catch (Exception ex)
     {
         return(HttpStatusCode.ExpectationFailed);
     }
 }
        private void AdminRegbtn_Click(object sender, EventArgs e)
        {
            string ps = PasswordTboxR.Text;

            #region Condition
            if (
                string.IsNullOrWhiteSpace(FirstnameTbox.Text) &&
                string.IsNullOrWhiteSpace(LastnameTbox.Text) &&
                string.IsNullOrWhiteSpace(UsernameTboxR.Text) &&
                string.IsNullOrWhiteSpace(PasswordTboxR.Text) &&
                string.IsNullOrWhiteSpace(CPassTbox.Text)
                )
            {
                MessageBox.Show("Please Fill All The Fields");
                //return;
            }

            #endregion
            else if (UsernameTboxR.Text.Length < 8)
            {
                MessageBox.Show("Username must contain minimum 8 charaters....!");
            }

            else if (ps.Length < 5)
            {
                MessageBox.Show("Password must contain minimum 5 charaters....!");
            }

            else if (PasswordTboxR.Text != CPassTbox.Text)
            {
                MessageBox.Show("Password Doesnt Match!");
            }

            else
            {
                AdminModel am = new AdminModel()
                {
                    Firstname = FirstnameTbox.Text,
                    Lastname  = LastnameTbox.Text,
                    Username  = UsernameTboxR.Text,
                    Password  = PasswordTboxR.Text,
                };

                var push         = client.Set("admin/admininfo/" + UsernameTboxR.Text + "/", am);
                var isadminexist = client.Set("admin/isadminexist", "YES");
                RegPanel.Hide();
                Regbtn.Hide();
                MessageBox.Show("Thank You, " + FirstnameTbox.Text + " " + LastnameTbox.Text + "\nYour Registration is Successfull! \nYou can login now....");
            }
        }
Beispiel #20
0
        public string Add(T entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            // push and set to update the Id
            var response = _client.Push("/", entity);

            entity.Id = response.Result.Name;
            _client.Set($"/{entity.Id}/", entity);
            return(entity.Id);
        }
Beispiel #21
0
        private void BtnReg_Click(object sender, EventArgs e)
        {
            #region Condition check
            if (string.IsNullOrWhiteSpace(txtUser.Text) &&
                string.IsNullOrWhiteSpace(txtPass.Text) &&
                string.IsNullOrWhiteSpace(txtName.Text) &&
                string.IsNullOrWhiteSpace(cbGender.Text))
            {
                MessageBox.Show("Please input All fields");
                return;
            }
            #endregion

            MyUser user = new MyUser()
            {
                Username = txtUser.Text,
                Password = txtPass.Text,
                Gender   = cbGender.Text,
                Fullname = txtName.Text
            };

            SetResponse set = client.Set(@"User/" + txtUser.Text, user);

            MessageBox.Show("Successfully registration!!");
        }
Beispiel #22
0
        private void addcategbtn_Click(object sender, EventArgs e)
        {
            Category category = new Category()
            {
                category = categoryTbox.Text,
                cid      = "0"
            };
            PushResponse catpush = client.Push("Categories/", category);
            string       cid     = catpush.Result.name;

            client.Set("Categories/" + cid + "/cid/", cid);
            loadcombobox();
            MessageBox.Show("Category " + categoryTbox.Text + " is Successfully Added...!");
            categoryTbox.Text          = "";
            SelCategCbox.SelectedIndex = -1;
        }
Beispiel #23
0
        //xóa dữ liệu IDDiscount
        public void Delete(string id)
        {
            if (id != "")
            {
                client = new FireSharp.FirebaseClient(config);
                var         discounts   = getDiscount(id); //lấy thông tin khuyến mãi
                var         data        = new Discount();
                SetResponse setResponse = client.Set("Discount/" + id, setnull(data));

                DiscountDish discountDish         = new DiscountDish();
                var          danhsachdiscountDish = discountDish.getAll();
                foreach (var item in danhsachdiscountDish)
                {
                    if (item.DishcountTypeID == discounts.IDDiscountType)
                    {
                        discountDish.Delete(item.DiscountDishID);
                    }
                }

                var danhsachkhuyenmai = getByidStore(discounts.IDStore);
                if (danhsachkhuyenmai.Count == 0)       //nếu chỉ có 1 khuyến mãi của quán
                {
                    Store danhsachstore = new Store();
                    var   store         = danhsachstore.getByID(discounts.IDStore, 0, 0);
                    foreach (var item2 in store)     //tắt biến khuyến mãi của quán thành false
                    {
                        item2.Discount = false;
                        danhsachstore.AddbyidToFireBase(item2.StoreID, item2);
                    }
                }
            }
        }
Beispiel #24
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(bunifuMaterialTextbox1.Text) || string.IsNullOrEmpty(bunifuMaterialTextbox2.Text) ||
                string.IsNullOrEmpty(bunifuMaterialTextbox3.Text) || string.IsNullOrEmpty(bunifuMaterialTextbox4.Text) ||
                string.IsNullOrEmpty(bunifuMaterialTextbox5.Text) || string.IsNullOrEmpty(comboBox1.Text))
            {
                MessageBox.Show("Please Specify all Blanks.");
            }
            else
            {
                string sel1 = this.comboBox1.GetItemText(this.comboBox1.SelectedItem);

                venregis c1 = new venregis()
                {
                    firstname  = bunifuMaterialTextbox3.Text,
                    id         = bunifuMaterialTextbox1.Text,
                    lastname   = bunifuMaterialTextbox5.Text,
                    middlename = bunifuMaterialTextbox4.Text,
                    org_type   = sel1,
                    password   = bunifuMaterialTextbox2.Text
                };

                var set = client.Set(@"User/Venue/" + bunifuMaterialTextbox1.Text, c1);

                MessageBox.Show("Register Success.");
                bunifuMaterialTextbox1.Text = string.Empty;
                bunifuMaterialTextbox2.Text = string.Empty;
                bunifuMaterialTextbox3.Text = string.Empty;
                bunifuMaterialTextbox4.Text = string.Empty;
                bunifuMaterialTextbox5.Text = string.Empty;
                comboBox1.Text = string.Empty;
            }
        }
Beispiel #25
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtLink.Text == string.Empty)
     {
         MessageBox.Show("No link selected to Update."); return;
     }
     firebaseConfiqration();
     if (btnSave.Text == "Save")
     {
         UpdateItem mictco = new UpdateItem();
         mictco.UpdationLink = txtLink.Text;
         var          entdata   = mictco;
         PushResponse responses = client.Push(sTable, entdata);
         entdata.Id = responses.Result.name;
         SetResponse setResponse = client.Set(sTable + entdata.Id, entdata);
         MessageBox.Show("Link Saved");
     }
     else
     {
         item.UpdationLink = txtLink.Text;
         FirebaseResponse responses = client.Update(sTable + item.Id, item);
         MessageBox.Show("Link Updated");
     }
     FB_Management_Load(null, null);
     txtLink.Text = string.Empty;
     this.Close();
 }
        private void btnregis_Click(object sender, EventArgs e)
        {
            #region Condition
            if (string.IsNullOrWhiteSpace(txtemail.Text) &&
                string.IsNullOrWhiteSpace(txtnama.Text) &&
                string.IsNullOrWhiteSpace(txttelepon.Text) &&
                string.IsNullOrWhiteSpace(txtpass.Text) &&
                string.IsNullOrWhiteSpace(txtrepass.Text))
            {
                MessageBox.Show("Tolong lengkapi formulir yang kosong");
                return;
            }
            #endregion

            MyUser user = new MyUser()
            {
                Email    = txtemail.Text,
                Nama     = txtnama.Text,
                Telepon  = txttelepon.Text,
                Password = txtpass.Text
            };
            SetResponse set    = client.Set(@"Users/" + txtnama.Text, user);
            MyUser      ReUser = set.ResultAs <MyUser>();

            MyUser CurUser = new MyUser()
            {
                Nama     = txtnama.Text,
                Email    = txtemail.Text,
                Telepon  = txttelepon.Text,
                Password = txtpass.Text
            };
        }
        public ActionResult ActualizaCumple(DateTime FechaNaci, string id)
        {
            client = new FireSharp.FirebaseClient(config);
            SetResponse response = client.Set("Usuario/" + id + "/Paciente/FechaNaci/", FechaNaci);

            return(RedirectToAction("Perfil", "Account", new { id }));
        }
Beispiel #28
0
        public ActionResult Edit(Store store)
        {
            client = new FireSharp.FirebaseClient(config);
            SetResponse response = client.Set("Store/" + store.StoreID, store);

            return(RedirectToAction("Index"));
        }
        private void SignUpbtn_Click(object sender, EventArgs e)
        {
            #region Conditions to Check Text Boxes Not Null
            if (String.IsNullOrEmpty(tbFName.Text) &&
                String.IsNullOrEmpty(tbLName.Text) &&
                String.IsNullOrEmpty(tbEmail.Text) &&
                String.IsNullOrEmpty(tbConfirmPass.Text) &&
                String.IsNullOrEmpty(tbPasswordSignUp.Text) ||
                !tbConfirmPass.Text.Equals(tbPasswordSignUp.Text))
            {
                MessageBox.Show("Fill all data or passord not correct", "Error");
            }
            else
            {
                //Use UserModel to Store data to set this values to firebase.
                UserModel user = new UserModel(tbFName.Text, tbLName.Text,
                                               tbPasswordSignUp.Text, tbEmail.Text);

                //this path to set data to user.
                // EX : USERS -- > *FullName* --> *ALL Data About User*.

                SetResponse response = firebase.Set(@"Users/" + tbFName.Text, user);

                MessageBox.Show("Sign Up Successfully", "Done");
                Home home = new Home();
                home.ShowDialog();
                this.Hide();
            }
            #endregion
        }
Beispiel #30
0
        public ActionResult Edit(Comment comment)
        {
            client = new FireSharp.FirebaseClient(config);
            SetResponse response = client.Set("Comment/" + comment.CommentID, comment);

            return(RedirectToAction("Index"));
        }