public IActionResult CreateFriend([FromBody] FriendInputModel body)
        {
            if (!ModelState.IsValid)
            {
                throw new ModelFormatException("Model not properly formatted");
            }
            var entity = _friendService.CreateFriend(body);

            return(CreatedAtRoute("GetFriendById", new { userId = entity.Id }, null));
        }
Пример #2
0
        public ActionResult <FriendDto> PostFriend(CreateFriendRequest request)
        {
            var newFriend = new FriendEntity()
            {
                Name = request.Name
            };

            var Friend = _friendService.CreateFriend(newFriend);

            return(CreatedAtAction("GetFriend", new { id = Friend.Id }, Friend));
        }
Пример #3
0
        public void TestCreateFriend()
        {
            var objTest = new FriendEntity()
            {
                Name = "Name test"
            };

            var result = _friendService.CreateFriend(objTest);

            Assert.NotNull(result);
            Assert.True(result.Id != default);
            Assert.Equal(result.Name, objTest.Name);
        }