public async Task <IActionResult> InviteFriend(string UserID, string FriendEmail)
        {
            try
            {
                //string url = $"{http://localhost:3000/Registration}";
                var user = await _userManager.FindByIdAsync(UserID);

                if (user == null)
                {
                    return(BadRequest(new { message = "There is no user." }));
                }


                await _emailService.SendEmailAsync(FriendEmail, "E-commerce", "<h1>Your friend " + user.FirstName + " " + user.LastName + " invite you to join us</h1>" +
                                                   $"<p>To send  your friend coupon please <a href='https://www.customer.app.fit.ba/Registration'> Register</a></p>");

                _friendService.AddFriend(UserID, FriendEmail);

                return(Ok("You invite your friend"));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public ActionResult AddFriend(int id)
        {
            var userId = _userService.GetUserByLogin(Thread.CurrentPrincipal.Identity.Name).Id;

            _friendService.AddFriend(userId, id);

            return(new EmptyResult());
        }
Beispiel #3
0
 public Friend AddFriend(int userId, int friendId)
 {
     return(_friendService.AddFriend(new Friend
     {
         Approved = 0,
         FirstFriend = userId,
         SecondFriend = friendId
     }));
 }
Beispiel #4
0
 public async Task <IActionResult> Post([FromBody] FriendListDto friend)
 {
     try
     {
         return(Ok(await _friendService.AddFriend(_mapper.Map <FriendList>(friend))));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.ToString()));
     }
 }
        public async Task <IResult> HandleAsync(AddFriendCommand command)
        {
            var validationResult = await IsValidAsync(command);

            if (validationResult.HasFailed())
            {
                return(validationResult);
            }

            await _friendService.AddFriend(command.CurrentUserId, command.UserId);

            return(Result.Success());
        }
Beispiel #6
0
        public async Task <IActionResult> AddFriend([FromBody] FriendDto friendToAdd)
        {
            if (friendToAdd.Nickname == null)
            {
                return(BadRequest("The nickname is mandatory!"));
            }
            var result = await _friendService.AddFriend(friendToAdd);

            if (!result.Succeeded)
            {
                return(BadRequest(result));
            }

            return(Ok(result));
        }
        public IActionResult AddFriend(int id, FriendRelationship friendRelationship)
        {
            try
            {
                friendRelationship.UserId = id;
                FriendRequestAddedDTO friendRequest = friendService.AddFriend(friendRelationship);

                if (friendRequest == null)
                {
                    return(NotFound("La amistad entre los usuarios ya existe."));
                }

                return(Ok(friendRequest));
            }
            catch (DbUpdateException)
            {
                return(NotFound());
            }
        }
Beispiel #8
0
 /// <summary>
 /// 添加好友
 /// </summary>
 /// <param name="managerId"></param>
 /// <param name="name"></param>
 /// <param name="hasTask"></param>
 /// <returns></returns>
 public MessageCodeResponse AddFriend(Guid managerId, string name, bool hasTask)
 {
     return(proxy.AddFriend(managerId, name, hasTask));
 }