public ActionResult EditSave(BONDAPPLICATION bONDAPPLICATION)
        {
            if (ModelState.IsValid)
            {
                /*var appScripts;*/ /*= Session["appScript"] != null ? Session["appScript"] as List<APPSCRIPT> : db.APPSCRIPTs.Where(b => b.BONDSCN.Equals(bONDAPPLICATION.BONDSCN)) as List<APPSCRIPT>;*/
                List <APPSCRIPT> appscripts = new List <APPSCRIPT>();

                if (Session["appScript"] != null)
                {
                    appscripts = Session["appScript"] as List <APPSCRIPT>;
                }
                else
                {
                    // appscripts = db.APPSCRIPTs.Where(b => b.BONDSCN == bONDAPPLICATION.BONDSCN).ToList();
                }
                //db.APPSCRIPTs.AddRange(appscripts);
                db.BONDAPPLICATIONs.Add(bONDAPPLICATION);
                db.Entry(bONDAPPLICATION.BENEFICIARY).State = EntityState.Modified;
                db.Entry(bONDAPPLICATION).State             = EntityState.Modified;
                db.SaveChanges();
                Session["appScript"] = null;
            }

            return(View());
        }
        public ActionResult DeleteConfirmed(string id)
        {
            BONDAPPLICATION bONDAPPLICATION = db.BONDAPPLICATIONs.Find(id);

            db.BONDAPPLICATIONs.Remove(bONDAPPLICATION);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(BONDAPPLICATION bONDAPPLICATION)

        {
            var appScripts = Session["appScript"] as List <APPSCRIPT>;

            db.APPSCRIPTs.AddRange(appScripts);
            db.BONDAPPLICATIONs.Add(bONDAPPLICATION);

            db.SaveChanges();
            Session["appScript"] = null;
            return(RedirectToAction("Succesfull"));
        }
        // GET: Application/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult((int)HttpStatusCode.BadRequest));
            }
            BONDAPPLICATION bONDAPPLICATION = db.BONDAPPLICATIONs.Find(id);

            if (bONDAPPLICATION == null)
            {
                return(HttpNotFound());
            }
            return(View(bONDAPPLICATION));
        }
        public ActionResult ApplicationNoWiseSave(BONDAPPLICATION model)
        {
            var application = db.BONDAPPLICATIONs.SingleOrDefault(o => o.BONDSCN == model.BONDSCN);

            if (application != null)
            {
                var singleOrDefault = db.STATUSINFOes.SingleOrDefault(o => o.STATUSCODE.Equals(model.STATUSCODE));
                if (singleOrDefault != null)
                {
                    application.STATUSCODE = singleOrDefault.STATUSCODE;
                }
            }
            db.Entry(application).State = EntityState.Modified;
            db.SaveChanges();
            return(View("Successfull"));
        }
        public ActionResult Create(FormCollection application)
        {
            BENEFICIARY _beneficiary = new BENEFICIARY()
            {
                //BONDSCN = application[2],//bond applicaiton no
                BENNAME  = application[38],              //beneficiary name
                BENFNAME = application[39],              //beneficiary fathers name
                BENMNAME = application[40],              //beneficiary mothers name
                BENDOB   = application[42].AsDateTime(), //beneficiary dateofbirth
                BENADDR  = application[41],              //beneficiary address
            };

            BONDAPPLICATION _bondapplication = new BONDAPPLICATION()
            {
                BONDCODE      = application[1],
                BONDSCN       = application[2],//bond applicaiton no===SHOULD BE USED IN MULTIPLE PLACE
                FILENO        = application[3].AsInt(),
                SCNDATE       = application[4].AsDateTime(),
                REINVDATE     = application[5].AsDateTime(),
                RESPONDDATE   = application[6].AsDateTime(),
                FBRCODE       = application[7],                 //issueing branch
                TOTALSCRIPT   = (short?)application[8].AsInt(), //total script
                BUYFNAME      = application[9],                 //buyer first name
                BUYMNAME      = application[10],                //buyier middle name
                BUYLNAME      = application[11],                //buyer lastname
                DOB           = application[12].AsDateTime(),   //buyer date of birth
                SEX           = application[13],                //sex
                DESIG         = application[14],                //designation
                COMNAME       = application[15],                //organisation
                COMADDR       = application[16],                //company address
                ABOARDADDR    = application[17],                //foreign address
                CNTYCODE      = application[18],                //country code
                LOCALADDR     = application[19],                //local address
                LOCALDIST     = application[20],                //district code
                LOCALTHANA    = application[21],                //thana
                PASSPORTNO    = application[22],                //passport no
                ISSUEPLACE    = application[23],                //passport issue place
                PASSISSUEDATE = application[24].AsDateTime(),   //passport issue date
                PAYMODE       = application[25],                //payment mode
                FCACNO        = application[26],                //fc account no
                FCBRCODE      = application[27],                //fc ac branch
                CURRCODE      = application[28],                //currency code
                VALUEDATE     = application[29].AsDateTime(),   //value date
                EXRATE        = application[30].AsDecimal(),    //currency rate
                AMOUNTFC      = application[31].AsDecimal(),    //amount in fc
                AMOUNTCR      = application[32].AsDecimal(),    // amount for credit
                FDDNO         = application[33],                //demand draft
                EXBANKCODE    = application[34],                //exbankcode or bank
                REMARKS       = application[35],                // remarks
                                                                //===================================BENEFICIARY======================================
                                                                //===================================OTHERS INFO======================================
                FNAME = application[36],                        //others fathersname
                MNAME = application[37],                        //others mothersname
                //APPSCRIPTs = Session["appScript"] as List<APPSCRIPT>,
                //BENEFICIARY = _beneficiary
            };

            //===============================BOND HOLDERS INFO========================================

            //==========================BOND SCRIPT======================================================
            //read the session
            //var appScript = Session["appScript"] as List<APPSCRIPT>;


            //add and save
            _context.BONDAPPLICATIONs.Add(_bondapplication);
            _context.SaveChanges();
            //_context.BENEFICIARies.Add(_beneficiary);
            //_context.SaveChanges();
            //_context.APPSCRIPTs.AddRange(appScript);
            //_context.SaveChanges();

            //clear the session appScript
            Session["appScript"] = null;

            return(RedirectToAction("NewApplication"));
        }