示例#1
0
        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."));
        }
示例#2
0
        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");
        }
示例#3
0
        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"));
        }
示例#4
0
        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());
        }