public ActionResult Create(CountryMasterVM c)
        {
            CountryMaster obj = new CountryMaster();
            int           max = (from a in db.CountryMasters orderby a.CountryID descending select a.CountryID).FirstOrDefault();

            if (max == null)
            {
                obj.CountryID   = 1;
                obj.CountryName = c.CountryName;
                obj.CountryCode = c.CountryCode;
                obj.IATACode    = c.IATACode;
            }
            else
            {
                obj.CountryID   = max + 1;
                obj.CountryName = c.CountryName;
                obj.CountryCode = c.CountryCode;
                obj.IATACode    = c.IATACode;
            }
            db.CountryMasters.Add(obj);
            db.SaveChanges();
            TempData["SuccessMsg"] = "You have successfully added Country.";

            return(RedirectToAction("Index"));
        }
        //
        // GET: /CountryMaster/

        public ActionResult Index()
        {
            var data = db.CountryMasters.ToList();
            List <CountryMasterVM> lst = new List <CountryMasterVM>();

            foreach (var Item in data)
            {
                CountryMasterVM obj = new CountryMasterVM();
                obj.CountryID   = Item.CountryID;
                obj.CountryName = Item.CountryName;
                obj.CountryCode = Item.CountryCode;
                obj.IATACode    = Item.IATACode;
                lst.Add(obj);
            }

            return(View(lst));
        }
        //
        // GET: /CountryMaster/Edit/5


        public ActionResult Edit(int id)
        {
            CountryMasterVM d    = new CountryMasterVM();
            var             data = (from c in db.CountryMasters where c.CountryID == id select c).FirstOrDefault();

            if (data == null)
            {
                return(HttpNotFound());
            }
            else
            {
                d.CountryID   = data.CountryID;
                d.CountryName = data.CountryName;
                d.CountryCode = data.CountryCode;
                d.IATACode    = data.IATACode;
            }
            return(View(d));
        }
        public ActionResult Edit(CountryMasterVM a)
        {
            CountryMaster d = new CountryMaster();

            d.CountryID   = a.CountryID;
            d.CountryName = a.CountryName;
            d.CountryCode = a.CountryCode;
            d.IATACode    = a.IATACode;

            //if (ModelState.IsValid)
            //{
            //    db.Entry(d).State = EntityState.Modified;
            //    db.SaveChanges();
            //    return RedirectToAction("Index");
            //}
            //return View();
            db.Entry(d).State = EntityState.Modified;
            db.SaveChanges();
            TempData["SuccessMsg"] = "You have successfully Updated Country.";

            return(RedirectToAction("Index"));
        }