public async Task UpdateAsync()
        {
            _firebaseRequestManagerMock.Setup(
                firebaseRequestManager => firebaseRequestManager.RequestAsync(RequestManager.Patch, "todos", _expected))
            .Returns(Task.FromResult(_expectedResponse));

            var response = await _firebaseClient.UpdateAsync("todos", _expected);

            Assert.NotNull(response);
            Assert.AreEqual(response.Body, _expected.ToJson());
        }
Beispiel #2
0
        public void Update(T data, int id)
        {
            IFirebaseClient client = new FirebaseClient(config);
            string          path   = $"{data.ToString()}/{id}";

            FirebaseResponse response = client.UpdateAsync(path, data).Result;
        }
Beispiel #3
0
        public async Task <IActionResult> Update([FromBody] ProdutoEntidade value)
        {
            var clientProduto = await client.UpdateAsync("Produto/" + value.Index, value);

            var result = clientProduto.ResultAs <ProdutoEntidade>();

            return(Json("Atualizado com sucesso"));
        }
        public async Task <IHttpActionResult> sendMessage(cls_msg _Msg)
        {
            IFirebaseClient client = new FirebaseClient(config);

            if (_Msg.File != null)
            {
                string filename  = Guid.NewGuid().ToString();// Path.GetFileNameWithoutExtension(post1.imagefile.FileName);
                string extention = Path.GetExtension(_Msg.File.FileName);
                filename     = filename + DateTime.Now.ToString("yymmddssfff") + extention;
                _Msg.message = "~/Content/image/" + filename;
                filename     = Path.Combine(System.Web.Hosting.HostingEnvironment.MapPath("~/Content/image/"), filename);
                //other way
                // Path.Combine(HttpContext.Current.Server.MapPath("~/Content/image/"), filename);
                _Msg.File.SaveAs(filename);
            }
            var new_msg = new
            {
                sender       = db.AspNetUsers.FirstOrDefault(x => x.Id == _Msg.sender_id).UserName,
                sender_photo = db.AspNetUsers.FirstOrDefault(x => x.Id == _Msg.sender_id).Photo,
                message      = _Msg.message,
                timeStamp    = DateTime.Now,
                type         = _Msg.MsgType
            };

            await Push(new_msg, "chat/messages/" + _Msg.Room_id);

            ////////////////////////////////////////////////////////////////////////////////////////////
            FirebaseResponse response_ids = await client.GetAsync("chat/members/" + _Msg.Room_id);

            dynamic data = JsonConvert.DeserializeObject <dynamic>(response_ids.Body);
            var     list = new List <mems>();

            foreach (var itemDynamic in data)
            {
                list.Add(JsonConvert.DeserializeObject <mems>(((JProperty)itemDynamic).Value.ToString()));
            }
            var members = list.Where(x => x.mem_id != _Msg.sender_id).Select(x => x.mem_id);

            foreach (var item in members)
            {
                PushNotifi(db.AspNetUsers.FirstOrDefault(x => x.Id == item).DeviceToken, "new message from " + new_msg.sender, _Msg.message, "room", _Msg.Room_id);
            }
            /////////////////////////////////////////////////////////////////////////////////////////////
            FirebaseResponse response = await client.GetAsync("chat/rooms/" + _Msg.Room_id);

            cls_chat_room todo = response.ResultAs <cls_chat_room>();

            todo.lastMessage = _Msg.message;
            todo.timeStamp   = DateTime.Now;

            FirebaseResponse response2 = await client.UpdateAsync("chat/rooms/" + _Msg.Room_id, todo);

            return(Ok(new_msg));
        }
Beispiel #5
0
        public async Task Update()
        {
            IFirebaseClient client    = new FirebaseClient(config);
            var             my_notifi = new notification
            {
                user_id     = db.AspNetUsers.FirstOrDefault(x => x.UserName == User.Identity.Name).Id,
                source_name = "app",
                source_id   = 0,
                image       = "no image",
                body        = "this is the first notification update in the app",
                timestamp   = DateTime.Now,
                readed      = false
            };
            FirebaseResponse response = await client.UpdateAsync("my_notifi/set", my_notifi);

            notification todo = response.ResultAs <notification>(); //The response will contain the data written
        }
Beispiel #6
0
        private async void button1_Click_1(object sender, EventArgs e)
        {
            if (NametextBox.Text == string.Empty)
            {
                MessageBox.Show("Please Enter all Information", caption: "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            else if (RegistrationtextBox.Text == string.Empty)
            {
                MessageBox.Show("Please Enter all Information", caption: "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (MobileNotextBox4.Text == string.Empty)
            {
                MessageBox.Show("Please Enter all Information", caption: "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            else
            {
                Student student = new Student();
                student.name           = NametextBox.Text;
                student.registrationNO = RegistrationtextBox.Text;
                student.mobileNo       = MobileNotextBox4.Text;
                student.departmentName = DepartmenttextBox5.Text;
                student.address        = AddresstextBox3.Text;
                student.Id             = Idlabel.Text;


                IFirebaseConfig firebaseConfig = new FirebaseConfig()
                {
                    AuthSecret = "0q034wxR0p8grjvFHJtPzXLmMhlTNH3yrgrqlAEf",
                    BasePath   = "https://crudforms.firebaseio.com/"
                };
                IFirebaseClient client = new FirebaseClient(firebaseConfig);
                if (InternetCheck.isInternet())
                {
                    if (Save.Text == @"Save")
                    {
                        PushResponse message = await client.PushAsync("StudentList", student);

                        if (message != null)
                        {
                            MessageBox.Show("Student Saved Successfully.", caption: "Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Reset();
                            GetAllStudent();
                        }
                        else
                        {
                            MessageBox.Show("Student doesn't saved.", caption: "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    if (Save.Text == @"Update")
                    {
                        var message = await client.UpdateAsync("StudentList/" + student.Id, student);

                        if (message != null)
                        {
                            MessageBox.Show("Student Updated Successfully.", caption: "Save", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Reset();
                            GetAllStudent();
                            Save.Text = "Save";
                        }
                        else
                        {
                            MessageBox.Show("Student doesn't Updated.", caption: "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Please check your Internet connection !!!", caption: "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.Close();
                }
            }
        }