public ActionResult DeleteConfirmed(int id)
        {
            MasterCurrency masterCurrency = db.masterCurrencies.Find(id);

            db.masterCurrencies.Remove(masterCurrency);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(MasterCurrency cvm, HttpPostedFileBase imgfile)
        {
            string path = "";
            var    cat  = db.masterCurrencies.Where(x => x.ID == cvm.ID).FirstOrDefault();

            if (cat.Symbol == Session["FileName"].ToString() && imgfile == null)
            {
                path = cat.Symbol;
            }
            else
            {
                path = uploadimgfile1(imgfile);
            }
            if (path.Equals("-1") && cat.Symbol != Session["FileName"].ToString())
            {
                ViewBag.error = "Image could not be uploaded....";
            }
            else
            {
                cat.CName      = cvm.CName;
                cat.Symbol     = path;
                cat.cat_status = 1;
                //if (cvm.Code == null)
                //{
                //    cat.Code = "00001";//cvm.Code;
                //}
                //else
                //{
                //    int maxcode = Convert.ToInt32(cvm.Code);
                //    maxcode = maxcode + 1;
                //    //int getfinalcode = maxcode + maxcode;
                //    cat.Code = "0000" + maxcode.ToString();
                //}
                cat.Code         = cvm.Code;
                cat.Symbol       = path;
                cat.cat_status   = 1;
                cat.ExchangeRate = cvm.ExchangeRate;
                cat.EmailAddress = cvm.EmailAddress;
                cat.isActive     = false;
                if (cvm.statusex == "Yes")
                {
                    cat.isActive = true;
                }

                db.masterCurrencies.Add(cat);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View());
        }
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MasterCurrency masterCurrency = db.masterCurrencies.Find(id);

            if (masterCurrency == null)
            {
                return(HttpNotFound());
            }
            return(View(masterCurrency));
        }
        // GET: MasterCurrencies/Create
        public ActionResult Create()
        {
            var getprodcut = db.masterCurrencies.FirstOrDefault();
            var mspro      = new MasterCurrency();

            if (getprodcut != null)
            {
                var maxcode = db.masterCurrencies.OrderByDescending(x => x.ID).Select(x => x.Code).FirstOrDefault();
                if (maxcode != null)
                {
                    mspro.Code = maxcode.ToString();
                }
            }
            return(View(mspro));
        }
        //[Bind(Include = "ID,CName,Symbol,ExchangeRate,Code,isActive")]
        // GET: MasterCurrencies/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MasterCurrency masterCurrency = db.masterCurrencies.Find(id);

            Session["FileName"] = masterCurrency.Symbol;
            if (masterCurrency == null)
            {
                return(HttpNotFound());
            }
            return(View(masterCurrency));
        }
        public ActionResult Create(MasterCurrency cvm, HttpPostedFileBase imgfile)
        {
            string path = uploadimgfile(imgfile);

            if (path.Equals("-1"))
            {
                ViewBag.error = "Image could not be uploaded....";
            }
            else
            {
                MasterCurrency cat = new MasterCurrency();
                cat.CName      = cvm.CName;
                cat.Symbol     = path;
                cat.cat_status = 1;
                if (cvm.Code == null)
                {
                    cat.Code = "00001";//cvm.Code;
                }
                else
                {
                    int maxcode = Convert.ToInt32(cvm.Code);
                    maxcode = maxcode + 1;
                    //int getfinalcode = maxcode + maxcode;
                    cat.Code = "0000" + maxcode.ToString();
                }
                cat.ExchangeRate = cvm.ExchangeRate;
                cat.EmailAddress = cvm.EmailAddress;
                cat.isActive     = false;
                if (cvm.statusex == "Yes")
                {
                    cat.isActive = true;
                }

                db.masterCurrencies.Add(cat);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View());
        }