public bool Put(int id, [FromBody] HospitalTransactionEntity hspTransEntity)
 {
     if (id > 0)
     {
         return(_hspTransServices.UpdateHspTransaction(id, hspTransEntity));
     }
     return(false);
 }
        public HttpResponseMessage Post([FromBody] HospitalTransactionEntity hspTransEntity)
        {
            Int32  intTranId;
            string strYear;
            string strMonth;
            string strDays;
            string strDate;

            strYear  = hspTransEntity.WasteDate.Year.ToString();
            strMonth = hspTransEntity.WasteDate.Month.ToString();
            strDays  = hspTransEntity.WasteDate.Day.ToString();

            strDate = strYear + "-" + strMonth + "-" + strDays;

            string strAllImagePath;
            string strRedImagePath;
            string strYellowImagePath;
            string strBlueImagePath;
            string strWhiteImagePath;


            strAllImagePath    = "http://app.bmwbarcode.com/Hospital/QrCode/" + hspTransEntity.HospitalName.Trim() + "_" + "R_" + hspTransEntity.RedBag + "_" + "Y" + "_" + hspTransEntity.YellowBag + "_" + "B" + "_" + hspTransEntity.BlueBag + "_" + "W" + "_" + hspTransEntity.WhiteBag + "_" + strDate + "_" + "!" + ".jpeg";
            strRedImagePath    = "http://app.bmwbarcode.com/Hospital/QrCode/" + hspTransEntity.HospitalName.Trim() + "_" + "R_" + hspTransEntity.RedBag + "_" + strDate + "_" + "!" + ".jpeg";
            strYellowImagePath = "http://app.bmwbarcode.com/Hospital/QrCode/" + hspTransEntity.HospitalName.Trim() + "_" + "Y_" + hspTransEntity.YellowBag + "_" + strDate + "_" + "!" + ".jpeg";
            strBlueImagePath   = "http://app.bmwbarcode.com/Hospital/QrCode/" + hspTransEntity.HospitalName.Trim() + "_" + "B_" + hspTransEntity.BlueBag + "_" + strDate + "_" + "!" + ".jpeg";
            strWhiteImagePath  = "http://app.bmwbarcode.com/Hospital/QrCode/" + hspTransEntity.HospitalName.Trim() + "_" + "W_" + hspTransEntity.WhiteBag + "_" + strDate + "_" + "!" + ".jpeg";

            hspTransEntity.BlueImgPath   = strBlueImagePath;
            hspTransEntity.RedImgPath    = strRedImagePath;
            hspTransEntity.YellowImgPath = strYellowImagePath;
            hspTransEntity.WhiteImgPath  = strWhiteImagePath;
            hspTransEntity.AllImgPath    = strAllImagePath;


            var hsps = _hspTransServices.CreateHspTransaction(hspTransEntity);

            // return _hspTransServices.CreateHspTransaction(hspTransEntity);

            getQRCodeAll(hspTransEntity);
            getQRCodeRed(hspTransEntity);
            getQRCodeYellow(hspTransEntity);
            getQRCodeBlue(hspTransEntity);
            getQRCodeWhite(hspTransEntity);


            if (hsps != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, hsps));
            }
            return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No Transaction found for this id"));

            //  return Request.CreateResponse(HttpStatusCode.OK, hspTransEntity);
        }
        protected void getQRCodeWhite(HospitalTransactionEntity hspTransEntity)
        {
            DateTime WasteDate;
            string   strYear;
            string   strMonth;
            string   strDays;
            string   strDate;

            strYear  = hspTransEntity.WasteDate.Year.ToString();
            strMonth = hspTransEntity.WasteDate.Month.ToString();
            strDays  = hspTransEntity.WasteDate.Day.ToString();

            strDate = strYear + "-" + strMonth + "-" + strDays;
            //codeAll = Company + "_" + "R" + "_" + Red + "_" + "Y" + "_" + Red + "_" + "B" + "_" + Blue + "_" + "W" + "_" + White + "_" + testDate + "_" + "!";
            // string qrcode = hspTransEntity.HospitalName + "_" + "R_" + hspTransEntity.RedBag + "_" + "Y" + "_" + hspTransEntity.YellowBag + "_" + "B" + "_" + hspTransEntity.BlueBag  + "_" + "W" + "_" + hspTransEntity.WhiteBag  + "_" + hspTransEntity.WasteDate  + "_" + "!";
            string qrcode = hspTransEntity.HospitalName.Trim() + "_" + "W_" + hspTransEntity.WhiteBag + "_" + strDate + "_" + "!";

            using (MemoryStream ms = new MemoryStream())
            {
                QRCodeGenerator        qrGenerator = new QRCodeGenerator();
                QRCodeGenerator.QRCode qrCode      = qrGenerator.CreateQrCode(qrcode, QRCodeGenerator.ECCLevel.Q);
                using (Bitmap bitMap = qrCode.GetGraphic(20))
                {
                    bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                    System.Drawing.Image img = System.Drawing.Image.FromStream(ms);

                    System.Drawing.Image imgs  = ResizeByWidth(img, 150);
                    System.Drawing.Image imgss = ResizeByHeight(imgs, 150);
                    //                   string pad = img.Save(HttpContext.Current.Server.MapPath("Hospital/QrCode/" + "Test.Jpeg", System.Drawing.Imaging.ImageFormat.Jpeg));
                    //img.Save(HttpContext.Current.Server.MapPath("~/Hospital/QrCode/" + qrcode+".Jpeg"));
                    // img.Save(HttpContext.Current.Server.MapPath("~/Hospital/QrCode/" + qrcode + ".Jpeg"));
                    imgss.Save(HttpContext.Current.Server.MapPath("~/Hospital/QrCode/" + qrcode + ".Jpeg"));

                    //img.Save(HttpContext.Current.Server.MapPath("Hospital/QrCode/" + qrcode + ".Jpeg"));

                    //  ViewBag.QRCodeImage = "data:image/png;base64," + Convert.ToBase64String(ms.ToArray());

                    //  var fs = new BinaryWriter(new FileStream("Hospital/QRCode/" + qrcode + ".jpeg"), FileMode.Append, FileAccess.Write));
                }
            }
        }