public void SaveCountry(Country b)
        {
            var context = new TourEntities1();

            if (b.Id == 0)
            {

                context.Country.Add(b);
            }
            else
            {

                Country dbEntry = context.Country.Find(b.Id);
                if (dbEntry != null)
                {

                    dbEntry.Name = b.Name;
                    dbEntry.Description = b.Description;
                    dbEntry.ImageData = b.ImageData ?? dbEntry.ImageData;
                    dbEntry.ImageMimeType = b.ImageMimeType;

                }
            }

            context.SaveChanges();
        }
 public int SaveCountry(Country country)
 {
     return db.SaveItem(country);
 }
        public ActionResult EditCountry(Country country, HttpPostedFileBase image)
        {
            var context = new TourEntities1();

            if (ModelState.IsValid)
            {
                if (image != null)
                {
                    country.ImageMimeType = image.ContentType;
                    country.ImageData = new byte[image.ContentLength];
                    image.InputStream.Read(country.ImageData, 0, image.ContentLength);
                }
                SaveCountry(country);
                TempData["message"] = string.Format("{0} has been saved", country.Name);
                return RedirectToAction("Index");
            }
            else
            {
                // there is something wrong with the data values
                return View(country);
            }
        }