Exemplo n.º 1
0
        public IActionResult Put(string username)
        {
            if (string.IsNullOrEmpty(username))
            {
                return(BadRequest());
            }

            var userBlocked = m_UserRepository.GetByUserName(username);

            if (userBlocked == null)
            {
                return(NotFound(ResponseFactory.CreateResponse("User Not Found")));
            }

            var blocking = m_ModelFactory.CreateBlocking(CurrentUser.UserID, userBlocked.UserID);

            if (TryValidateModel(blocking))
            {
                m_BlockingRepository.Insert(blocking);
            }
            else
            {
                return(BadRequest(ResponseFactory.CreateResponse(ModelState)));
            }

            return(Ok());
        }