public async Task <ActionResult <Tuple <double, string, string, string, IEnumerable <Contact> > > > Get() { var result = await Repository.GetItemsAsync(c => true, c => new Contact { LastName = c.LastName, FirstName = c.FirstName, Email = c.Email, Phone = c.Phone, Company = c.Company, ContactType = c.ContactType }); return(new Tuple <double, string, string, string, IEnumerable <Contact> >(result.Item1, result.Item2, result.Item3, result.Item4, result.Item5.OrderBy(c => c.LastName))); }
private async void LoadLookupAsync() { var items = await LookupRepository.GetItemsAsync(c => true); if (items.Item5.Count() == 0) { await LookupRepository.CreateItemAsync(new Lookup { Area = "Type", Key = "Contact", Value = "Contact" }); await LookupRepository.CreateItemAsync(new Lookup { Area = "Type", Key = "Customer", Value = "Customer" }); await LookupRepository.CreateItemAsync(new Lookup { Area = "Type", Key = "Lead", Value = "Lead" }); } }
public async Task <IActionResult> Index() { // Optimization: Don't get the notes to minimize the payload var result = await Repository.GetItemsAsync ( c => c.ContactType == DefaultContactType, c => new Contact { Id = c.Id, Company = c.Company, FirstName = c.FirstName, LastName = c.LastName, Phone = c.Phone, Email = c.Email }, DefaultContactType.ToString() ); ViewBag.Area = Constants.ContactList; ViewBag.TotalRUs = result.Item1; ViewBag.ReadEndpoint = result.Item2; ViewBag.WriteEndpoint = result.Item3; ViewBag.ConsistencyLevel = result.Item4; return(View(result.Item5.ToList().OrderBy(c => c.LastName))); }
public async Task <IActionResult> Index() { // Execute a cross partition query // Demo: compare getting all the properties vs not all the properties var result = await Repository.GetItemsAsync(c => true, c => new Contact { LastName = c.LastName, FirstName = c.FirstName, Email = c.Email, Phone = c.Phone, Company = c.Company, ContactType = c.ContactType }); //var result = await Repository.GetItemsAsync(c => true); ViewBag.TotalRUs = result.Item1; ViewBag.ReadEndpoint = result.Item2; ViewBag.WriteEndpoint = result.Item3; ViewBag.ConsistencyLevel = result.Item4; return(View(result.Item5.ToList().OrderBy(c => c.LastName))); }
public async Task <IActionResult> Index() { // Create the lookup data once LoadLookupAsync(); // Load the session data await HttpContext.Session.LoadAsync(); // Try to get the data from sessions var json = HttpContext.Session.GetString(CustomerTypes); if (json == null) { // If it does not exists add it customerTypes = (await LookupRepository.GetItemsAsync(c => true)).Item5; HttpContext.Session.SetString(CustomerTypes, JsonConvert.SerializeObject(customerTypes)); ViewData["CustomerTypes"] = null; } else { // Deserialize the json back to a .Net object from cache customerTypes = JsonConvert.DeserializeObject <IEnumerable <Lookup> >(json); ViewData["CustomerTypes"] = customerTypes; } var readCharge = CosmosCache.LastReadCharge; var lastWriteCharge = CosmosCache.LastWriteCharge; // Execute a cross partition query // Demo: compare getting all the properties vs not all the properties var result = await Repository.GetItemsAsync(c => true, c => new Contact { LastName = c.LastName, FirstName = c.FirstName, Email = c.Email, Phone = c.Phone, Company = c.Company, ContactType = c.ContactType }); //var result = await Repository.GetItemsAsync(c => true); ViewBag.TotalRUs = result.Item1; ViewBag.ReadEndpoint = result.Item2; ViewBag.WriteEndpoint = result.Item3; ViewBag.ConsistencyLevel = result.Item4; return(View(result.Item5.ToList().OrderBy(c => c.LastName))); }