public async Task <MembershipResponse> PostMembership(PostMembershipRequest postMembershipRequest) { //We suppose we saved user's data MembershipResponse membershipResponse = _mapper.Map <MembershipResponse>(postMembershipRequest); MembershipStartedEvent membershipStartedEvent = new MembershipStartedEvent { Id = Guid.NewGuid(), MembershipResponse = membershipResponse }; _appDbContext.Messages.Add(new Model.Message { Id = membershipStartedEvent.Id, Type = membershipStartedEvent.GetType().ToString(), Content = JsonConvert.SerializeObject(membershipStartedEvent), CreatedOn = DateTime.UtcNow }); await _appDbContext.SaveChangesAsync(); await _busControl.Publish(membershipStartedEvent); return(membershipResponse); }
public async Task <IActionResult> Post([FromBody] PostMembershipRequest popstMembershipRequest) { var result = await _membershipService.PostMembership(popstMembershipRequest); return(Ok(result)); }