Example #1
0
        public JsonResult GenerateQRCode(string code)
        {
            string linkImg  = @"\imgQR\test\";
            string fileName = code + ".png";

            linkImg += fileName;
            string urlPath = this.Server.MapPath("~" + linkImg);
            //urlPath = System.IO.Path.Combine(urlPath, fileName);
            ProductDAO dao       = new ProductDAO();
            var        qrManager = dao.Model.QRManagers.FirstOrDefault(f => f.idProduct == code && f.isDeleted == 0);

            if (qrManager == null)
            {
                return(Json(false, "Không có yêu cầu của mã nông sản này, vui lòng kiểm tra lại!"));
            }
            if (qrManager != null && qrManager.accepted == 1)
            {
                return(Json(new ResultOfRequest(false, "Đã tạo mã QR cho nông sản này!")));
            }
            GenerateQR(urlPath, code);
            if (System.IO.File.Exists(urlPath))
            {
                var result = dao.AcceptQRRequest(code, linkImg);
                return(Json(result));
            }
            return(Json(new ResultOfRequest(false, "Không tìm thấy file!")));
        }