コード例 #1
0
        public IActionResult Post([FromBody] LoginUser loginUser)
        {
            try
            {
                if (loginUser.Password == null || loginUser.Password.Length < 1)
                {
                    ModelState.AddModelError("Password", "비밀번호를 입력해야 합니다");
                }

                //모델 유효성 검사
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState)); //400에러 출력
                }

                var m = loginUserService.AddLoginUser(loginUser);
                return(CreatedAtRoute("GetLoginUserById", new { id = m.Id }, m)); //201
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }