示例#1
0
        public async Task <EventViewmodel> Find(Guid eventUuid, UserHelper requestingUser)
        {
            if (eventUuid == Guid.Empty)
            {
                throw new UnprocessableException();
            }

            EventDto dbEvent = await _eventDal.Find(eventUuid);

            if (dbEvent == null)
            {
                throw new KeyNotFoundException();
            }

            var         mappedEvent        = _mapper.Map <EventViewmodel>(dbEvent);
            List <Guid> userUuidCollection = GetUserUuidsFromEvent(mappedEvent);

            var usersFromUserService = _rpcClient.Call <List <UserRabbitMq> >(userUuidCollection, RabbitMqQueues.FindUserQueue);

            AddUsernamesToEventDate(requestingUser, mappedEvent, usersFromUserService);
            AddUsernamesToEventSteps(requestingUser, mappedEvent, usersFromUserService);

            mappedEvent.CanBeRemoved = dbEvent.AuthorUuid != Guid.Empty &&
                                       dbEvent.AuthorUuid == requestingUser.Uuid;
            return(mappedEvent);
        }