public List <SpendingDto> Get()
        {
            var spendings = _spendingRepos.GetAll()
                            .Include(x => x.Category)
                            .Include(x => x.Tags);

            var claim  = HttpContext.User.Claims;
            var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

            var result = spendings
                         .Where(x => x.UserId == userId)
                         .Select(x => new SpendingDto
            {
                Description = x.Description,
                Value       = x.Value,
                Date        = x.Date,
                Id          = x.Id,
                Category    = x.Category.Name,
                Tags        = x.Tags.Select(t => t.Tag.Name).ToList()
            }).ToList();

            return(result);
        }
Example #2
0
        public List <DriverData> GetAllDrivers()
        {
            List <DriverData> drivers = _repo.GetAll().ToList();

            return(drivers);
        }