public List <OrderVM> GetAllOrders() { var orders = _orderRepo.GetAll(); var ordersViewModelList = OrderMapper.MapOrdersToOrderVM(orders); return(ordersViewModelList); }
public List <OrderVM> GetAllOrdersByUserId(int userId) { var user = _userRepo.GetById(userId); if (user == null) { throw new UserNotFoundException("User with thad Id doesn't exist."); } var userOrders = user.Orders; var userOrdersViewModelList = OrderMapper.MapOrdersToOrderVM(userOrders); return(userOrdersViewModelList); }