public IActionResult RequestLeave([FromBody] RequestLeave request) { var userName = SecurityInfo.GetUserIdentity(User); var command = new RequestLeaveCommand( userName, request.LeftDate); _bus.Send(command); var id = command.RequestId; return(CreatedAtRoute("GetRequestLeave", new { id }, id)); }
public void Handle(RequestLeaveCommand message) { var request = MapUtil.Map <RequestLeaveCommand, SchedulingRequest>(message); var response = _schedulingRepository.CreateScheduledingFromRequest(request); if (!response.Success) { var rejected = new ScheduleRequestRejectedEvent(request.Id.ToString(), response.Description); Bus.RaiseEvent(rejected); return; } message.RequestId = response.RequestId.ToString(); var leaveRequest = LeaveRequest.Factory.Create( response.AggregateId, request.RequestedBy, request.EndDate); var created = MapUtil.Map <LeaveRequest, ScheduleCreatedEvent>(leaveRequest); Bus.RaiseEvent(created); }