Пример #1
0
        public async Task <ActionResult> FindByUsername(string username)
        {
            var result = await userFinder.Handle(new FindByValueParams <string>(username, user : User));

            return(result.Match <ActionResult>(
                       user => user != null ? Ok(user) : NotFound() as ActionResult,
                       fail => BadRequest(fail)
                       ));
        }
Пример #2
0
        public async Task <ActionResult> FindByUsername(string username)
        {
            // When checking for username availability, see if the username is banned first.
            if (Request.Method.Equals("HEAD") && User.IsUsernameBanned(username))
            {
                return(BadRequest("Username is unavailable"));
            }

            var result = await userFinder.Handle(new FindByValueParams <string>(username, user : User));

            return(result.Match <ActionResult>(
                       user => user != null ? Ok(user) : NotFound() as ActionResult,
                       fail => BadRequest(fail)
                       ));
        }