예제 #1
0
        public Task <HttpResponseMessage> Post([FromBody] dynamic body)
        {
            HttpResponseMessage response = new HttpResponseMessage();

            var command = new RegisterUserCommand(
                fullName: (string)body.fullName,
                username: (string)body.username,
                email: (string)body.email,
                password: (string)body.password,
                confirmpass: (string)body.confirmPass
                );

            _service.Register(command);
            _service.Authenticate("andrebaltieri", "123456");

            if (_notification.HasNotifications())
            {
                foreach (var item in _notification.Notify())
                {
                    ModelState.AddModelError("", item.Value);
                }

                response = Request.CreateResponse(HttpStatusCode.BadRequest, _notification.Notify());
            }
            else
            {
                response = Request.CreateResponse(HttpStatusCode.OK, command);
            }

            var tsc = new TaskCompletionSource <HttpResponseMessage>();

            tsc.SetResult(response);
            return(tsc.Task);
        }