public ActionResult Search(Guid countryId)
        {
            var countriesResult = client.Get <List <SelectModel> >(APIUrls.CountryIdNames);
            var countryResult   = GetCountryById(countryId);
            var userResult      = client.Get <CMS_Db.Entity.User>(APIUrls.LoggedInUser);
            var selectList      = new SelectList(countriesResult.Data, "Id", "Name");
            var user            = (CMS_Entity.Db.User) this.HttpContext.Cache[KeyConstants.User.ToString()];

            var fevCountry = countryResult.Data.FavoriteUserCountries.FirstOrDefault(c => user.Id.Equals(c.UserId));

            if (fevCountry == null)
            {
                fevCountry = new FavoriteUserCountry()
                {
                    UserId = user.Id, CountryId = countryResult.Data.Id, IsFavorite = false
                };
            }

            SearchCountryViewModel searchCountry = new SearchCountryViewModel()
            {
                CountriesToSearch = selectList,
                Country           = countryResult.Data,
                FevCountry        = fevCountry,
            };

            return(View(searchCountry));
        }
        public ActionResult Edit([Bind(Include = "Id,UserId,CountryId,IsFavorite")] FavoriteUserCountry favoriteUserCountry)
        {
            if (ModelState.IsValid)
            {
                client.Put(APIUrls.UpdateFevUserCountry.Replace("{id}", favoriteUserCountry.Id.ToString()), favoriteUserCountry);
                return(RedirectToAction("Index"));
            }

            return(View(favoriteUserCountry));
        }
        public ActionResult Create([Bind(Include = "UserId,CountryId,IsFavorite")] FavoriteUserCountry favoriteUserCountry)
        {
            if (ModelState.IsValid)
            {
                favoriteUserCountry.IsFavorite = true;
                var result = client.Post(APIUrls.CreateFavCountry, favoriteUserCountry);
                return(RedirectToAction("Index"));
            }

            return(View("Index"));
        }
        // POST: api/FavoriteUserCountry
        public IHttpActionResult Post(FavoriteUserCountry favoriteUserCountry)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            favoriteUserCountry.Id = Guid.NewGuid();
            Repository.FavoriteUserCountries.Add(favoriteUserCountry);
            Repository.SaveChanges();

            return(Ok(favoriteUserCountry));;
        }
        // PUT: api/FavoriteUserCountry/5
        public IHttpActionResult Put(Guid id, FavoriteUserCountry favoriteUserCountry)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var favoriteUserCountryToUpdate = Repository.FavoriteUserCountries.Find(id);

            if (favoriteUserCountryToUpdate == null)
            {
                return(NotFound());
            }

            favoriteUserCountryToUpdate.IsFavorite = favoriteUserCountry.IsFavorite;
            //Repository.Entry(favoriteUserCountryToUpdate).State = EntityState.Modified;
            Repository.SaveChanges();

            return(Ok(favoriteUserCountry));
        }