コード例 #1
0
        public ICollection <RequestsDTO> GetRequests()
        {
            var requests = _repo.List();

            var allRequests = new List <RequestsDTO>();

            foreach (var request in requests)
            {
                var bar        = _barRepo.GetBarById(request.BarId);
                var user       = _repo.GetUserById(request.UserId);
                var requestDTO = new RequestsDTO
                {
                    Id            = request.Id,
                    UserName      = user.UserName,
                    UserEmail     = user.Email,
                    PhoneNumber   = bar.PhoneNumber,
                    BarName       = bar.Name,
                    DateRequested = request.DateRequested
                };

                allRequests.Add(requestDTO);
            }
            return(allRequests);
        }