protected virtual async Task <dynamic> getCustomerInfo() { string userId = User.Identity.GetUserId(); User user = await UserManager.FindByIdAsync(userId); if (user == null) { return(null); } List <CustomerInfo> customerInfos = new List <CustomerInfo>(); List <Hotel> hotels = await YummyOnlineManager.GetHotels(); foreach (Hotel h in hotels) { HotelManager hotelManager = new HotelManager(h.ConnectionString); HotelDAO.Models.Customer customer = await hotelManager.GetCustomer(userId); if (customer == null) { continue; } customerInfos.Add(new CustomerInfo { Hotel = new { h.Id, h.Name }, Points = customer.Points, VipLevel = customer.VipLevel == null ? null : new { customer.VipLevel.Id, customer.VipLevel.Name }, DinesCount = await hotelManager.GetHistoryDinesCount(userId) }); } return(new { user.Id, user.Email, user.PhoneNumber, user.UserName, CustomerInfos = customerInfos }); }
protected override async Task <dynamic> getCustomerInfo() { string userId = User.Identity.GetUserId(); User user = await UserManager.FindByIdAsync(userId); if (user == null) { return(null); } HotelDAO.Models.Customer customer = await HotelManager.GetOrCreateCustomer(userId); return(new { user.Id, user.Email, user.PhoneNumber, user.UserName, customer.Points, customer.VipLevelId, DinesCount = await HotelManager.GetHistoryDinesCount(userId) }); }