Пример #1
0
        public void Put()
        {
            string usname        = this.HttpContext.Request.Headers["Username"];
            string idProposition = this.HttpContext.Request.Headers["idProposition"];
            string answer        = this.HttpContext.Request.Headers["answer"];

            if (usname != null && idProposition != null && answer != null)
            {
                _friendsService.CreateFriend(Convert.ToInt32(idProposition), Convert.ToBoolean(answer));
            }
        }
Пример #2
0
        public IActionResult CreateFriend([FromBody] CreateFriendDTO createFriendDTO)
        {
            if (!ModelState.IsValid)
            {
                return(StatusCode(400, "bad data!"));
            }

            try
            {
                Friend friend = _friendService.CreateFriend(createFriendDTO);
                return(Ok(friend));
            }
            catch (APIException e)
            {
                ErrorMessage error = new ErrorMessage {
                    message = e.Message
                };
                return(StatusCode(e.StatusCode, error));
            }
        }