Exemplo n.º 1
0
        public async Task <ActionResult> CreateFriend(int Userid, int Friendid)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ApiCommonResponse {
                    Status = false
                }));
            }

            try
            {
                var newUser = await _FriendListRepository.InsertFriendAsync(Userid, Friendid);

                if (newUser == null)
                {
                    return(BadRequest(new ApiCommonResponse {
                        Status = false
                    }));
                }
                return(CreatedAtAction("GetFriendRoute", new { id = newUser.UserId },
                                       new ApiCommonResponse {
                    Status = true, id = newUser.UserId
                }));
            }
            catch (Exception exp)
            {
                _Logger.LogError(exp.Message);
                return(BadRequest(new ApiCommonResponse {
                    Status = false
                }));
            }
        }
        public async Task <ActionResult> CreateFriend(int id, string userName, string email)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new ApiCommonResponse {
                    Status = false
                }));
            }

            try
            {
                var newUser = await _FriendListRepository.InsertFriendAsync(id, userName, email);

                if (newUser == null)
                {
                    return(BadRequest(new ApiCommonResponse {
                        Status = false
                    }));
                }
                if (newUser.UserId != 0)
                {
                    return(CreatedAtAction("GetFriendRoute", new { id = newUser.UserId },
                                           new ApiCommonResponse {
                        Status = true, id = newUser.FriendListId
                    }));
                }
                else
                {
                    return(BadRequest(new ApiCommonResponse {
                        Status = false, id = 0
                    }));
                }
            }
            catch (Exception exp)
            {
                _Logger.LogError(exp.Message);
                return(BadRequest(new ApiCommonResponse {
                    Status = false
                }));
            }
        }