Esempio n. 1
0
        public IHttpActionResult AcceptRequest(string Sender, string Reciver)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            db.accept_friend_request(Reciver, Sender);
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!friendExists(Sender))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> AcceptRequest(string Sender, string Reciver)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            db.accept_friend_request(Reciver, Sender);
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!friendExists(Sender, Reciver))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            var new_notifi = new cls_notifi
            {
                source_name  = "user",
                source_id    = Reciver,
                image        = db.AspNetUsers.FirstOrDefault(x => x.Id == Reciver).Photo,//"no image",
                body_English = db.AspNetUsers.FirstOrDefault(x => x.Id == Reciver).UserName + " accepted your friend request",
                body_Arabic  = "تم قبول طلب صداقتك من قبل " + db.AspNetUsers.FirstOrDefault(x => x.Id == Reciver).UserName,
                timestamp    = DateTime.Now,
                readed       = false
            };

            await Push(new_notifi, "notifications/" + Sender.ToString() + "/" + DateTime.UtcNow.ToString("dd-MM-yyyy"));

            PushNotifi(db.AspNetUsers.FirstOrDefault(x => x.Id == Sender.ToString()).DeviceToken, "Friend Request Accepted", new_notifi.body_English, "user", Reciver);

            //RedirectToRoute("/rpc/notifi/push/", new { notifi = new_notifi, path = "notifications/" + Sender.ToString() + "/friends" });
            return(StatusCode(HttpStatusCode.NoContent));
        }