示例#1
0
        public UnSubcribeToSubResponse Handle(UnSubcribeToSub command)
        {
            var response = new UnSubcribeToSubResponse();

            try
            {
                var sub = _subService.GetSubByName(command.SubName);

                if (sub == null)
                {
                    response.Error = "No sub found with the given name";
                    return(response);
                }

                _subService.UnSubscribeToSub(command.UserId, sub.Id);

                _eventBus.Publish(new SubScriptionChanged
                {
                    Unsubscribed = true,
                    UserId       = command.UserId,
                    SubId        = sub.Id
                });

                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Error = ex.Message;
                return(response);
            }

            return(response);
        }