Exemplo n.º 1
0
        public async Task <Guid> Create(CreateUser request)
        {
            // To do - Make the necessary repository/domain behavior calls
            // Publish the event
            UserCreated domainEvent = new UserCreated()
            {
                Id        = Guid.NewGuid(),
                FirstName = request.FirstName,
                LastName  = request.LastName,
                Tenant    = request.Tenant
            };
            await MessagingClient.PublishMessage(JsonConvert.SerializeObject(domainEvent), request.Tenant);

            return(domainEvent.Id);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> SignupCourseV2(Guid courseId, [FromBody] SignupCourseRequest request)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(StatusCode(StatusCodes.Status400BadRequest));
                }
                var result = await MessagingClient.PublishMessage(new CourseSignupCommand(courseId, request));

                return(Accepted());
            }
            catch (Exception ex)
            {
                // To do - Handle exceptions, log it and throw appropriate errors
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }