//async Task<IEnumerable<AppUserIndexViewMode>> GetAppUserIndexViewModel() //{ // return appusers; //} public async Task <IActionResult> Index() { var appusers = new List <AppUserIndexViewMode>(); foreach (var user in _userManager.Users) { var vm = new AppUserIndexViewMode { Id = user.Id, Email = user.Email, Password = user.PasswordHash }; if (user.VolunteerId != null) { var ss = await _context.GetVolunteerForIndex(user.VolunteerId.Value); vm.VIdName = ss; } if (user.AppRoleId != null) { vm.Role = _roleManager.FindByIdAsync(user.AppRoleId.ToString()).Result.Name; } appusers.Add(vm); } return(View(appusers)); }
// GET: Orders public async Task <IActionResult> Index() { // var bellyful_v03Context = _context.Order.Include(o => o.Recipient).Include(o => o.Status).Include(o => o.Volunteer); // return View(await bellyful_v03Context.ToListAsync()); var ordersVMs = new List <OrderIndexViewModel>(); foreach (var o in _context.Order) { var vm = new OrderIndexViewModel { OrderId = o.OrderId }; if (o.CreatedDatetime != null) { vm.PlacedTime = o.CreatedDatetime; } if (o.AssignDatetime != null) { vm.AssignedTime = o.AssignDatetime; } if (o.PickupDatetime != null) { vm.PickedUpTime = o.PickupDatetime; } if (o.DeliveredDatetime != null) { vm.DeliveredTime = o.DeliveredDatetime; } if (o.StatusId != null) { vm.StatusId = o.StatusId.Value; } if (o.VolunteerId != null) { var ss = await _context.GetVolunteerForIndex(o.VolunteerId.Value); vm.VIdName = ss; } vm.RIdName = await _context.GetRecipientForIndex(o.RecipientId); if (o.StatusId != null) { vm.Status = _context.OrderStatus.FindAsync(o.StatusId.Value).Result.Content; } ordersVMs.Add(vm); } ordersVMs.Sort(); return(View(ordersVMs)); }
public async Task <IActionResult> MyOrdersIndex(string name) { if (name == null) { return(NotFound()); } var appuser = await _userManager.FindByEmailAsync(name); var ordersVMs = new List <OrderIndexViewModel>(); if (appuser != null) { foreach (var o in _context.Order) { if (o.VolunteerId == appuser.VolunteerId) { var vm = new OrderIndexViewModel { OrderId = o.OrderId }; var r = await _context.Recipient.FindAsync(o.RecipientId); if (r != null) { vm.TheRecipientAddress = r.AddressNumStreet; if (r.DogOnProperty != null) { vm.TheRecipientDogOnProperty = r.DogOnProperty.Value; } vm.RIdName = r.FirstName + "" + r.LastName; } if (o.CreatedDatetime != null) { vm.PlacedTime = o.CreatedDatetime; } if (o.AssignDatetime != null) { vm.AssignedTime = o.AssignDatetime; } if (o.PickupDatetime != null) { vm.PickedUpTime = o.PickupDatetime; } if (o.DeliveredDatetime != null) { vm.DeliveredTime = o.DeliveredDatetime; } if (o.StatusId != null) { vm.StatusId = o.StatusId.Value; } if (o.VolunteerId != null) { var ss = await _context.GetVolunteerForIndex(o.VolunteerId.Value); vm.VIdName = ss; } if (o.StatusId != null) { vm.Status = _context.OrderStatus.FindAsync(o.StatusId.Value).Result.Content; } ordersVMs.Add(vm); } } } ordersVMs.Sort(); return(View(ordersVMs)); }