Example #1
0
        public async Task <IActionResult> LikeUser(int id, int recipientId)
        {
            if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }
            var like = await _repo.GetLike(id, recipientId);

            if (like != null)
            {
                return(BadRequest("Tu as déja liké ce membre"));
            }
            if (await _repo.GetUser(recipientId) == null)
            {
                return(NotFound());
            }
            like = new Like
            {
                LikerId = id,
                LikeeId = recipientId
            };
            _repo.Add <Like>(like);
            if (await _repo.SaveAll())
            {
                return(Ok());
            }
            return(BadRequest(" Like échoué "));
        }
Example #2
0
        public async Task <IActionResult> LikeUser(int id, int recipientId)
        {
            if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }
            var like = await _repo.GetLike(id, recipientId);

            if (like != null)
            {
                return(BadRequest("لقد قمت بالاعجاب بهذا المشترك من قبل"));
            }
            if (await _repo.GetUser(recipientId, false) == null)
            {
                return(NotFound());
            }
            like = new Like
            {
                LikerId = id,
                LikeeId = recipientId
            };
            _repo.Add <Like>(like);
            if (await _repo.SaveAll())
            {
                return(Ok());
            }
            return(BadRequest("فشل الاعجاب"));
        }
Example #3
0
        public async Task <IActionResult> LikeUser(int id, int recipientId)
        {
            if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var like = await _repo.GetLike(id, recipientId);

            if (like != null)
            {
                return(BadRequest("this user likee By this user Before"));
            }
            var userFromRepo = await _repo.GetUser(recipientId);

            if (userFromRepo == null)
            {
                return(NotFound("this user recipient is not found in data base"));
            }

            like = new Like
            {
                LikerId = id,
                LikeeId = recipientId
            };
            _repo.Add <Like>(like);
            if (await _repo.SaveAll())
            {
                return(Ok("Save user Like sccuss"));
            }
            return(BadRequest("Save user Like Error"));
        }