public IActionResult Index() { ReportViewModel model = new ReportViewModel(); model.RemoveNulls(); return(View(model)); }
public async Task <IActionResult> FetchReport(ReportViewModel model) { model.RemoveNulls(); // Set values based on if the blob is ready or not. if (await _cloudBlobService.IsBlobReady(HttpContext.Session.GetString("blob_name"))) { model.SasUri = HttpContext.Session.GetString("sas_uri"); model.FetchMessage = "Fetched!"; } else { model.FetchMessage = "Blob not ready yet... try again later."; } return(View("Index", model)); }
public async Task <IActionResult> GenerateReport(ReportViewModel model) { model.RemoveNulls(); // No location passed if (string.IsNullOrEmpty(model.Location)) { model.GenerateMessage = $"Empty location input... please input valid location."; return(View("Index", model)); } // Location not found if (mapServices.SearchAddress(model.Location) == null) { model.GenerateMessage = $"Couldn't find address for location: {model.Location}. Please try again with a different location."; return(View("Index", model)); } // Prepare the queue command var queueCommand = new GenerateBeerReportCommand() { BlobName = model.Location + _cloudBlobService.GetRandomBlobName(model.Location + ".png"), Location = model.Location }; // Get and save the sas uri so we can access the blob once it's done string sasUri = await _cloudBlobService.GetBlobSasUri(queueCommand.BlobName); HttpContext.Session.SetString("sas_uri", sasUri); HttpContext.Session.SetString("blob_name", queueCommand.BlobName); // Send to the queue await _queueCommunicator.SendAsync(queueCommand); model.GenerateMessage = $"Thank you. Request for beer report in {model.Location} will be added to queue."; return(View("Index", model)); }