Example #1
0
        public IActionResult Create([FromBody] FriendInputModel inputModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var friend = new Friend
            {
                FirstName = inputModel.FirstName,
                LastName  = inputModel.LastName,
                Email     = inputModel.Email,
                Phone     = inputModel.Phone,
                Address   = inputModel.Address,
            };

            FriendsService.Create(friend);
            return(CreatedAtAction(nameof(GetSingle), new { id = friend.Id }, friend.ToDto()));
        }