public async Task<ActionResult> Search(int? typeId, bool? outgoing) { ViewBag.AppName = Startup.App.Name; var m = new ContactsQueryOpts { UserId = User.Identity.GetUserId(), TypeId = typeId == null ? -1 : typeId.Value, Outgoing = outgoing == null ? true : outgoing.Value }; await PopulateTypes(m); return View(m); }
private async Task PopulateTypes(ContactsQueryOpts m) { List<ContactType> l = new List<ContactType>(); var types = await ContactContext.ListTypes(); foreach (var type in types) { var t = new ContactType { Id = type.ID, Name = type.TypeName // map it to a more user friendly name later. }; l.Add(t); } m.Types = l.ToArray(); }