public async Task <GoogleMapDTO> Add(GoogleMapDTO cateringFacility) { var uri = _api.GetMaps(); var request = new HttpRequestMessage(HttpMethod.Post, uri); request.Content = new StringContent(System.Text.Json.JsonSerializer.Serialize(cateringFacility)); request.Content.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json"); var client = _httpClientFactory; client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = await client.SendAsync(request); // GoogleMapDTO locations = null; //if (response.IsSuccessStatusCode) //{ // var responseStream = await response.Content.ReadAsStringAsync(); // qRCodes = JsonConvert.DeserializeObject<QRDataCatering>(responseStream); //} //Checking the response is successful or not which is sent using HttpClient //TODO STO VRATITI AKO UPIT BUDE NEUSPIJESAN "Umjesto Exception" return(response.IsSuccessStatusCode ? JsonConvert.DeserializeObject <GoogleMapDTO>(await response.Content.ReadAsStringAsync()) : throw new Exception("Error cancelling order, try later.")); }
public async Task <ActionResult> SingleFile(GoogleMapDTO file) { var QRImage = await _QRCodeSvc.GetQRImage(file); // ReturnFileFromBitmap(); //Isto kao sto bi se inace vratio View, na ovaj nacin pretrazivac izbaci sirovi file(u ovom slucaju QR kod) return(File(QRImage.QRImageInBytes, System.Net.Mime.MediaTypeNames.Application.Octet, "MyQRCode.jpg")); //return RedirectToAction("Index"); }
public async Task <ActionResult> Create (CatererViewModel model) { if (ModelState.IsValid) { var newLocation = new GoogleMapDTO { Address = model.Address, Lat = model.Lat, Long = model.Long }; var userID = _userManager.GetUserId(User); var newCaterer = new CatererDTO { CatererID = userID, Address = model.Address, Lat = model.Lat, Long = model.Long, CateringFacilitiName = model.CateringFacilitiName, CatererName = model.CatererName }; newLocation = await _GoogleMapSvc.Add(newLocation); var IDCateringFacility = await _CatererSvc.PostCaterer(newCaterer); List <Item> itemList = await _ExcelSvc.Get(model.FormDocument, IDCateringFacility); await _ItemSvc.PostItem(itemList); var QRImage = await _QRCodeSvc.GetQRImage(newLocation); return(File(QRImage.QRImageInBytes, System.Net.Mime.MediaTypeNames.Application.Octet, "MyQRCode.jpg")); } return(View("Index")); }
public IActionResult Create (GoogleMapsCreateViewModel model) { if (ModelState.IsValid) { var newLocation = new GoogleMapDTO { Address = model.Address, Lat = model.Lat, Long = model.Long }; _GoogleMapSvc.Add(newLocation); return(RedirectToAction("Index", "GoogleMaps")); } return(View()); }