public ActionResult Add(int?country_id)
        {
            Country_State_ExtraShipping model = new Country_State_ExtraShipping()
            {
                CountryId = country_id.HasValue ? country_id.Value : 0
            };

            return(View(model));
        }
        public ActionResult Update(Country_State_ExtraShipping model)
        {
            if (Db.Count <Country>(x => (x.Id == model.CountryId)) == 0)
            {
                return(JsonError("Please choose field » Country."));
            }
            if (string.IsNullOrEmpty(model.State))
            {
                return(JsonError("Please enter field » State."));
            }
            if (model.Amount < 0)
            {
                model.Amount = 0;
            }
            Country_State_ExtraShipping current_item = new Country_State_ExtraShipping();

            if (model.Id != 0)
            {
                var z = Db.Where <Country_State_ExtraShipping>(m => m.Id == model.Id);
                if (z.Count == 0)
                {
                    return(JsonError("Please don't try to hack us."));
                }
                current_item = z.First();
            }
            if (Db.Count <Country_State_ExtraShipping>(x => (
                                                           (model.Id == 0 && x.CountryId == model.CountryId && x.State == model.State) ||
                                                           (model.Id != 0 && x.CountryId == model.CountryId && x.State == model.State && x.Id != model.Id))) != 0)
            {
                return(JsonError("State » is already used."));
            }
            if (model.Id == 0)
            {
                Db.Insert <Country_State_ExtraShipping>(model);
            }
            else
            {
                Db.Update <Country_State_ExtraShipping>(model);
            }

            return(JsonSuccess(Url.Action("Index", new { country_id = model.CountryId })));
        }