Exemplo n.º 1
0
        public IActionResult DownloadQRCode(QRCodeViewModel qrCode)
        {
            var venueId = qrCode.VenueId;

            try
            {
                var venue = this._venueService.GetVenueById(venueId);

                if (venue == null)
                {
                    throw new Exception("venue was not found");
                }

                var qrCodeFilePath = venue.QRCodeImageUrl;

                var qrCodeFileName = System.IO.Path.GetFileName(qrCodeFilePath);

                var fullFilePath = Path.Combine(Globals.QRCODE_DIR, qrCodeFileName);

                var bytes = System.IO.File.ReadAllBytes(fullFilePath);

                string contentType = "application/jpeg";

                return(File(bytes, contentType, qrCodeFileName));
            }
            catch (System.Exception ex)
            {
                this._logger.LogError(ex.StackTrace);
                TempData["Error"] = ex.Message;

                return(RedirectToAction("QRCode", new { id = venueId }));
            }
        }
Exemplo n.º 2
0
        public IActionResult QRCode(string id)
        {
            var qrCode = new QRCodeViewModel();

            try {
                if (id == null)
                {
                    throw new Exception("The venue cannot be found");
                }

                var venue = this._venueService.GetVenueById(Guid.Parse(id));

                if (venue == null)
                {
                    throw new Exception("The venue cannot be found");
                }

                qrCode.ImageUrl = venue.QRCodeImageUrl;
                qrCode.VenueId  = venue.Id;

                if (TempData["Error"] != null)
                {
                    ViewBag.Error = TempData["Error"] as string;
                }
            }
            catch (Exception ex) {
                this._logger.LogError(ex.StackTrace);
                ModelState.AddModelError("Error", ex.Message);
            }

            return(View(qrCode));
        }
Exemplo n.º 3
0
 public QRCodePage()
 {
     InitializeComponent();
     //AddImage(PlaceHolder, "NottCS.Images.example-background.jpg");
     BindingContext = new QRCodeViewModel();
     //AddImage(Back, "NottCS.Images.Icons.back.png");
 }
        public QRCodePage(Wellness.Model.Requests.ClanViewRequest clan)
        {
            InitializeComponent();

            _clan = clan;

            BindingContext = new QRCodeViewModel(clan);
        }
Exemplo n.º 5
0
        public ActionResult ShowQR(int id)
        {
            var model     = this.CardCoupon.GetCardCounpon(id);
            var qrcode    = this.CardCoupon.CreateQRCode(model.WxNo);
            var viewModel = new QRCodeViewModel()
            {
                QRCodeUrl = qrcode.ShowQRCodeUrl
            };

            return(View(viewModel));
        }
Exemplo n.º 6
0
 public JsonResultData CreateQRCodeRaw(QRCodeViewModel paramsdata)
 {
     try
     {
         string UrlPath         = HttpContext.Current.Server.MapPath("/BarcodeImg");
         string FullPath        = UrlPath + "\\" + paramsdata.NAME + ".jpg";
         string DomainPath      = ConfigurationManager.AppSettings["hostSetting"] + "BarcodeImg/" + paramsdata.NAME + ".jpg";
         string objectSerialize = string.Format("LAMIPEL ERP\nSelection: {4} {5} \nPallet No: {0} \nLayer: {6} \nNet Weight: {1} KGS \nGross Weight: {2} KGS \nSquare Foot: {7} \nRESA: {3} \nProd.PKL: {8}", paramsdata.NAME, paramsdata.NETWEIGHT, paramsdata.GROSSWEIGHT, paramsdata.RESACODE, paramsdata.SELECTION, paramsdata.SUBSELECTION, paramsdata.HIDE, paramsdata.SQUAREFOOT, paramsdata.CONTAINERID);
         var    qrCodeWriter    = new BarcodeWriter
         {
             Format  = BarcodeFormat.QR_CODE,
             Options = new QrCodeEncodingOptions
             {
                 Margin          = 1,
                 Height          = 200,
                 Width           = 200,
                 ErrorCorrection = ErrorCorrectionLevel.Q,
             },
         };
         var writeableBitmap = qrCodeWriter.Write(objectSerialize);
         var memoryStream    = new MemoryStream();
         writeableBitmap.Save(FullPath);
         string stringRawImgSave = "data:image/*;base64,";
         string stringRawImg     = string.Empty;
         using (Image image = Image.FromFile(FullPath))
         {
             using (MemoryStream m = new MemoryStream())
             {
                 image.Save(m, image.RawFormat);
                 byte[] imageBytes = m.ToArray();
                 stringRawImg = Convert.ToBase64String(imageBytes);
             }
         }
         stringRawImgSave += stringRawImg;
         File.Delete(FullPath);
         return(new JsonResultData
         {
             IsOk = true,
             dataObj = stringRawImgSave,
             dataErr = null,
             Msg = string.Empty
         });
     }
     catch (Exception ex)
     {
         return(new JsonResultData
         {
             IsOk = false,
             dataObj = string.Empty,
             dataErr = ex,
             Msg = ex.ToString()
         });
     }
 }
