Esempio n. 1
0
        public ActionResult <List <QuoteGetDto> > Get()
        {
            var quotes = _myService.GetAll();
            var res    = new List <QuoteGetDto>();

            foreach (var q in quotes)
            {
                var user     = _userService.GetById(q.AuthorId);
                var category = _categoryService.GetById(q.CategoryId);

                var qgetdto = new QuoteGetDto
                {
                    Id       = q.Id,
                    Quote    = q.Quote,
                    Category = new CategoryGetDto {
                        Id = category.Id, Name = category.Name
                    },
                    User = new UserGetDto {
                        Id = user.Id, Username = user.Username, Email = user.Email
                    }
                };

                res.Add(qgetdto);
            }

            return(res);
        }