public List <PaymentViewModel> GetPayments(string list = "user", bool range = false, int from = 0, int to = 0) { string id = User.Identity.GetUserId(); List <Payment> data; int total; if (User.IsInRole("Admin") && list == "all") { data = _payments.All(out total, from, to); } else { data = _payments.AllByUser(id, out total, from, to); } if (range) { Request.Headers.Add("X-Range-Total", total.ToString()); } var result = data.Select(p => new PaymentViewModel() { Id = p.Id, Sum = p.Sum, UserId = p.UserID, Date = p.Date, UserName = UserManager.FindById(p.UserID).UserName, }); return(result.ToList()); }
public async Task <List <PaymentDTO> > All() { var items = await _paymentRepository.All(); return(_mapper.Map <List <PaymentDTO> >(items)); }