Exemplo n.º 7
0
 public IActionResult QRCode(QRCodeViewModel model)
 {
     try
     {
         model.ResultString = _qrCodeService.ToQRCodeBase64(model.SourceString);
     }
     catch (Exception e)
     {
         model.ResultString = $"Invalid input! Error message: \r\n{e.Message} \r\n {e.StackTrace}";
     }
     return(View(model));
 }
Exemplo n.º 8
0
        public IActionResult Index(string name, double amount, string pin)
        {
            string imageString = string.Empty;
            var    qrText      = $"{name} Amount: {amount}";

            imageString = IDTPQRCodeGenerator.GenerateQRCode(qrText);

            QRCodeViewModel qRCodeViewModel = new QRCodeViewModel()
            {
                RecipientName = name, Amount = amount, PIN = pin, QRCodeImage = imageString
            };

            return(View(qRCodeViewModel));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> QRCode(int?id)
        {
            try { await UpdateUserAndLocation(id); }
            catch { return(NotFound()); }

            var qrCodeImageAsBase64 = _locationService.GetQrCode(location);

            var model = new QRCodeViewModel()
            {
                QREncodedBase64 = qrCodeImageAsBase64,
                location        = location
            };

            return(View(model));
        }
Exemplo n.º 10
0
        public IHttpActionResult GetQRCode(int id)
        {
            var teacher = this.Data.Teachers.Find(id);

            var dbCode = teacher.QRCodes.FirstOrDefault();

            if (dbCode != null)
            {
                var code = new QRCodeViewModel()
                {
                    Code      = dbCode.Code,
                    TeacherId = dbCode.TeacherId
                };
                return(Ok(code));
            }

            return(NotFound());
        }
Exemplo n.º 11
0
        public IActionResult QRCode(QRCodeViewModel qrCode)
        {
            if (ModelState.IsValid)
            {
                try {
                    var url = Url.Action("Details", "Venue", new { id = qrCode.VenueId });

                    var qrcode_file = this._venueService.GenerateQRCodeFromUrl(url);

                    this._venueService.UpdateVenueQRCode(qrCode.VenueId, qrcode_file);

                    return(RedirectToAction("Index"));
                }
                catch (Exception ex) {
                    this._logger.LogError(ex.Message);
                    ModelState.AddModelError("Εrror", ex.Message);
                }
            }

            return(View(qrCode));
        }
Exemplo n.º 12
0
        public QRCodeView(QRCodeViewModel viewModel)
        {
            InitializeComponent();

            DataContext = viewModel;
        }
Exemplo n.º 13
0
        public IActionResult QRCode()
        {
            var model = new QRCodeViewModel();

            return(View(model));
        }
Exemplo n.º 14
0
        public async Task <TravellerResponse> BookPass(BookedPassInformationViewModel bookingInfo)
        {
            _logger.LogInfo("Trying to book pass having id " + bookingInfo.PassInformationId + "with traveller id " + bookingInfo.TravellerDeviceId);
            try
            {
                //Get selected pass information based on id
                PassInformationViewModel passInformation = _mapper.Map <PassInformation, PassInformationViewModel>(await _passRepository.GetActivePass(bookingInfo.PassInformationId));
                if (passInformation == null)
                {
                    throw new Exception(string.Format(_messageHandler.GetMessage(ErrorMessagesEnum.InValidPassInformation)));
                }

                //Get active user based on device id
                Traveller travellerInfo    = new Traveller();
                var       isExistTraveller = _travellerRepository.GetTravellerByDeviceId(bookingInfo.TravellerDeviceId);
                if (isExistTraveller == null)
                {
                    //Add traveller information
                    travellerInfo.DeviceId   = bookingInfo.TravellerDeviceId;
                    travellerInfo.DeviceType = bookingInfo.TravellerDeviceType;
                    travellerInfo.IsActive   = true;

                    //Added new traveller
                    _travellerRepository.AddTraveller(travellerInfo);
                    _logger.LogInfo("Successfully added new traveller with device id " + bookingInfo.TravellerDeviceId);

                    //Once traveller info added then get the traveller id
                    isExistTraveller = _travellerRepository.GetTravellerByDeviceId(bookingInfo.TravellerDeviceId);
                }

                //Business logic goes here for booking pass information
                bookingInfo.TravellerId            = isExistTraveller.Id;
                bookingInfo.UniqueReferrenceNumber = "HST-" + bookingInfo.TravellerId + "-" + DateTime.Now.ToString("ddMMyyhhmmssff");
                bookingInfo.TransactionNumber      = DateTime.Now.ToString("ddMMyyhhmmssff");
                bookingInfo.BookingDate            = DateTime.Today;
                bookingInfo.TotalAmout             = (bookingInfo.Adult * passInformation.AdultPrice) + (bookingInfo.Child * passInformation.ChildPrice);
                bookingInfo.IsActive = true;
                bookingInfo.QRCode   = null;
                // QR code information to be stored with booking information id
                QRCodeViewModel qrCode = new QRCodeViewModel();
                //bookingInfo.PaymentStatus = true;
                //bookingInfo.IsActive = true;
                //bookingInfo.PaymentResponse = "Success";
                qrCode.IsActive = false;
                qrCode.BookedPassInformationId = bookingInfo.Id;
                qrCode.PassExpiredDuraionDate  = passInformation.PassExpiredDate;
                bookingInfo.QRCode             = qrCode;
                ///////////////////////////////////////////////////////////////
                if (bookingInfo.TotalAmout == 0)
                {
                    throw new Exception(string.Format(_messageHandler.GetMessage(ErrorMessagesEnum.InValidPassengerInformation)));
                }
                _travellerRepository.BookPass(_mapper.Map <BookedPassInformation>(bookingInfo));
                _logger.LogInfo("Successfully addded booking information");
                TravellerResponse response = new TravellerResponse(true, string.Format(_messageHandler.GetSuccessMessage(SuccessMessagesEnum.SuccessfullySaved)));
                response.Result = bookingInfo.UniqueReferrenceNumber;
                return(response);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(new TravellerResponse(false, ex.Message));
            }
        }
Exemplo n.º 15
0
        public IActionResult Index()
        {
            QRCodeViewModel qRCodeViewModel = new QRCodeViewModel();

            return(View(qRCodeViewModel));
        }
Exemplo n.º 16
0
 public QRCodePage(string SlotDateTime)
 {
     InitializeComponent();
     BindingContext = new QRCodeViewModel(Navigation, SlotDateTime);
 }
 //[CommonAction]
 public JsonResult CreateQRCode(QRCodeViewModel info)
 {
     return(Json(Barcode.Current.CreateQRCodeRaw(info), JsonRequestBehavior.AllowGet));
 }