private SuperadminCustomerCard GetSuperadminCustomerCard(User user) { var problems = ProblemService.GetUserProblems(user); var sessions = SessionService.GetUserSessions(user) .Select(session => GetSpecialistSession(session)) .ToList(); return(new SuperadminCustomerCard { UserID = user.ID, FullName = $"{user.FirstName} {user.LastName}", PhoneNumber = user.PhoneNumber, Role = user.Role, Sessions = sessions, ProblemsCount = problems.Count, SpendOrEarned = sessions .Where(session => session.SessionStatus == SessionStatus.Success) .ToList() .Sum(session => session.Reward), RefundsCount = sessions .Where(session => session.SessionStatus == SessionStatus.Refund) .ToList() .Count }); }
public IActionResult GetCustomer(long userID) { var user = UserService.Get(userID); if (user == null) { return(NotFound(new ResponseModel { Success = false, Message = "Пользователь не найден" })); } var problems = ProblemService.GetUserProblems(user); var sessions = SessionService.GetUserSessions(user) .Select(session => GetSpecialistSession(session)) .ToList(); return(Ok(new DataResponse <SuperadminCustomerCard> { Data = new SuperadminCustomerCard { UserID = user.ID, FullName = $"{user.FirstName} {user.LastName}", PhoneNumber = user.PhoneNumber, Role = user.Role, Sessions = sessions, ProblemsCount = problems.Count, SpendOrEarned = sessions .Where(session => session.SessionStatus == SessionStatus.Success) .ToList() .Sum(session => session.Reward), RefundsCount = sessions .Where(session => session.SessionStatus == SessionStatus.Refund) .ToList() .Count } })); }